diff --git a/cde/programs/nsgmls/Allocator.C b/cde/programs/nsgmls/Allocator.C deleted file mode 100644 index 466305f95..000000000 --- a/cde/programs/nsgmls/Allocator.C +++ /dev/null @@ -1,127 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: Allocator.C /main/1 1996/07/29 16:45:56 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#include "splib.h" -#include "Allocator.h" -#include "macros.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -Allocator::Allocator(size_t maxSize, unsigned blocksPerSegment) -: objectSize_(maxSize), - blocksPerSegment_(blocksPerSegment), - freeList_(0), - segments_(0) -{ -} - -Allocator::~Allocator() -{ - SegmentHeader *p = segments_; - while (p) { - SegmentHeader *tem = p->next; - if (p->liveCount == 0) - ::operator delete(p); - else - p->freeList = 0; - p = tem; - } -} - -void *Allocator::alloc(size_t sz) -{ - if (sz > objectSize_) - tooBig(sz); - Block *tem = freeList_; - if (tem) { - tem->header.seg->liveCount += 1; - freeList_ = tem->next; - return &(tem->next); - } - else - return alloc1(); -} - -void *Allocator::allocSimple(size_t sz) -{ - BlockHeader *p = (BlockHeader *)::operator new(sz + sizeof(BlockHeader)); - p->seg = 0; - return p + 1; -} - -void Allocator::free(void *p) -{ - BlockHeader *b = ((BlockHeader *)p) - 1; - SegmentHeader *seg = b->seg; - if (seg == 0) - ::operator delete(b); - else { - Block **freeList = seg->freeList; - if (freeList == 0) { - seg->liveCount -= 1; - if (seg->liveCount == 0) - ::operator delete(seg); - } - else { - ((Block *)b)->next = *freeList; - *freeList = (Block *)b; - seg->liveCount -= 1; - } - } -} - -void *Allocator::alloc1() -{ - SegmentHeader *seg - = (SegmentHeader *)::operator new(sizeof(SegmentHeader) - + ((objectSize_ + sizeof(BlockHeader)) - * blocksPerSegment_)); - seg->next = segments_; - segments_ = seg; - seg->liveCount = 1; - seg->freeList = &freeList_; - char *p = (char *)(seg + 1); - Block *head = 0; - for (size_t n = blocksPerSegment_; n > 0; n--) { - ((Block *)p)->next = head; - ((Block *)p)->header.seg = seg; - head = (Block *)p; - p += sizeof(BlockHeader) + objectSize_; - } - freeList_ = head->next; - return &(head->next); -} - -void Allocator::tooBig(size_t sz) -{ - ASSERT(sz <= objectSize_); -} - -#ifdef SP_NAMESPACE -} -#endif diff --git a/cde/programs/nsgmls/Allocator.h b/cde/programs/nsgmls/Allocator.h deleted file mode 100644 index 6b7f01bdb..000000000 --- a/cde/programs/nsgmls/Allocator.h +++ /dev/null @@ -1,90 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: Allocator.h /main/1 1996/07/29 16:46:04 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#ifndef Allocator_INCLUDED -#define Allocator_INCLUDED 1 - -#include - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -class SP_API Allocator { -public: - Allocator(size_t maxSize, unsigned blocksPerSegment); - ~Allocator(); - void *alloc(size_t); - static void *allocSimple(size_t); - static void free(void *); - - // It would be nice to make these private, but some compilers have problems. - union ForceAlign { - unsigned long n; - struct SP_API { - char c; - } s; - char *cp; - long *lp; - }; - struct SegmentHeader; - union BlockHeader; - friend union BlockHeader; - union BlockHeader { - SegmentHeader *seg; - ForceAlign align; - }; - struct Block; - friend struct Block; - struct SP_API Block { - BlockHeader header; - Block *next; - }; - friend struct SegmentHeader; - struct SP_API SegmentHeader { - union { - Block **freeList; - ForceAlign align; - }; - unsigned liveCount; - SegmentHeader *next; - }; -private: - Allocator(const Allocator &); // undefined - Allocator &operator=(const Allocator &); // undefined - Block *freeList_; - size_t objectSize_; - unsigned blocksPerSegment_; - SegmentHeader *segments_; - void *alloc1(); - void tooBig(size_t); -}; - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* not Allocator_INCLUDED */ diff --git a/cde/programs/nsgmls/ArcEngine.C b/cde/programs/nsgmls/ArcEngine.C deleted file mode 100644 index 98e67d605..000000000 --- a/cde/programs/nsgmls/ArcEngine.C +++ /dev/null @@ -1,1845 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: ArcEngine.C /main/1 1996/07/29 16:46:09 cde-hp $ */ -// Copyright (c) 1996 James Clark -// See the file COPYING for copying permission. - -#ifdef __GNUG__ -#pragma implementation -#endif - -#include "splib.h" -#include "ArcEngine.h" -#include "ArcProcessor.h" -#include "Vector.h" -#include "NCVector.h" -#include "IQueue.h" -#include "ArcEngineMessages.h" -#include "MessageArg.h" -#include "ParserOptions.h" -#include "SgmlParser.h" -#include "Allocator.h" -#include "LinkProcess.h" -#include "macros.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -static const char notationSetArchPublicId[] - = "ISO/IEC 10744//NOTATION AFDR ARCBASE \ -Notation Set Architecture Definition Document//EN"; - -static const size_t sizes[] = { - sizeof(StartElementEvent), - sizeof(EndElementEvent), - sizeof(ImmediateDataEvent), - sizeof(SdataEntityEvent), - sizeof(EndPrologEvent), - sizeof(CdataEntityEvent), - sizeof(SdataEntityEvent), - sizeof(ExternalDataEntityEvent), - sizeof(OpenElement) -}; - -static -size_t maxSize(const size_t *v, size_t n) -{ - size_t max = 0; - for (size_t i = 0; i < n; i++) { - if (v[i] > max) - max = v[i]; - } - return max; -} - -const unsigned invalidAtt = unsigned(-1); -const unsigned contentPseudoAtt = unsigned(-2); - -class DelegateEventHandler : public EventHandler { -public: -#define EVENT(C, f) void f(C *ev) { delegateTo_->f(ev); } -#include "events.h" -#undef EVENT -protected: - EventHandler *delegateTo_; -}; - -class QueueEventHandler : public EventHandler, public IQueue { -public: -#define EVENT(C, f) void f(C *ev) { ev->copyData(); append(ev); } -#include "events.h" -#undef EVENT -}; - -// This just passes through messages. - -class NullEventHandler : public EventHandler { -public: - NullEventHandler(Messenger &mgr) : mgr_(&mgr) { } - void message(MessageEvent *event) { - mgr_->dispatchMessage(event->message()); - } -private: - Messenger *mgr_; -}; - -class ArcEngineImpl : public DelegateEventHandler, private Messenger { -public: - ArcEngineImpl(Messenger &mgr, - const SgmlParser *parser, - ArcDirector &director, - SP_CONST SP_VOLATILE sig_atomic_t *cancelPtr, - const Notation *, - const Vector &name, - const SubstTable *table); - ~ArcEngineImpl(); - void sgmlDecl(SgmlDeclEvent *); - void appinfo(AppinfoEvent *); - void startElement(StartElementEvent *); - void endElement(EndElementEvent *); - void data(DataEvent *); - void sdataEntity(SdataEntityEvent *); - void externalDataEntity(ExternalDataEntityEvent *); - void pi(PiEvent *); - void endProlog(EndPrologEvent *); - void startDtd(StartDtdEvent *); - void endDtd(EndDtdEvent *); - void startLpd(StartLpdEvent *); - void endLpd(EndLpdEvent *); - void uselink(UselinkEvent *); - size_t nBases() const { return arcProcessors_.size(); } - EventHandler *delegateHandler() { return eventHandler_; } -private: - void dispatchMessage(const Message &); - void dispatchMessage(Message &); - void initMessage(Message &); - - EventHandler *eventHandler_; - NCVector arcProcessors_; - ConstPtr sd_; - ConstPtr syntax_; - StringC arcBase_; - int stage_; - QueueEventHandler eventQueue_; - NullEventHandler nullHandler_; - const SgmlParser *parser_; - Location currentLocation_; - unsigned gatheringContent_; - Text content_; - unsigned startAgain_; - Allocator allocator_; - StringC appinfo_; - const AttributeList *linkAttributes_; - LinkProcess linkProcess_; - Boolean haveLinkProcess_; - Vector docName_; - ArcDirector *director_; - Messenger *mgr_; - SP_CONST SP_VOLATILE sig_atomic_t *cancelPtr_; -}; - - -void ArcEngine::parseAll(SgmlParser &parser, - Messenger &mgr, - ArcDirector &director, - SP_CONST SP_VOLATILE sig_atomic_t *cancelPtr) -{ - ArcEngineImpl wrap(mgr, &parser, director, cancelPtr, - 0, Vector(), 0); - parser.parseAll(wrap, cancelPtr); -} - -EventHandler * -SelectOneArcDirector::arcEventHandler(const Notation *, - const Vector &name, - const SubstTable *table) -{ - if (name.size() != select_.size()) - return 0; - for (size_t i = 0; i < name.size(); i++) { - StringC tem(select_[i]); - table->subst(tem); - if (name[i] != tem) - return 0; - } - return eh_; -} - -void SelectOneArcDirector::dispatchMessage(const Message &msg) -{ - eh_->message(new MessageEvent(msg)); -} - -void SelectOneArcDirector::dispatchMessage(Message &msg) -{ - eh_->message(new MessageEvent(msg)); -} - -ArcEngineImpl::ArcEngineImpl(Messenger &mgr, - const SgmlParser *parser, - ArcDirector &director, - SP_CONST SP_VOLATILE sig_atomic_t *cancelPtr, - const Notation *notation, - const Vector &docName, - const SubstTable *table) - -: director_(&director), mgr_(&mgr), cancelPtr_(cancelPtr), - parser_(parser), stage_(0), - gatheringContent_(0), startAgain_(0), haveLinkProcess_(0), - allocator_(maxSize(sizes, SIZEOF(sizes)), 50), - nullHandler_(mgr), docName_(docName), linkAttributes_(NULL) -{ - eventHandler_ = director.arcEventHandler(notation, docName, table); - if (!eventHandler_) - eventHandler_ = &nullHandler_; - delegateTo_ = eventHandler_; -} - -ArcEngineImpl::~ArcEngineImpl() -{ - for (size_t i = 0; i < arcProcessors_.size(); i++) - if (arcProcessors_[i].valid()) - arcProcessors_[i].checkIdrefs(); -} - -void ArcEngineImpl::appinfo(AppinfoEvent *event) -{ - const StringC *str; - if (event->literal(str)) - appinfo_ = *str; - DelegateEventHandler::appinfo(event); -} - -void ArcEngineImpl::pi(PiEvent *event) -{ - currentLocation_ = event->location(); - if (stage_ == 1 - && arcBase_.size() - && event->dataLength() > arcBase_.size()) { - Boolean match = 1; - for (size_t i = 0; i < arcBase_.size() && match; i++) - if ((*syntax_->generalSubstTable())[event->data()[i]] != arcBase_[i]) - match = 0; - if (!syntax_->isS(event->data()[arcBase_.size()])) - match = 0; - if (match) { - size_t i = arcBase_.size(); - size_t dataLength = event->dataLength(); - const Char *data = event->data(); - for (;;) { - while (i < dataLength && syntax_->isS(data[i])) - i++; - if (i >= dataLength) - break; - size_t start = i++; - while (i < dataLength && !syntax_->isS(data[i])) - i++; - StringC name(data + start, i - start); - syntax_->generalSubstTable()->subst(name); - arcProcessors_.resize(arcProcessors_.size() + 1); - arcProcessors_.back().setName(name); - } - } - } - DelegateEventHandler::pi(event); -} - -void ArcEngineImpl::endProlog(EndPrologEvent *event) -{ - currentLocation_ = event->location(); - for (size_t i = 0; i < arcProcessors_.size(); i++) - arcProcessors_[i].init(*event, - sd_, - syntax_, - parser_, - this, - docName_, - *director_, - cancelPtr_); - if (!event->lpdPointer().isNull()) { - haveLinkProcess_ = 1; - linkProcess_.init(event->lpdPointer()); - } - DelegateEventHandler::endProlog(event); -} - -void ArcEngineImpl::startDtd(StartDtdEvent *event) -{ - stage_++; - DelegateEventHandler::startDtd(event); -} - -void ArcEngineImpl::endDtd(EndDtdEvent *event) -{ - stage_++; - DelegateEventHandler::endDtd(event); -} - -void ArcEngineImpl::startLpd(StartLpdEvent *event) -{ - if (event->active()) - stage_ = 1; - DelegateEventHandler::startLpd(event); -} - -void ArcEngineImpl::endLpd(EndLpdEvent *event) -{ - stage_++; - DelegateEventHandler::endLpd(event); -} - -void ArcEngineImpl::sgmlDecl(SgmlDeclEvent *event) -{ - currentLocation_ = event->location(); - sd_ = event->sdPointer(); - syntax_ = event->instanceSyntaxPointer(); - arcBase_ = sd_->execToDoc("ArcBase"); - syntax_->generalSubstTable()->subst(arcBase_); - Boolean atStart = 1; - for (size_t i = 0; i < appinfo_.size(); i++) - if (syntax_->isS(appinfo_[i])) - atStart = 1; - else if (atStart) { - if (i + 7 > appinfo_.size()) - break; - StringC tem(appinfo_.data() + i, 7); - syntax_->generalSubstTable()->subst(tem); - if (tem == arcBase_) { - if (i + 7 == appinfo_.size() || syntax_->isS(appinfo_[i + 7])) - break; - if (appinfo_[i + 7] == sd_->execToDoc('=')) { - arcBase_.resize(0); - for (size_t j = i + 7; j < appinfo_.size(); j++) { - if (syntax_->isS(appinfo_[j])) - break; - arcBase_ += appinfo_[j]; - } - syntax_->generalSubstTable()->subst(arcBase_); - break; - } - } - atStart = 0; - } - DelegateEventHandler::sgmlDecl(event); -} - -void ArcEngineImpl::startElement(StartElementEvent *event) -{ - if (gatheringContent_) { - gatheringContent_++; - DelegateEventHandler::startElement(event); - return; - } - currentLocation_ = event->location(); - const Text *contentP; - size_t start; - if (startAgain_) { - start = startAgain_ - 1; - contentP = &content_; - startAgain_ = 0; - } - else { - contentP = 0; - start = 0; - if (haveLinkProcess_) { - const ResultElementSpec *resultElementSpec; - linkProcess_.startElement(event->elementType(), - event->attributes(), - event->location(), - *this, // Messenger & - linkAttributes_, - resultElementSpec); - } - else - linkAttributes_ = 0; - } - for (size_t i = start; i < arcProcessors_.size(); i++) { - if (arcProcessors_[i].valid()) { - if (!arcProcessors_[i].processStartElement(*event, - linkAttributes_, - contentP, - allocator_)) { - ASSERT(contentP == 0); - startAgain_ = i + 1; - gatheringContent_ = 1; - delegateTo_ = &eventQueue_; - DelegateEventHandler::startElement(event); - return; - } - } - } - - content_.clear(); - DelegateEventHandler::startElement(event); -} - -void ArcEngineImpl::data(DataEvent *event) -{ - const Entity *entity = event->entity(); - if (gatheringContent_) { - if (entity) - content_.addCdata(entity->asInternalEntity(), - event->location().origin()); - else { - // Do attribute value literal interpretation. - Location loc(event->location()); - for (size_t i = 0; i < event->dataLength(); i++, loc += 1) { - Char ch = event->data()[i]; - if (syntax_->isS(ch) && ch != syntax_->space()) { - if (ch == syntax_->standardFunction(Syntax::fRS)) - content_.ignoreChar(ch, loc); - else - content_.addChar(syntax_->space(), - Location(new ReplacementOrigin(loc, ch), 0)); - } - else - content_.addChar(ch, loc); - } - } - } - else { - currentLocation_ = event->location(); - for (size_t i = 0; i < arcProcessors_.size(); i++) { - if (arcProcessors_[i].valid() && arcProcessors_[i].processData()) { - if (entity) - arcProcessors_[i].docHandler() - .data(new (allocator_) CdataEntityEvent(entity->asInternalEntity(), - event->location().origin())); - else - arcProcessors_[i].docHandler() - .data(new (allocator_) ImmediateDataEvent(event->type(), - event->data(), - event->dataLength(), - event->location(), - 0)); - } - } - } - DelegateEventHandler::data(event); -} - -void ArcEngineImpl::sdataEntity(SdataEntityEvent *event) -{ - if (gatheringContent_) { - content_.addSdata(event->entity()->asInternalEntity(), - event->location().origin()); - return; - } - else { - currentLocation_ = event->location(); - for (size_t i = 0; i < arcProcessors_.size(); i++) { - if (arcProcessors_[i].valid() && arcProcessors_[i].processData()) { - const Entity *entity = event->entity(); - arcProcessors_[i].docHandler() - .sdataEntity(new (allocator_) - SdataEntityEvent(entity->asInternalEntity(), - event->location().origin())); - } - } - } - DelegateEventHandler::sdataEntity(event); -} - -void ArcEngineImpl::externalDataEntity(ExternalDataEntityEvent *event) -{ - if (!gatheringContent_) { - currentLocation_ = event->location(); - for (size_t i = 0; i < arcProcessors_.size(); i++) { - if (arcProcessors_[i].valid() - && arcProcessors_[i].processData()) { - ConstPtr entity - = arcProcessors_[i].dtdPointer() - ->lookupEntity(0, event->entity()->name()); - if (!entity.isNull()) { - ConstPtr oldOrigin = event->entityOrigin(); - Owner markup; - if (oldOrigin->markup()) - markup = new Markup(*oldOrigin->markup()); - ConstPtr newOrigin - = new EntityOrigin(entity, - oldOrigin->parent(), - oldOrigin->refLength(), - markup); - arcProcessors_[i].docHandler() - .externalDataEntity(new (allocator_) - ExternalDataEntityEvent(entity->asExternalDataEntity(), - newOrigin)); - } - // otherwise entity is not architectural - } - } - } - DelegateEventHandler::externalDataEntity(event); -} - -void ArcEngineImpl::endElement(EndElementEvent *event) -{ - while (gatheringContent_) { - if (--gatheringContent_ > 0) { - DelegateEventHandler::endElement(event); - return; - } - delegateTo_ = delegateHandler(); - // Clear out eventQueue_ in case handling the events - // causes events to be queued again. - IQueue tem; - tem.swap(eventQueue_); - while (!tem.empty()) - tem.get()->handle(*this); - } - currentLocation_ = event->location(); - for (size_t i = 0; i < arcProcessors_.size(); i++) - if (arcProcessors_[i].valid()) - arcProcessors_[i].processEndElement(*event, allocator_); - DelegateEventHandler::endElement(event); - if (haveLinkProcess_) - linkProcess_.endElement(); -} - -void ArcEngineImpl::uselink(UselinkEvent *event) -{ - if (!gatheringContent_) - linkProcess_.uselink(event->linkSet(), - event->restore(), - event->lpd().pointer()); - DelegateEventHandler::uselink(event); -} - -void ArcEngineImpl::dispatchMessage(const Message &msg) -{ - mgr_->dispatchMessage(msg); -} - -void ArcEngineImpl::dispatchMessage(Message &msg) -{ - mgr_->dispatchMessage(msg); -} - -void ArcEngineImpl::initMessage(Message &msg) -{ - mgr_->initMessage(msg); - msg.loc = currentLocation_; -} - -ArcProcessor::ArcProcessor() -: errorIdref_(1), notationSetArch_(0), docHandler_(0), arcAuto_(1), - arcDtdIsParam_(0), valid_(false), mgr_(NULL), director_(NULL), docIndex_(0) -{ -} - -void ArcProcessor::setName(const StringC &name) -{ - name_ = name; -} - -const Syntax &ArcProcessor::attributeSyntax() const -{ - return *docSyntax_; -} - -ConstPtr ArcProcessor::getAttributeNotation(const StringC &name, - const Location &) -{ - if (!metaDtd_.isNull()) - return metaDtd_->lookupNotation(name); - return 0; -} - -ConstPtr ArcProcessor::getAttributeEntity(const StringC &name, - const Location &) -{ - // FIXME What about default entity - if (!notationSetArch_ && !metaDtd_.isNull()) - return metaDtd_->lookupEntity(0, name); - return 0; -} - -void ArcProcessor::noteCurrentAttribute(size_t i, AttributeValue *value) -{ - if (valid_ && !notationSetArch_) - currentAttributes_[i] = value; -} - -ConstPtr ArcProcessor::getCurrentAttribute(size_t i) const -{ - if (notationSetArch_) - return 0; - return currentAttributes_[i]; -} - -// This code is the same as in the main parser. -// Once handling of ID/IDREF in architectures has been clarified. -// Maybe factor out into AttributeContext. - -Boolean ArcProcessor::defineId(const StringC &str, const Location &loc, - Location &prevLoc) -{ - if (!valid_) - return 1; - Id *id = lookupCreateId(str); - if (id->defined()) { - prevLoc = id->defLocation(); - return 0; - } - id->define(loc); - return 1; -} - -void ArcProcessor::noteIdref(const StringC &str, const Location &loc) -{ - if (!valid_ || !errorIdref_) - return; - Id *id = lookupCreateId(str); - if (!id->defined()) - id->addPendingRef(loc); -} - -Id *ArcProcessor::lookupCreateId(const StringC &name) -{ - Id *id = idTable_.lookup(name); - if (!id) { - id = new Id(name); - idTable_.insert(id); - } - return id; -} - -void ArcProcessor::checkIdrefs() -{ - NamedTableIter iter(idTable_); - Id *id; - while ((id = iter.next()) != 0) { - for (size_t i = 0; i < id->pendingRefs().size(); i++) { - Messenger::setNextLocation(id->pendingRefs()[i]); - message(ArcEngineMessages::missingId, StringMessageArg(id->name())); - } - } -} - -void ArcProcessor::init(const EndPrologEvent &event, - const ConstPtr &sd, - const ConstPtr &syntax, - const SgmlParser *parentParser, - Messenger *mgr, - const Vector &superName, - ArcDirector &director, - SP_CONST SP_VOLATILE sig_atomic_t *cancelPtr) -{ - director_ = &director; - mgr_ = mgr; - docSyntax_ = syntax; - docSd_ = sd; - mgr_ = mgr; - valid_ = 0; - docDtd_ = event.dtdPointer(); - metaSyntax_ = docSyntax_; - mayDefaultAttribute_ = 1; - docSyntax_->generalSubstTable()->subst(name_); - Vector docName(superName); - docName.push_back(name_); - ConstPtr notation; - if (name_ == docSyntax_->rniReservedName(Syntax::rNOTATION)) { - notationSetArch_ = 1; - supportAtts_[rArcNamrA] = docSd_->execToDoc("NOTNAMES"); - supportAtts_[rArcSuprA] = docSd_->execToDoc("NOTSUPR"); - } - else { - notation = docDtd_->lookupNotation(name_); - if (!notation.isNull()) { - ConstPtr notAttDef = notation->attributeDef(); - attributeList_.init(notAttDef); - attributeList_.finish(*this); - supportAttributes(attributeList_); - // FIXME make sure locations in error messages are right - if (notation->externalId().publicIdString() - && (*notation->externalId().publicIdString() - == docSd_->execToDoc(notationSetArchPublicId))) { - notationSetArch_ = 1; - } - } - else - message(ArcEngineMessages::noArcNotation, StringMessageArg(name_)); - } - ArcEngineImpl *engine - = new ArcEngineImpl(*mgr, parentParser, director, cancelPtr, - notation.pointer(), - docName, - docSyntax_->generalSubstTable()); - docHandler_ = engine; - ownEventHandler_ = engine; - if (notationSetArch_) { - initNotationSet(event.location()); - return; - } - if (supportAtts_[rArcDocF].size() == 0) - supportAtts_[rArcDocF] = name_; - if (supportAtts_[rArcFormA].size() == 0) - supportAtts_[rArcFormA] = name_; - rniContent_ = docSyntax_->delimGeneral(Syntax::dRNI); - rniContent_ += sd->execToDoc("CONTENT"); - rniDefault_ = docSyntax_->delimGeneral(Syntax::dRNI); - rniDefault_ += docSyntax_->reservedName(Syntax::rDEFAULT); - rniArcCont_ = metaSyntax_->delimGeneral(Syntax::dRNI); - rniArcCont_ += sd->execToDoc("ARCCONT"); - ConstPtr dtdent = makeDtdEntity(notation.pointer()); - if (dtdent.isNull()) - return; - StringC sysid = dtdent->asExternalEntity()->externalId().effectiveSystemId(); - if (sysid.size() == 0 - && !parentParser->entityCatalog().lookup(*dtdent, - *docSyntax_, - sd->docCharset(), - *mgr_, - sysid)) { - message(ArcEngineMessages::arcGenerateSystemId, - StringMessageArg(name_)); - return; - } - docHandler_->sgmlDecl(new SgmlDeclEvent(sd, syntax)); - docHandler_->startDtd(new StartDtdEvent(dtdent->name(), - dtdent, - 0, - event.location(), - 0)); - SgmlParser::Params params; - params.entityType = SgmlParser::Params::dtd; - params.sysid = sysid; - params.parent = parentParser; - ParserOptions options = parentParser->options(); - errorIdref_ = options.errorIdref; - options.errorAfdr = 0; - options.includes = arcOpts_; - params.options = &options; - params.sd = docSd_; - params.prologSyntax = metaSyntax_; - params.instanceSyntax = metaSyntax_; - params.doctypeName = dtdent->name(); - SgmlParser parser(params); - parser.parseAll(*docHandler_, cancelPtr); - Ptr baseDtd = parser.baseDtd(); - if (baseDtd.isNull() - || baseDtd->documentElementType()->definition()->undefined()) - return; - metaDtd_ = baseDtd; - metaMapCache_.resize(docDtd_->nElementTypeIndex()); - mungeMetaDtd(*baseDtd, *docDtd_); - docHandler_->endDtd(new EndDtdEvent(metaDtd_, event.location(), 0)); - startContent(*metaDtd_); - currentAttributes_.resize(metaDtd_->nCurrentAttribute()); - valid_ = 1; - docHandler_->endProlog(new EndPrologEvent(metaDtd_, event.location())); - if (engine->nBases() == 0) - docHandler_ = engine->delegateHandler(); -} - -void ArcProcessor::initNotationSet(const Location &loc) -{ - StringC name(docSyntax_->rniReservedName(Syntax::rNOTATION)); - Ptr notDtd(new Dtd(name, 1)); - metaDtd_ = notDtd; - ConstPtr def - = new ElementDefinition(loc, - notDtd->allocElementDefinitionIndex(), - 0, - ElementDefinition::any); - notDtd->lookupElementType(name)->setElementDefinition(def, 0); - Dtd::ConstNotationIter iter(docDtd_->notationIter()); - for (size_t i = 1;; i++) { - const Notation *notation = iter.next().pointer(); - if (!notation) - break; - ElementType *e = new ElementType(notation->name(), - notDtd->nElementTypeIndex()); - notDtd->insertElementType(e); - e->setElementDefinition(def, i); - if (!notation->attributeDef().isNull()) { - Vector > - attdefs(notation->attributeDef()->size()); - for (size_t i = 0; i < attdefs.size(); i++) - attdefs[i] = notation->attributeDef()->def(i)->copy(); - e->setAttributeDef(new AttributeDefinitionList(attdefs, - notDtd->allocAttributeDefinitionListIndex())); - } - } - docHandler_->endProlog(new EndPrologEvent(metaDtd_, loc)); - metaMapCache_.resize(docDtd_->nElementTypeIndex()); - startContent(*notDtd); - valid_ = 1; -} - -void ArcProcessor::mungeMetaDtd(Dtd &metaDtd, const Dtd &docDtd) -{ - if (supportAtts_[rArcDataF].size() > 0 - && metaDtd.lookupNotation(supportAtts_[rArcDataF]).isNull()) { - Messenger::message(ArcEngineMessages::noArcDataF, - StringMessageArg(supportAtts_[rArcDataF])); - metaDtd.insertNotation(new Notation(supportAtts_[rArcDataF], - metaDtd.namePointer(), - metaDtd.isBase())); - } - // FIXME check for ArcAutoF - Dtd::ConstEntityIter iter(docDtd.generalEntityIter()); - for (;;) { - ConstPtr ent = iter.next(); - if (ent.isNull()) - break; - Ptr copy(ent->copy()); - if (!copy->asExternalDataEntity() - || mungeDataEntity(*(ExternalDataEntity *)copy.pointer())) - metaDtd.insertEntity(copy, 1); - } -} - -Boolean ArcProcessor::mungeDataEntity(ExternalDataEntity &entity) -{ - const MetaMap &map = buildMetaMap(0, - entity.notation(), - entity.attributes(), - 0, - 0); - if (!map.attributed) - return 0; - AttributeList atts; - const Notation *notation = (const Notation *)map.attributed; - ConstPtr arcContent; - if (mapAttributes(entity.attributes(), 0, 0, atts, arcContent, map)) { - // FIXME check arcContent - entity.setNotation((Notation *)notation, atts); - return 1; - } - // FIXME error tried to use #CONTENT - return 0; -} - -ConstPtr ArcProcessor::makeDtdEntity(const Notation *) -{ - if (!supportAtts_[rArcDTD].size()) { - mgr_->message(ArcEngineMessages::noArcDTDAtt); - return 0; - } - ConstPtr entity = docDtd_->lookupEntity(arcDtdIsParam_, - supportAtts_[rArcDTD]); - if (entity.isNull()) { - mgr_->message(ArcEngineMessages::arcDtdNotDeclared, - StringMessageArg(supportAtts_[rArcDTD])); - return 0; - } - if (!entity->asExternalEntity()) { - mgr_->message(ArcEngineMessages::arcDtdNotExternal, - StringMessageArg(supportAtts_[rArcDTD])); - return 0; - } - ExternalId externalId(entity->asExternalEntity()->externalId()); -#if 0 - // Use the public identifier of the notation to find the meta-DTD. - if (externalId.effectiveSystemId().size() == 0 && notation) { - if (notation->externalId().effectiveSystemId().size()) { - StringC tem(notation->externalId().effectiveSystemId()); - externalId.setEffectiveSystem(tem); - } - else if (!externalId.publicId()) { - const PublicId *pubid = notation->externalId().publicId(); - PublicId::OwnerType ownerType; - if (pubid && pubid->getOwnerType(ownerType)) { - Text pubidText; - unsigned textClassPos = 2; - if (ownerType != PublicId::ISO) - textClassPos += 3; - StringC owner; - pubid->getOwner(owner); - textClassPos += owner.size(); - pubidText.addChars(pubid->string().data(), - textClassPos, - pubid->text().charLocation(0)); - pubidText.addChars(docSd_->execToDoc("DTD"), - pubid->text().charLocation(textClassPos)); - for (; textClassPos < pubid->string().size(); textClassPos++) - if (pubid->string()[textClassPos] == docSyntax_->space()) - break; - pubidText.addChars(pubid->string().data() + textClassPos, - pubid->string().size() - textClassPos, - pubid->text().charLocation(textClassPos)); - const MessageType1 *msg; - externalId.setPublic(pubidText, docSd_->docCharset(), - docSyntax_->space(), msg); - } - } - } -#endif - return new ExternalTextEntity(supportAtts_[rArcDocF], - Entity::doctype, - entity->defLocation(), - externalId); -} - -void ArcProcessor::supportAttributes(const AttributeList &atts) -{ - static const char *const s[] = { - "ArcFormA", - "ArcNamrA", - "ArcSuprA", - "ArcIgnDA", - "ArcDocF", - "ArcSuprF", - "ArcBridF", - "ArcDataF", - "ArcAuto", - "ArcIndr", - "ArcDTD", - "ArcQuant", - }; - for (size_t i = 0; i < SIZEOF(s); i++) { - StringC attName(docSd_->execToDoc(s[i])); - docSyntax_->generalSubstTable()->subst(attName); - unsigned ind; - if (atts.attributeIndex(attName, ind)) { - const AttributeValue *value = atts.value(ind); - if (value) { - const Text *textP = value->text(); - // FIXME check for empty value - if (textP) { - supportAtts_[i] = textP->string(); - switch (i) { - case rArcQuant: - processArcQuant(*textP); - break; - case rArcAuto: - docSyntax_->generalSubstTable()->subst(supportAtts_[i]); - if (supportAtts_[i] == docSd_->execToDoc("ARCAUTO")) - arcAuto_ = 1; - else if (supportAtts_[i] == docSd_->execToDoc("NARCAUTO")) - arcAuto_ = 0; - else - Messenger::message(ArcEngineMessages::invalidArcAuto, - StringMessageArg(supportAtts_[i])); - break; - case rArcIndr: - docSyntax_->generalSubstTable()->subst(supportAtts_[i]); - if (supportAtts_[i] == docSd_->execToDoc("ARCINDR")) { - Messenger::setNextLocation(textP->charLocation(0)); - Messenger::message(ArcEngineMessages::arcIndrNotSupported); - } - else if (supportAtts_[i] != docSd_->execToDoc("NARCINDR")) { - Messenger::setNextLocation(textP->charLocation(0)); - Messenger::message(ArcEngineMessages::invalidArcIndr, - StringMessageArg(supportAtts_[i])); - } - break; - case rArcFormA: - case rArcNamrA: - case rArcSuprA: - case rArcIgnDA: - docSyntax_->generalSubstTable()->subst(supportAtts_[i]); - break; - case rArcDocF: - case rArcSuprF: - case rArcBridF: - case rArcDataF: - metaSyntax_->generalSubstTable()->subst(supportAtts_[i]); - break; - case rArcDTD: - { - const StringC &pero = docSyntax_->delimGeneral(Syntax::dPERO); - if (supportAtts_[i].size() >= pero.size()) { - StringC tem(supportAtts_[i].data(), pero.size()); - docSyntax_->generalSubstTable()->subst(tem); - if (tem == pero) { - arcDtdIsParam_ = 1; - tem.assign(supportAtts_[i].data() + pero.size(), - supportAtts_[i].size() - pero.size()); - tem.swap(supportAtts_[i]); - } - } - docSyntax_->entitySubstTable()->subst(supportAtts_[i]); - } - break; - } - } - } - } - } - processArcOpts(atts); -} - -void ArcProcessor::processArcOpts(const AttributeList &atts) -{ - StringC attName(docSd_->execToDoc("ArcOptSA")); - docSyntax_->generalSubstTable()->subst(attName); - unsigned ind; - Vector arcOptA; - Vector arcOptAPos; - const Text *arcOptAText = 0; - if (atts.attributeIndex(attName, ind)) { - const AttributeValue *value = atts.value(ind); - if (value) { - arcOptAText = value->text(); - if (arcOptAText) - split(*arcOptAText, docSyntax_->space(), arcOptA, arcOptAPos); - } - } - if (!arcOptAText) - arcOptA.push_back(docSd_->execToDoc("ArcOpt")); - for (size_t i = 0; i < arcOptA.size(); i++) { - docSyntax_->generalSubstTable()->subst(arcOptA[i]); - if (atts.attributeIndex(arcOptA[i], ind)) { - const AttributeValue *value = atts.value(ind); - if (value) { - const Text *textP = value->text(); - if (textP) { - Vector opts; - Vector optsPos; - split(*textP, docSyntax_->space(), opts, optsPos); - arcOpts_.insert(arcOpts_.begin(), - opts.begin(), opts.begin() + opts.size()); - } - } - } - } -} - -void ArcProcessor::processArcQuant(const Text &text) -{ - Ptr newMetaSyntax; - Vector tokens; - Vector tokensPos; - split(text, docSyntax_->space(), tokens, tokensPos); - for (size_t i = 0; i < tokens.size(); i++) { - docSyntax_->generalSubstTable()->subst(tokens[i]); - Syntax::Quantity quantityName; - if (!docSd_->lookupQuantityName(tokens[i], quantityName)) { - setNextLocation(text.charLocation(tokensPos[i])); - Messenger::message(ArcEngineMessages::invalidQuantity, - StringMessageArg(tokens[i])); - } - else if (i + 1 >= tokens.size()) { - setNextLocation(text.charLocation(tokensPos[i])); - Messenger::message(ArcEngineMessages::missingQuantityValue, - StringMessageArg(tokens[i])); - } - else { - i++; - unsigned long val = 0; - if (tokens[i].size() > 8) { - setNextLocation(text.charLocation(tokensPos[i] + 8)); - Messenger::message(ArcEngineMessages::quantityValueTooLong, - StringMessageArg(tokens[i])); - tokens[i].resize(8); - } - for (size_t j = 0; j < tokens[i].size(); j++) { - int weight = docSd_->digitWeight(tokens[i][j]); - if (weight < 0) { - setNextLocation(text.charLocation(tokensPos[i] + j)); - Char c = tokens[i][j]; - Messenger::message(ArcEngineMessages::invalidDigit, - StringMessageArg(StringC(&c, 1))); - val = 0; - break; - } - else { - val *= 10; - val += weight; - } - } - if (val > docSyntax_->quantity(quantityName)) { - if (newMetaSyntax.isNull()) - newMetaSyntax = new Syntax(*docSyntax_); - newMetaSyntax->setQuantity(quantityName, val); - } - } - } - if (!newMetaSyntax.isNull()) - metaSyntax_ = newMetaSyntax; -} - -Boolean ArcProcessor::processStartElement(const StartElementEvent &event, - const AttributeList *linkAttributes, - const Text *content, - Allocator &allocator) -{ - unsigned suppressFlags = (openElementFlags_.size() > 0 - ? (openElementFlags_.back() & ~isArc) - : (unsigned)condIgnoreData); - if ((suppressFlags & suppressForm) - && (suppressFlags & suppressSupr)) { - // Make this case efficient. - openElementFlags_.push_back(suppressFlags); - return 1; - } - const AttributeList &atts = event.attributes(); - const MetaMap &map = buildMetaMap(event.elementType(), - 0, - atts, - linkAttributes, - suppressFlags); - const ElementType *metaType; - ConstPtr arcContent; - if (map.attributed == 0) { - if (!(tagLevel() == 0 - && !currentElement().isFinished())) { - if (!arcContent.isNull() - && (currentElement().declaredEmpty() - || !currentElement().tryTransitionPcdata())) - Messenger::message(ArcEngineMessages::invalidArcContent); - openElementFlags_.push_back(map.suppressFlags); - return 1; - } - metaType = metaDtd_->documentElementType(); - if (!notationSetArch_) - mgr_->message(ArcEngineMessages::documentElementNotArc, - StringMessageArg(metaType->name())); - attributeList_.init(metaType->attributeDef()); - attributeList_.finish(*this); - } - else { - if (!mapAttributes(atts, linkAttributes, content, attributeList_, - arcContent, map)) - return 0; - metaType = (const ElementType *)map.attributed; - suppressFlags = map.suppressFlags; - } - StartElementEvent *genEvent - = new (allocator) StartElementEvent(metaType, - metaDtd_, - &attributeList_, - event.location(), - 0); - if (notationSetArch_) { - if (tagLevel() == 0 - && !currentElement().isFinished()) - currentElement().tryTransition(metaDtd_->documentElementType()); - } - else if (metaType->definition()->undefined()) - Messenger::message(ArcEngineMessages::undefinedElement, - StringMessageArg(metaType->name())); - else if (elementIsExcluded(metaType)) - Messenger::message(ArcEngineMessages::elementExcluded, - StringMessageArg(metaType->name())); - else if (elementIsIncluded(metaType)) - genEvent->setIncluded(); - else if (!currentElement().tryTransition(metaType)) - Messenger::message(ArcEngineMessages::invalidElement, - StringMessageArg(metaType->name())); - - pushElement(new (allocator) OpenElement(metaType, - 0, - genEvent->included(), - 0, - event.location())); - docHandler_->startElement(genEvent); - if (attributeList_.conref()) - currentElement().setConref(); - if (!arcContent.isNull() && arcContent->text() != 0) { - if (currentElement().declaredEmpty() - || !currentElement().tryTransitionPcdata()) - Messenger::message(ArcEngineMessages::invalidArcContent); - else - emitArcContent(*arcContent->text(), docHandler(), allocator); - suppressFlags |= (suppressForm|suppressSupr|ignoreData); - } - suppressFlags &= ~recoverData; - openElementFlags_.push_back(suppressFlags | isArc); - return 1; -} - -void ArcProcessor::emitArcContent(const Text &text, - EventHandler &handler, - Allocator &allocator) -{ - TextIter iter(text); - TextItem::Type type; - const Char *s; - size_t n; - const Location *loc; - while (iter.next(type, s, n, loc)) - switch (type) { - case TextItem::data: - case TextItem::cdata: - // +1 because first dataEvent is the non-architectural data. - if (type == TextItem::data) - handler.data(new (allocator) ImmediateDataEvent(Event::characterData, - s, - n, - *loc, - 0)); - else - - handler.data(new (allocator) - CdataEntityEvent(loc->origin()->asEntityOrigin() - ->entity()->asInternalEntity(), - loc->origin())); - break; - case TextItem::sdata: - - handler.sdataEntity(new (allocator) - SdataEntityEvent(loc->origin()->asEntityOrigin() - ->entity()->asInternalEntity(), - loc->origin())); - break; - default: - break; - } -} - -Boolean ArcProcessor::processData() -{ - if (openElementFlags_.size() > 0 - && (openElementFlags_.back() & ignoreData)) - return 0; - if (notationSetArch_) - return currentElement().type() != metaDtd_->documentElementType(); - else if (!currentElement().declaredEmpty() - && currentElement().tryTransitionPcdata()) - return 1; - else if (openElementFlags_.size() > 0 - && (openElementFlags_.back() & condIgnoreData)) - return 0; - else { - // Only give this error once per element - if (openElementFlags_.size() > 0) { - if (openElementFlags_.back() & recoverData) - return 1; - openElementFlags_.back() |= recoverData; - } - Messenger::message(ArcEngineMessages::invalidData); - return 1; - } -} - -Boolean ArcProcessor::mapAttributes(const AttributeList &from, - const AttributeList *fromLink, - const Text *content, - AttributeList &to, - ConstPtr &arcContent, - const MetaMap &map) -{ - if (map.attributed) - to.init(map.attributed->attributeDef()); - for (size_t i = 0; i < map.attMapFrom.size(); i++) { - unsigned fromIndex = map.attMapFrom[i]; - const AttributeList *fromList = &from; - if (fromIndex != contentPseudoAtt && fromIndex >= fromList->size()) { - fromList = fromLink; - fromIndex -= from.size(); - } - if (map.attMapTo[i] == contentPseudoAtt) { - if (fromIndex != contentPseudoAtt) - arcContent = fromList->valuePointer(fromIndex); - } - else { - const Text *fromText = 0; - Boolean fromTextTokenized = 0; - if (map.attMapFrom[i] == contentPseudoAtt) { - if (!content) - return 0; - fromText = content; - } - else { - const AttributeValue *value = fromList->value(fromIndex); - if (value) { - fromText = value->text(); - fromTextTokenized = fromList->tokenized(fromIndex); - if (fromText - && fromList == &from - && !from.specified(fromIndex) - && (map.attributed->attributeDef()->def(map.attMapTo[i]) - ->missingValueWouldMatch(*fromText, *this))) - fromText = 0; - } - } - if (fromText) { - unsigned specLength = 0; - Text tem; - if (!fromTextTokenized && to.tokenized(map.attMapTo[i])) - fromText->tokenize(docSyntax_->space(), tem); - else - tem = *fromText; - to.setSpec(map.attMapTo[i], *this); - to.setValue(map.attMapTo[i], tem, *this, specLength); - } - } - } - if (map.attributed) - to.finish(*this); - return 1; -} - -const ArcProcessor::MetaMap & -ArcProcessor::buildMetaMap(const ElementType *docElementType, - const Notation *notation, - const AttributeList &atts, - const AttributeList *linkAtts, - unsigned suppressFlags) -{ - Boolean isNotation; - const Attributed *attributed = docElementType; - const StringC *nameP; - if (!attributed) { - attributed = notation; - isNotation = 1; - nameP = ¬ation->name(); - } - else { - isNotation = 0; - nameP = &docElementType->name(); - } - // Try to use cached entry. - Boolean inhibitCache = 0; - size_t cacheIndex; - if (isNotation || docElementType->definition()->undefined()) { - inhibitCache = 1; - cacheIndex = (unsigned)-1; - } - else { - cacheIndex = docElementType->index(); - const MetaMapCache *cache = metaMapCache_[cacheIndex].pointer(); - if (cache - && cache->suppressFlags == suppressFlags - && cache->linkAtts == linkAtts) { - for (int i = 0;; i++) { - if (i == MetaMapCache::nNoSpec) - return cache->map; - unsigned attIndex = cache->noSpec[i]; - if (attIndex != invalidAtt && atts.specified(attIndex)) - break; - } - } - } - // no valid cached MetaMap - // Handle suppression. - unsigned oldSuppressFlags = suppressFlags; - unsigned newSuppressFlags = suppressFlags; - unsigned arcSuprIndex; - if (!isNotation) - considerSupr(atts, linkAtts, suppressFlags, newSuppressFlags, inhibitCache, - arcSuprIndex); - else - arcSuprIndex = invalidAtt; - // Handle ArcIgnD - unsigned arcIgnDIndex; - if (!isNotation) - considerIgnD(atts, linkAtts, suppressFlags, newSuppressFlags, inhibitCache, - arcIgnDIndex); - else - arcIgnDIndex = invalidAtt; - // Handle ArcForm. - unsigned arcFormIndex; - const Attributed *metaAttributed - = (notationSetArch_ - ? considerNotation(atts, suppressFlags, inhibitCache, arcFormIndex) - : considerForm(atts, linkAtts, *nameP, isNotation, - suppressFlags, newSuppressFlags, - inhibitCache, arcFormIndex)); - // See if there's a renamer that will inhibit cacheing. - unsigned arcNamerIndex; - const Text *namerText; - if (metaAttributed) - namerText = considerNamer(atts, inhibitCache, arcNamerIndex); - else { - arcNamerIndex = invalidAtt; - namerText = 0; - } - MetaMap *mapP; - if (inhibitCache) { - noCacheMetaMap_.clear(); - mapP = &noCacheMetaMap_; - } - else { - MetaMapCache *cache = metaMapCache_[cacheIndex].pointer(); - if (cache) - cache->clear(); - else { - cache = new MetaMapCache; - metaMapCache_[cacheIndex] = cache; - } - cache->noSpec[0] = arcFormIndex; - cache->noSpec[1] = arcNamerIndex; - cache->noSpec[2] = arcSuprIndex; - cache->noSpec[3] = arcIgnDIndex; - cache->suppressFlags = oldSuppressFlags; - cache->linkAtts = linkAtts; - mapP = &cache->map; - } - mapP->attributed = metaAttributed; - mapP->suppressFlags = newSuppressFlags; - // Build the attribute map. - if (metaAttributed) { - Vector renamed; - ConstPtr metaAttDef - = metaAttributed->attributeDef(); - if (!metaAttDef.isNull()) - renamed.assign(metaAttDef->size(), PackedBoolean(0)); - if (linkAtts) { - Boolean specified; - unsigned index; - const Text *linkNamerText = considerNamer(*linkAtts, specified, index); - if (linkNamerText) - buildAttributeMapRename(*mapP, *linkNamerText, atts, linkAtts, renamed); - } - if (namerText) - buildAttributeMapRename(*mapP, *namerText, atts, 0, renamed); - buildAttributeMapRest(*mapP, atts, linkAtts, renamed); - } - return *mapP; -} - -void ArcProcessor::considerSupr(const AttributeList &atts, - const AttributeList *linkAtts, - unsigned &thisSuppressFlags, - unsigned &newSuppressFlags, - Boolean &inhibitCache, - unsigned &arcSuprIndex) -{ - arcSuprIndex = invalidAtt; - if (thisSuppressFlags & suppressSupr) - return; - if (!supportAtts_[rArcSuprA].size()) - return; - const AttributeValue *val; - unsigned tem; - if (linkAtts && linkAtts->attributeIndex(supportAtts_[rArcSuprA], tem)) - val = linkAtts->value(tem); - else if (atts.attributeIndex(supportAtts_[rArcSuprA], arcSuprIndex)) { - if (atts.current(arcSuprIndex) || atts.specified(arcSuprIndex)) - inhibitCache = 1; - val = atts.value(arcSuprIndex); - } - else - return; - if (!val) - return; - const Text *textP = val->text(); - if (!textP) - return; - StringC token = textP->string(); - // FIXME trim spaces - docSyntax_->generalSubstTable()->subst(token); - // sArcForm suppress processing for all elements except - // those that have a non-implied ArcSupr attribute. - thisSuppressFlags &= ~suppressForm; - newSuppressFlags &= ~(suppressForm|suppressSupr); - if (matchName(token, "sArcForm")) - newSuppressFlags |= suppressForm; -#if 0 - // I don't think this is useful - else if (matchName(token, "sArcSupr")) - newSuppressFlags |= suppressSupr; -#endif - else if (matchName(token, "sArcAll")) - newSuppressFlags |= (suppressSupr|suppressForm); - else if (!matchName(token, "sArcNone")) { - Messenger::setNextLocation(textP->charLocation(0)); - Messenger::message(ArcEngineMessages::invalidSuppress, - StringMessageArg(token)); - } -} - -void ArcProcessor::considerIgnD(const AttributeList &atts, - const AttributeList *linkAtts, - unsigned thisSuppressFlags, - unsigned &newSuppressFlags, - Boolean &inhibitCache, - unsigned &arcIgnDIndex) -{ - arcIgnDIndex = invalidAtt; - if (thisSuppressFlags & suppressSupr) - return; - if (!supportAtts_[rArcIgnDA].size()) - return; - const AttributeValue *val; - unsigned tem; - if (linkAtts && linkAtts->attributeIndex(supportAtts_[rArcIgnDA], tem)) - val = linkAtts->value(tem); - else if (atts.attributeIndex(supportAtts_[rArcIgnDA], arcIgnDIndex)) { - if (atts.current(arcIgnDIndex) || atts.specified(arcIgnDIndex)) - inhibitCache = 1; - val = atts.value(arcIgnDIndex); - } - else - return; - if (!val) - return; - const Text *textP = val->text(); - if (!textP) - return; - StringC token = textP->string(); - // FIXME trim spaces - docSyntax_->generalSubstTable()->subst(token); - newSuppressFlags &= ~(ignoreData|condIgnoreData); - if (matchName(token, "ArcIgnD")) - newSuppressFlags |= ignoreData; - else if (matchName(token, "cArcIgnD")) - newSuppressFlags |= condIgnoreData; - else if (!matchName(token, "nArcIgnD")) { - Messenger::setNextLocation(textP->charLocation(0)); - Messenger::message(ArcEngineMessages::invalidIgnD, - StringMessageArg(token)); - } -} - -const Attributed * -ArcProcessor::considerNotation(const AttributeList &atts, - unsigned thisSuppressFlags, - Boolean &inhibitCache, - unsigned ¬AttIndex) -{ - if (thisSuppressFlags & suppressForm) - return 0; - for (unsigned i = 0; i < atts.size(); i++) { - const AttributeSemantics *sem = atts.semantics(i); - if (sem) { - ConstPtr notation = sem->notation(); - if (!notation.isNull()) { - notAttIndex = i; - if (atts.current(notAttIndex) || atts.specified(notAttIndex)) - inhibitCache = 1; - return metaDtd_->lookupElementType(notation->name()); - } - } - } - notAttIndex = invalidAtt; - return 0; -} - -const Attributed * -ArcProcessor::considerForm(const AttributeList &atts, - const AttributeList *linkAtts, - const StringC &name, - Boolean isNotation, - unsigned thisSuppressFlags, - unsigned &newSuppressFlags, - Boolean &inhibitCache, - unsigned &arcFormIndex) -{ - arcFormIndex = invalidAtt; - if ((thisSuppressFlags & suppressForm) - && (supportAtts_[rArcSuprF].size() == 0 - || (thisSuppressFlags & suppressSupr) - || isNotation)) - return 0; - unsigned tem; - const AttributeValue *val; - if (linkAtts && linkAtts->attributeIndex(supportAtts_[rArcFormA], tem)) - val = linkAtts->value(tem); - else if (atts.attributeIndex(supportAtts_[rArcFormA], arcFormIndex)) { - if (atts.current(arcFormIndex) || atts.specified(arcFormIndex)) - inhibitCache = 1; - val = atts.value(arcFormIndex); - } - else - return autoForm(atts, name, isNotation, - thisSuppressFlags, newSuppressFlags, - inhibitCache, arcFormIndex); - - if (!val) - return 0; - const Text *textP = val->text(); - if (!textP) - return 0; - StringC metaName; - metaName = textP->string(); - // FIXME should trim leading and trailing spaces - metaSyntax_->generalSubstTable()->subst(metaName); - if (!isNotation) { - const Attributed *metaAttributed = metaDtd_->lookupElementType(metaName); - if (!metaAttributed) - metaAttributed = lookupCreateUndefinedElement(metaName, Location()); - if (metaName == supportAtts_[rArcSuprF]) { - newSuppressFlags |= suppressForm; - return metaAttributed; - } - if (thisSuppressFlags & suppressForm) - return 0; - return metaAttributed; - } - else - return metaDtd_->lookupNotation(metaName).pointer(); -} - -const Attributed * -ArcProcessor::autoForm(const AttributeList &atts, - const StringC &name, - Boolean isNotation, - unsigned thisSuppressFlags, - unsigned &newSuppressFlags, - Boolean &inhibitCache, - unsigned &idIndex) -{ - if (!isNotation) { - const Attributed *metaAttributed; - if (openElementFlags_.size() == 0) { - metaAttributed = metaDtd_->documentElementType(); - inhibitCache = 1; - } - else { - metaAttributed = 0; - if (arcAuto_) - metaAttributed = metaDtd_->lookupElementType(name); - if (!metaAttributed - && supportAtts_[rArcBridF].size() > 0 - && atts.idIndex(idIndex) - && atts.specified(idIndex)) { - inhibitCache = 1; - metaAttributed - = metaDtd_->lookupElementType(supportAtts_[rArcBridF]); - } - } - if (metaAttributed - && name == supportAtts_[rArcSuprF]) { - newSuppressFlags = suppressForm|ignoreData; - } - else if (thisSuppressFlags & suppressForm) - return 0; - return metaAttributed; - } - else if (thisSuppressFlags & suppressForm) - return 0; - else { - const Attributed *metaAttributed = 0; - if (arcAuto_) - metaAttributed = metaDtd_->lookupNotation(name).pointer(); - if (!metaAttributed && supportAtts_[rArcDataF].size() > 0) - metaAttributed - = metaDtd_->lookupNotation(supportAtts_[rArcDataF]).pointer(); - return metaAttributed; - } -} - - -const Text * -ArcProcessor::considerNamer(const AttributeList &atts, - Boolean &inhibitCache, - unsigned &arcNamerIndex) -{ - arcNamerIndex = invalidAtt; - if (supportAtts_[rArcNamrA].size() == 0 - || !atts.attributeIndex(supportAtts_[rArcNamrA], arcNamerIndex)) - return 0; - if (atts.current(arcNamerIndex) || atts.specified(arcNamerIndex)) - inhibitCache = 1; - const AttributeValue *val = atts.value(arcNamerIndex); - if (!val) - return 0; - return val->text(); -} - -void ArcProcessor::buildAttributeMapRename(MetaMap &map, - const Text &rename, - const AttributeList &atts, - const AttributeList *linkAtts, - Vector &attRenamed) -{ - Vector tokens; - Vector tokensPos; - split(rename, docSyntax_->space(), tokens, tokensPos); - ConstPtr metaAttDef; - if (map.attributed) - metaAttDef = map.attributed->attributeDef(); - // FIXME Should check that ARCCONT doesn't appear more than once. - for (size_t i = 0; i < tokens.size(); i += 2) { - unsigned fromIndex = invalidAtt; - unsigned toIndex = invalidAtt; - metaSyntax_->generalSubstTable()->subst(tokens[i]); - if (tokens[i] == rniArcCont_) - toIndex = contentPseudoAtt; - else if (metaAttDef.isNull() - || !metaAttDef->attributeIndex(tokens[i], toIndex)) { - setNextLocation(rename.charLocation(tokensPos[i])); - Messenger::message(ArcEngineMessages::renameToInvalid, - StringMessageArg(tokens[i])); - } - else if (attRenamed[toIndex]) { - toIndex = invalidAtt; - setNextLocation(rename.charLocation(tokensPos[i])); - Messenger::message(ArcEngineMessages::renameToDuplicate, - StringMessageArg(tokens[i])); - } - if (i + 1 >= tokens.size()) { - setNextLocation(rename.charLocation(tokensPos[i])); - Messenger::message(ArcEngineMessages::renameMissingAttName); - } - else { - docSyntax_->generalSubstTable()->subst(tokens[i + 1]); - if (tokens[i + 1] == rniContent_) { - fromIndex = contentPseudoAtt; - } - else if (tokens[i + 1] == rniDefault_) { - if (toIndex != contentPseudoAtt) - attRenamed[toIndex] = 1; - } - else if (linkAtts - && linkAtts->attributeIndex(tokens[i + 1], fromIndex)) - fromIndex += atts.size(); - else if (!atts.attributeIndex(tokens[i + 1], fromIndex)) { - setNextLocation(rename.charLocation(tokensPos[i + 1])); - Messenger::message(ArcEngineMessages::renameFromInvalid, - StringMessageArg(tokens[i + 1])); - } - } - if (fromIndex != invalidAtt && toIndex != invalidAtt) { - map.attMapFrom.push_back(fromIndex); - map.attMapTo.push_back(toIndex); - if (toIndex != contentPseudoAtt) { - attRenamed[toIndex] = 1; - if (metaAttDef->def(toIndex)->isId() - && (fromIndex >= atts.size() || !atts.id(fromIndex))) - Messenger::message(ArcEngineMessages::idMismatch, - StringMessageArg(metaAttDef->def(toIndex) - ->name())); - } - } - } -} - -void ArcProcessor::buildAttributeMapRest(MetaMap &map, - const AttributeList &atts, - const AttributeList *linkAtts, - const Vector &attRenamed) -{ - ConstPtr metaAttDef - = map.attributed->attributeDef(); - if (metaAttDef.isNull()) - return; - for (unsigned i = 0; i < metaAttDef->size(); i++) - if (!attRenamed[i]) { - unsigned fromIndex; - if (metaAttDef->def(i)->isId()) { - for (unsigned j = 0; j < atts.size(); j++) - if (atts.id(j)) { - map.attMapFrom.push_back(j); - map.attMapTo.push_back(i); - break; - } - } - else if (linkAtts && linkAtts->attributeIndex(metaAttDef->def(i)->name(), - fromIndex)) { - map.attMapFrom.push_back(fromIndex + atts.size()); - map.attMapTo.push_back(i); - } - else if (atts.attributeIndex(metaAttDef->def(i)->name(), fromIndex)) { - map.attMapFrom.push_back(fromIndex); - map.attMapTo.push_back(i); - } - } -} - -Boolean ArcProcessor::matchName(const StringC &name, const char *key) -{ - if (name.size() != strlen(key)) - return 0; - StringC tem(docSd_->execToDoc(key)); - docSyntax_->generalSubstTable()->subst(tem); - return name == tem; -} - -void ArcProcessor::split(const Text &text, - Char space, - Vector &tokens, - Vector &tokensPos) -{ - const StringC &str = text.string(); - for (size_t i = 0;;) { - for (; i < str.size() && str[i] == space; i++) - ; - if (i >= str.size()) - break; - size_t start = i; - for (; i < str.size() && str[i] != space; i++) - ; - tokens.push_back(StringC(str.data() + start, i - start)); - tokensPos.push_back(start); - } -} - -void ArcProcessor::processEndElement(const EndElementEvent &event, - Allocator &allocator) -{ - Boolean wasArc = (openElementFlags_.back() & isArc); - openElementFlags_.resize(openElementFlags_.size() - 1); - if (wasArc) { - EndElementEvent *genEvent - = new (allocator) EndElementEvent(currentElement().type(), - metaDtd_, - event.location(), - 0); - if (currentElement().included()) - genEvent->setIncluded(); - docHandler_->endElement(genEvent); - if (!currentElement().isFinished()) - Messenger::message(ArcEngineMessages::unfinishedElement, - StringMessageArg(currentElement().type()->name())); - popElement(); - } -} - -void ArcProcessor::dispatchMessage(Message &msg) -{ - mgr_->dispatchMessage(msg); -} - -void ArcProcessor::dispatchMessage(const Message &msg) -{ - mgr_->dispatchMessage(msg); -} - -void ArcProcessor::initMessage(Message &msg) -{ - mgr_->initMessage(msg); - if (valid_) { - StringC rniPcdata = metaSyntax_->delimGeneral(Syntax::dRNI); - rniPcdata += metaSyntax_->reservedName(Syntax::rPCDATA); - getOpenElementInfo(msg.openElementInfo, rniPcdata); - } -} - -ArcProcessor::MetaMapCache::MetaMapCache() -{ - for (int i = 0; i < nNoSpec; i++) - noSpec[i] = invalidAtt; - linkAtts = 0; - suppressFlags = 0; -} - -void ArcProcessor::MetaMapCache::clear() -{ - for (int i = 0; i < nNoSpec; i++) - noSpec[i] = invalidAtt; - linkAtts = 0; - map.clear(); -} - -ArcProcessor::MetaMap::MetaMap() -: attributed(0), suppressFlags(0) -{ -} - -void ArcProcessor::MetaMap::clear() -{ - attMapFrom.clear(); - attMapTo.clear(); - attributed = 0; -} - -#ifdef SP_NAMESPACE -} -#endif diff --git a/cde/programs/nsgmls/ArcEngine.h b/cde/programs/nsgmls/ArcEngine.h deleted file mode 100644 index e081c4a39..000000000 --- a/cde/programs/nsgmls/ArcEngine.h +++ /dev/null @@ -1,78 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: ArcEngine.h /main/1 1996/07/29 16:46:15 cde-hp $ */ -// Copyright (c) 1996 James Clark -// See the file COPYING for copying permission. - -#ifndef ArcEngine_INCLUDED -#define ArcEngine_INCLUDED 1 - -#ifdef __GNUG__ -#pragma interface -#endif - -#include "Event.h" -#include "Vector.h" -#include "SgmlParser.h" -#include - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -class SP_API ArcDirector { -public: - virtual EventHandler *arcEventHandler(const Notation *, - const Vector &, - const SubstTable *) = 0; -}; - -class SP_API SelectOneArcDirector : public ArcDirector, public Messenger { -public: - SelectOneArcDirector(const Vector &select, EventHandler &eh) - : select_(select), eh_(&eh) { } - EventHandler *arcEventHandler(const Notation *, - const Vector &, - const SubstTable *); - void dispatchMessage(const Message &); - void dispatchMessage(Message &); -private: - Vector select_; - EventHandler *eh_; -}; - -class SP_API ArcEngine { -public: - static void parseAll(SgmlParser &, - Messenger &, - ArcDirector &, - SP_CONST SP_VOLATILE sig_atomic_t *cancelPtr = 0); -private: - ArcEngine(); -}; - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* not ArcEngine_INCLUDED */ diff --git a/cde/programs/nsgmls/ArcEngineMessages.h b/cde/programs/nsgmls/ArcEngineMessages.h deleted file mode 100644 index c775c20be..000000000 --- a/cde/programs/nsgmls/ArcEngineMessages.h +++ /dev/null @@ -1,427 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: ArcEngineMessages.h /main/1 1996/07/29 16:46:22 cde-hp $ */ -// This file was automatically generated from ArcEngineMessages.msg by msggen.pl. -#include "Message.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -struct ArcEngineMessages { - // 3000 - static const MessageType1 arcGenerateSystemId; - // 3001 - static const MessageType1 undefinedElement; - // 3002 - static const MessageType1 elementExcluded; - // 3003 - static const MessageType1 invalidElement; - // 3004 - static const MessageType1 documentElementNotArc; - // 3005 - static const MessageType1 unfinishedElement; - // 3006 - static const MessageType0 renameMissingAttName; - // 3007 - static const MessageType1 renameToInvalid; - // 3008 - static const MessageType1 renameToDuplicate; - // 3009 - static const MessageType1 renameFromInvalid; - // 3010 - static const MessageType1 missingId; - // 3011 - static const MessageType0 invalidArcContent; - // 3012 - static const MessageType1 invalidSuppress; - // 3013 - static const MessageType1 arcDtdNotDeclared; - // 3014 - static const MessageType1 arcDtdNotExternal; - // 3015 - static const MessageType0 noArcDTDAtt; - // 3016 - static const MessageType1 noArcDataF; - // 3017 - static const MessageType1 idMismatch; - // 3018 - static const MessageType1 invalidArcAuto; - // 3019 - static const MessageType1 noArcNotation; - // 3020 - static const MessageType0 invalidData; - // 3021 - static const MessageType1 invalidIgnD; - // 3022 - static const MessageType1 invalidArcIndr; - // 3023 - static const MessageType1 invalidQuantity; - // 3024 - static const MessageType1 missingQuantityValue; - // 3025 - static const MessageType1 quantityValueTooLong; - // 3026 - static const MessageType1 invalidDigit; - // 3027 - static const MessageType0 arcIndrNotSupported; -}; -const MessageType1 ArcEngineMessages::arcGenerateSystemId( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -3000 -#ifndef SP_NO_MESSAGE_TEXT -,"no system identifier could be generated for meta-DTD for architecture %1" -#endif -); -const MessageType1 ArcEngineMessages::undefinedElement( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -3001 -#ifndef SP_NO_MESSAGE_TEXT -,"element type %1 not defined in meta-DTD" -#endif -); -const MessageType1 ArcEngineMessages::elementExcluded( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -3002 -#ifndef SP_NO_MESSAGE_TEXT -,"element %1 invalid in meta-DTD because excluded" -#endif -); -const MessageType1 ArcEngineMessages::invalidElement( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -3003 -#ifndef SP_NO_MESSAGE_TEXT -,"meta-DTD does not allow element %1 at this point" -#endif -); -const MessageType1 ArcEngineMessages::documentElementNotArc( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -3004 -#ifndef SP_NO_MESSAGE_TEXT -,"document element must be instance of %1 element type form" -#endif -); -const MessageType1 ArcEngineMessages::unfinishedElement( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -3005 -#ifndef SP_NO_MESSAGE_TEXT -,"element %1 unfinished in meta-DTD" -#endif -); -const MessageType0 ArcEngineMessages::renameMissingAttName( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -3006 -#ifndef SP_NO_MESSAGE_TEXT -,"missing substitute name" -#endif -); -const MessageType1 ArcEngineMessages::renameToInvalid( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -3007 -#ifndef SP_NO_MESSAGE_TEXT -,"substitute for non-existent architecture attribute %1" -#endif -); -const MessageType1 ArcEngineMessages::renameToDuplicate( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -3008 -#ifndef SP_NO_MESSAGE_TEXT -,"substitute name for %1 already defined" -#endif -); -const MessageType1 ArcEngineMessages::renameFromInvalid( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -3009 -#ifndef SP_NO_MESSAGE_TEXT -,"substitute name %1 is not the name of an attribute" -#endif -); -const MessageType1 ArcEngineMessages::missingId( -MessageType::idrefError, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -3010 -#ifndef SP_NO_MESSAGE_TEXT -,"reference in architecture to non-existent ID %1" -#endif -); -const MessageType0 ArcEngineMessages::invalidArcContent( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -3011 -#ifndef SP_NO_MESSAGE_TEXT -,"architectural content specified with #ARCCONT not allowed by meta-DTD" -#endif -); -const MessageType1 ArcEngineMessages::invalidSuppress( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -3012 -#ifndef SP_NO_MESSAGE_TEXT -,"invalid value %1 for ArcSupr attribute" -#endif -); -const MessageType1 ArcEngineMessages::arcDtdNotDeclared( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -3013 -#ifndef SP_NO_MESSAGE_TEXT -,"no declaration for meta-DTD parameter entity %1" -#endif -); -const MessageType1 ArcEngineMessages::arcDtdNotExternal( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -3014 -#ifndef SP_NO_MESSAGE_TEXT -,"meta-DTD entity %1 must be external" -#endif -); -const MessageType0 ArcEngineMessages::noArcDTDAtt( -MessageType::warning, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -3015 -#ifndef SP_NO_MESSAGE_TEXT -,"no ArcDTD architecture support attribute specified" -#endif -); -const MessageType1 ArcEngineMessages::noArcDataF( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -3016 -#ifndef SP_NO_MESSAGE_TEXT -,"ArcDataF notation %1 not defined in meta-DTD" -#endif -); -const MessageType1 ArcEngineMessages::idMismatch( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -3017 -#ifndef SP_NO_MESSAGE_TEXT -,"ID attribute %1 in meta-DTD not declared as ID in DTD" -#endif -); -const MessageType1 ArcEngineMessages::invalidArcAuto( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -3018 -#ifndef SP_NO_MESSAGE_TEXT -,"invalid value %1 for ArcAuto architectural support attribute" -#endif -); -const MessageType1 ArcEngineMessages::noArcNotation( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -3019 -#ifndef SP_NO_MESSAGE_TEXT -,"no notation declaration for architecture %1" -#endif -); -const MessageType0 ArcEngineMessages::invalidData( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -3020 -#ifndef SP_NO_MESSAGE_TEXT -,"meta-DTD does not allow data at this point" -#endif -); -const MessageType1 ArcEngineMessages::invalidIgnD( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -3021 -#ifndef SP_NO_MESSAGE_TEXT -,"invalid value %1 for ArcIgnD attribute" -#endif -); -const MessageType1 ArcEngineMessages::invalidArcIndr( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -3022 -#ifndef SP_NO_MESSAGE_TEXT -,"invalid value %1 for ArcIndr architectural support attribute" -#endif -); -const MessageType1 ArcEngineMessages::invalidQuantity( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -3023 -#ifndef SP_NO_MESSAGE_TEXT -,"unrecognized quantity name %1" -#endif -); -const MessageType1 ArcEngineMessages::missingQuantityValue( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -3024 -#ifndef SP_NO_MESSAGE_TEXT -,"no value specified for quantity %1" -#endif -); -const MessageType1 ArcEngineMessages::quantityValueTooLong( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -3025 -#ifndef SP_NO_MESSAGE_TEXT -,"length of value %1 for quantity is too long" -#endif -); -const MessageType1 ArcEngineMessages::invalidDigit( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -3026 -#ifndef SP_NO_MESSAGE_TEXT -,"invalid digit %1" -#endif -); -const MessageType0 ArcEngineMessages::arcIndrNotSupported( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -3027 -#ifndef SP_NO_MESSAGE_TEXT -,"only value of nArcIndr for ArcIndr attribute supported" -#endif -); -#ifdef SP_NAMESPACE -} -#endif diff --git a/cde/programs/nsgmls/ArcProcessor.h b/cde/programs/nsgmls/ArcProcessor.h deleted file mode 100644 index 075a69765..000000000 --- a/cde/programs/nsgmls/ArcProcessor.h +++ /dev/null @@ -1,239 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: ArcProcessor.h /main/1 1996/07/29 16:46:28 cde-hp $ */ -// Copyright (c) 1996 James Clark -// See the file COPYING for copying permission. - -#ifndef ArcProcessor_INCLUDED -#define ArcProcessor_INCLUDED 1 - -#include "Event.h" -#include "ContentState.h" -#include "Id.h" -#include "NamedTable.h" -#include "Vector.h" -#include "ArcEngine.h" -#include "SgmlParser.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -class Allocator; - -// Processor for a single architecture - -class ArcProcessor : private ContentState, private AttributeContext { -public: - struct MetaMap { - MetaMap(); - void clear(); - const Attributed *attributed; - unsigned suppressFlags; - // #ARCCONT and #CONTENT are handled with a special index - // list of indexes into element's attlist of architectural attributes - Vector attMapFrom; - // corresponding list of indexes in form's attlist - Vector attMapTo; - }; - struct MetaMapCache { - MetaMapCache(); - void clear(); - MetaMap map; - enum { nNoSpec = 4 }; - // Prerequisites for this cached entry to be valid. - // The cache is only valid if for each member of noSpec != -1 - // the attribute with that index was not specified (or current) - unsigned noSpec[nNoSpec]; - unsigned suppressFlags; - const AttributeList *linkAtts; - }; - ArcProcessor(); - void setName(const StringC &); - void init(const EndPrologEvent &, - const ConstPtr &, - const ConstPtr &, - const SgmlParser *parser, - Messenger *, - const Vector &superName, - ArcDirector &director, - SP_CONST SP_VOLATILE sig_atomic_t *cancelPtr); - // Return 0 if the content is needed, but wasn't supplied - Boolean processStartElement(const StartElementEvent &, - const AttributeList *linkAttributes, - const Text *content, - Allocator &); - void processEndElement(const EndElementEvent &, - Allocator &); - // Return true if its architectural. - Boolean processData(); - const ConstPtr &dtdPointer() const { return metaDtd_; } - Boolean valid() const { return valid_; } - void checkIdrefs(); - const StringC &name() const { return name_; } - EventHandler &docHandler() const { return *docHandler_; } -private: - ArcProcessor(const ArcProcessor &); // undefined - void operator=(const ArcProcessor &); // undefined - const Syntax &attributeSyntax() const; - ConstPtr getAttributeNotation(const StringC &, - const Location &); - ConstPtr getAttributeEntity(const StringC &, - const Location &); - void noteCurrentAttribute(size_t, AttributeValue *); - ConstPtr getCurrentAttribute(size_t) const; - Boolean defineId(const StringC &, const Location &, Location &); - void noteIdref(const StringC &, const Location &); - Id *lookupCreateId(const StringC &); - void dispatchMessage(const Message &); - void dispatchMessage(Message &); - void initMessage(Message &); - const MetaMap &buildMetaMap(const ElementType *, - const Notation *, - const AttributeList &, - const AttributeList *linkAtts, - unsigned suppressFlags); - void considerSupr(const AttributeList &atts, - const AttributeList *linkAtts, - unsigned &thisSuppressFlags, - unsigned &newSuppressFlags, - Boolean &inhibitCache, - unsigned &arcSuprIndex); - void considerIgnD(const AttributeList &atts, - const AttributeList *linkAtts, - unsigned thisSuppressFlags, - unsigned &newSuppressFlags, - Boolean &inhibitCache, - unsigned &arcSuprIndex); - const Attributed *considerForm(const AttributeList &atts, - const AttributeList *linkAtts, - const StringC &name, - Boolean isNotation, - unsigned thisSuppressFlags, - unsigned &newSuppressFlags, - Boolean &inhibitCache, - unsigned &arcFormIndex); - const Attributed *autoForm(const AttributeList &atts, - const StringC &name, - Boolean isNotation, - unsigned thisSuppressFlags, - unsigned &newSuppressFlags, - Boolean &inhibitCache, - unsigned &idIndex); - const Text *considerNamer(const AttributeList &atts, - Boolean &inhibitCache, - unsigned &arcNamerIndex); - void buildAttributeMapRename(MetaMap &map, - const Text &rename, - const AttributeList &atts, - const AttributeList *linkAtts, - Vector &attRenamed); - void buildAttributeMapRest(MetaMap &map, - const AttributeList &atts, - const AttributeList *linkAtts, - const Vector &attRenamed); - Boolean matchName(const StringC &name, const char *key); - void split(const Text &text, - Char space, - Vector &tokens, - Vector &tokenPos); - Boolean mapAttributes(const AttributeList &from, - const AttributeList *fromLink, - const Text *content, - AttributeList &to, - ConstPtr &arcContent, - const MetaMap &map); - void initNotationSet(const Location &loc); - const Attributed *considerNotation(const AttributeList &atts, - unsigned thisSuppressFlags, - Boolean &inhibitCache, - unsigned ¬AttIndex); - void supportAttributes(const AttributeList &); - void processArcOpts(const AttributeList &atts); - void processArcQuant(const Text &); - ConstPtr makeDtdEntity(const Notation *); - void mungeMetaDtd(Dtd &metaDtd, const Dtd &docDtd); - Boolean mungeDataEntity(ExternalDataEntity &entity); - void emitArcContent(const Text &text, - EventHandler &handler, - Allocator &allocator); - - Boolean valid_; - StringC name_; - Messenger *mgr_; - ConstPtr docDtd_; - ConstPtr metaDtd_; - ConstPtr docSyntax_; - ConstPtr metaSyntax_; - ConstPtr docSd_; - enum ReservedName { - rArcFormA, - rArcNamrA, - rArcSuprA, - rArcIgnDA, - rArcDocF, - rArcSuprF, - rArcBridF, - rArcDataF, - rArcAuto, - rArcIndr, - rArcDTD, - rArcQuant - }; - enum { nReserve = rArcQuant + 1 }; - StringC supportAtts_[nReserve]; - Boolean arcDtdIsParam_; - Boolean arcAuto_; - Vector arcOpts_; - StringC rniContent_; - StringC rniArcCont_; - StringC rniDefault_; - enum { - isArc = 01, - suppressForm = 02, - suppressSupr = 04, - ignoreData = 010, - condIgnoreData = 020, - // recovering from invalid data - recoverData = 040 - }; - Vector openElementFlags_; - AttributeList attributeList_; - NCVector > metaMapCache_; - MetaMap noCacheMetaMap_; - NamedTable idTable_; - Vector > currentAttributes_; - ConstPtr defaultNotation_; - Boolean errorIdref_; - Boolean notationSetArch_; - ArcDirector *director_; - EventHandler *docHandler_; - Owner ownEventHandler_; - size_t docIndex_; -}; - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* not ArcProcessor_INCLUDED */ diff --git a/cde/programs/nsgmls/Attribute.C b/cde/programs/nsgmls/Attribute.C deleted file mode 100644 index 4bc76b270..000000000 --- a/cde/programs/nsgmls/Attribute.C +++ /dev/null @@ -1,1346 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: Attribute.C /main/1 1996/07/29 16:46:34 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#ifdef __GNUG__ -#pragma implementation -#endif -#include "splib.h" -#include "Attribute.h" -#include "MessageArg.h" -#include "macros.h" -#include "ParserMessages.h" -#include "StringVectorMessageArg.h" -#include "Syntax.h" -#include "Entity.h" -#include "Notation.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -DeclaredValue::DeclaredValue() -{ -} - -DeclaredValue::~DeclaredValue() -{ -} - -AttributeValue *DeclaredValue::makeValueFromToken(Text &text, - AttributeContext &context, - const StringC &name, - unsigned &specLength) const -{ - return makeValue(text, context, name, specLength); -} - -AttributeSemantics *DeclaredValue::makeSemantics(const TokenizedAttributeValue &, - AttributeContext &, - const StringC &, - unsigned &, - unsigned &) const -{ - return 0; -} - -Boolean DeclaredValue::containsToken(const StringC &) const -{ - return 0; -} - -Boolean DeclaredValue::isNotation() const -{ - return 0; -} - -Boolean DeclaredValue::isEntity() const -{ - return 0; -} - -Boolean DeclaredValue::isId() const -{ - return 0; -} - -Boolean DeclaredValue::isIdref() const -{ - return 0; -} - -const Vector *DeclaredValue::getTokens() const -{ - return 0; -} - - -CdataDeclaredValue::CdataDeclaredValue() -{ -} - -Boolean CdataDeclaredValue::tokenized() const -{ - return 0; -} - -AttributeValue *CdataDeclaredValue::makeValue(Text &text, AttributeContext &context, - const StringC &, - unsigned &specLength) const -{ - const Syntax &syntax = context.attributeSyntax(); - size_t normsep = syntax.normsep(); - size_t normalizedLength = text.size() + (normsep - * (1 + text.nDataEntities())); - specLength += normalizedLength; - size_t litlen = syntax.litlen(); - // A length error will already have been given if - // length > litlen - normsep. - if (litlen >= normsep && text.size() <= litlen - normsep - && normalizedLength > litlen) - context.message(ParserMessages::normalizedAttributeValueLength, - NumberMessageArg(litlen), - NumberMessageArg(normalizedLength)); - return new CdataAttributeValue(text); -} - -void CdataDeclaredValue::buildDesc(AttributeDefinitionDesc &desc) const -{ - desc.declaredValue = AttributeDefinitionDesc::cdata; -} - -DeclaredValue *CdataDeclaredValue::copy() const -{ - return new CdataDeclaredValue(*this); -} - -TokenizedDeclaredValue::TokenizedDeclaredValue(TokenType type, - Boolean isList) -: type_(type), isList_(isList) -{ - switch (type) { - case name: - case entityName: - initialCategories_ = Syntax::nameStartCategory; - subsequentCategories_ = (Syntax::nameStartCategory|Syntax::digitCategory - | Syntax::otherNameCategory); - break; - case number: - initialCategories_ = Syntax::digitCategory; - subsequentCategories_ = Syntax::digitCategory; - break; - case nameToken: - initialCategories_ = (Syntax::nameStartCategory|Syntax::digitCategory - | Syntax::otherNameCategory); - subsequentCategories_ = initialCategories_; - break; - case numberToken: - initialCategories_ = Syntax::digitCategory; - subsequentCategories_ = (Syntax::nameStartCategory|Syntax::digitCategory - | Syntax::otherNameCategory); - break; - } -} - -Boolean TokenizedDeclaredValue::tokenized() const -{ - return 1; -} - -AttributeValue *TokenizedDeclaredValue::makeValue(Text &text, - AttributeContext &context, - const StringC &str, - unsigned &specLength) const -{ - return makeTokenizedValue(text, context, str, specLength); -} - -TokenizedAttributeValue * -TokenizedDeclaredValue::makeTokenizedValue(Text &text, - AttributeContext &context, - const StringC &name, - unsigned &specLength) const -{ - const Syntax &syntax = context.attributeSyntax(); - Vector spaceIndex; - Char space = syntax.space(); - text.subst(*(type_ == entityName - ? syntax.entitySubstTable() - : syntax.generalSubstTable()), - space); - const StringC &value = text.string(); - size_t i = 0; - size_t length = value.size(); - - for (;;) { - if (i >= length) { - // ends with a space (which would have to have been entered - // via a numeric character reference) - context.message(ParserMessages::attributeValueSyntax); - return 0; - } - if (!(syntax.charCategory(value[i]) & initialCategories_)) { - context.Messenger::setNextLocation(text.charLocation(i)); - Char c = value[i]; - if (!(syntax.charCategory(value[i]) & subsequentCategories_)) - context.message(ParserMessages::attributeValueChar, - StringMessageArg(StringC(&c, 1)), - StringMessageArg(name)); - else if (initialCategories_ == Syntax::digitCategory) - context.message(ParserMessages::attributeValueNumberToken, - StringMessageArg(StringC(&c, 1)), - StringMessageArg(name)); - else - context.message(ParserMessages::attributeValueName, - StringMessageArg(StringC(&c, 1)), - StringMessageArg(name)); - return 0; - } - size_t startIndex = i; - for (++i; - i < length - && (syntax.charCategory(value[i]) & subsequentCategories_); - i++) - ; - if (i - startIndex > syntax.namelen()) { - context.Messenger::setNextLocation(text.charLocation(i)); - context.message(ParserMessages::nameTokenLength, - NumberMessageArg(syntax.namelen())); - } - if (i == length) - break; - if (value[i] == space) { - if (!isList_) { - context.Messenger::setNextLocation(text.charLocation(i)); - context.message(ParserMessages::attributeValueMultiple, - StringMessageArg(name)); - return 0; - } - spaceIndex.push_back(i); - i++; - } - else { - Char c = value[i]; - // character value[i] is not allowed anywhere in the value - context.Messenger::setNextLocation(text.charLocation(i)); - context.message(ParserMessages::attributeValueChar, - StringMessageArg(StringC(&c, 1)), - StringMessageArg(name)); - return 0; - } - } - size_t normsep = syntax.normsep(); - size_t litlen = syntax.litlen(); - size_t normalizedLength = normsep + length; - // should we count CDATA and SDATA entities here? - if (isList_) { - normalizedLength += 1; - // length is now the number of characters in each token in the list - // + 1 for each token in the list; so add normsep - 1 for each - // token in the list. - if (normsep > 0) - normalizedLength += (normsep - 1)*(spaceIndex.size() + 1); - else - normalizedLength -= spaceIndex.size() + 1; - } - specLength += normalizedLength; - // A length error will already have been given if - // length > litlen - normsep. - if (litlen >= normsep && length <= litlen - normsep - && normalizedLength > litlen) - context.message(ParserMessages::normalizedAttributeValueLength, - NumberMessageArg(litlen), - NumberMessageArg(normalizedLength)); - return new TokenizedAttributeValue(text, spaceIndex); -} - -Boolean TokenizedAttributeValue::recoverUnquoted(const StringC &str, - const Location &strLoc, - AttributeContext &context, - const StringC &name) -{ - TextIter iter(text_); - TextItem::Type type; - const Char *s; - size_t len; - const Location *loc; - if (iter.next(type, s, len, loc) - && type == TextItem::data - && len == text_.size() - && loc->origin().pointer() == strLoc.origin().pointer() - && loc->index() + len == strLoc.index() - && !iter.next(type, s, len, loc)) { - context.Messenger::setNextLocation(strLoc); - context.message(ParserMessages::attributeValueChar, - StringMessageArg(StringC(str.data(), 1)), - StringMessageArg(name)); - return 1; - } - return 0; -} - -void TokenizedDeclaredValue::buildDesc(AttributeDefinitionDesc &desc) const -{ - desc.declaredValue = AttributeDefinitionDesc::DeclaredValue( - type_ - name + (isList_ - ? AttributeDefinitionDesc::names - : AttributeDefinitionDesc::name)); -} - -DeclaredValue *TokenizedDeclaredValue::copy() const -{ - return new TokenizedDeclaredValue(*this); -} - -GroupDeclaredValue::GroupDeclaredValue(TokenType type, - Vector &vec) -: TokenizedDeclaredValue(type, 0) -{ - vec.swap(allowedValues_); -} - -void GroupDeclaredValue::buildDesc(AttributeDefinitionDesc &desc) const -{ - desc.allowedValues = allowedValues_; -} - -DeclaredValue *GroupDeclaredValue::copy() const -{ - return new GroupDeclaredValue(*this); -} - -AttributeValue *GroupDeclaredValue::makeValue(Text &text, - AttributeContext &context, - const StringC &name, - unsigned &specLength) const -{ - TokenizedAttributeValue *val = makeTokenizedValue(text, context, name, - specLength); - if (!val) - return 0; - for (size_t i = 0; i < allowedValues_.size(); i++) - if (val->string() == allowedValues_[i]) - return val; - context.message(ParserMessages::attributeValueNotInGroup, - StringMessageArg(val->string()), - StringMessageArg(name), - StringVectorMessageArg(allowedValues_)); - delete val; - return 0; -} - -AttributeValue *GroupDeclaredValue::makeValueFromToken(Text &text, - AttributeContext &context, - const StringC &, - unsigned &specLength) - const -{ - const Syntax &syntax = context.attributeSyntax(); - size_t litlen = syntax.litlen(); - size_t normsep = syntax.normsep(); - if (normsep > litlen || text.size() > litlen - normsep) - context.message(ParserMessages::normalizedAttributeValueLength, - NumberMessageArg(litlen), - NumberMessageArg(text.size() + normsep)); - specLength += text.size() + normsep; - return new TokenizedAttributeValue(text, Vector()); -} - -Boolean GroupDeclaredValue::containsToken(const StringC &token) const -{ - for (size_t i = 0; i < allowedValues_.size(); i++) - if (allowedValues_[i] == token) - return 1; - return 0; -} - -const Vector *GroupDeclaredValue::getTokens() const -{ - return &allowedValues_; -} - -NameTokenGroupDeclaredValue::NameTokenGroupDeclaredValue(Vector &vec) -: GroupDeclaredValue(nameToken, vec) -{ -} - -void NameTokenGroupDeclaredValue::buildDesc(AttributeDefinitionDesc &desc) const -{ - GroupDeclaredValue::buildDesc(desc); - desc.declaredValue = AttributeDefinitionDesc::nameTokenGroup; -} - -DeclaredValue *NameTokenGroupDeclaredValue::copy() const -{ - return new NameTokenGroupDeclaredValue(*this); -} - -NotationDeclaredValue::NotationDeclaredValue(Vector &vec) -: GroupDeclaredValue(name, vec) -{ -} - -Boolean NotationDeclaredValue::isNotation() const -{ - return 1; -} - -AttributeSemantics * -NotationDeclaredValue::makeSemantics(const TokenizedAttributeValue &value, - AttributeContext &context, - const StringC &, - unsigned &, - unsigned &) const -{ - ConstPtr notation - = context.getAttributeNotation(value.string(), - value.tokenLocation(0)); - if (notation.isNull()) { - context.setNextLocation(value.tokenLocation(0)); - context.message(ParserMessages::invalidNotationAttribute, - StringMessageArg(value.string())); - return 0; - } - return new NotationAttributeSemantics(notation); -} - -void NotationDeclaredValue::buildDesc(AttributeDefinitionDesc &desc) const -{ - GroupDeclaredValue::buildDesc(desc); - desc.declaredValue = AttributeDefinitionDesc::notation; -} - -DeclaredValue *NotationDeclaredValue::copy() const -{ - return new NotationDeclaredValue(*this); -} - -EntityDeclaredValue::EntityDeclaredValue(Boolean isList) -: TokenizedDeclaredValue(entityName, isList) -{ -} - -Boolean EntityDeclaredValue::isEntity() const -{ - return 1; -} - -AttributeSemantics * -EntityDeclaredValue::makeSemantics(const TokenizedAttributeValue &value, - AttributeContext &context, - const StringC &, - unsigned &, - unsigned &nEntityNames) const -{ - Boolean valid = 1; - size_t nTokens = value.nTokens(); - nEntityNames += nTokens; - Vector > entities(nTokens); - for (size_t i = 0; i < nTokens; i++) { - entities[i] = context.getAttributeEntity(value.token(i), - value.tokenLocation(i)); - if (entities[i].isNull()) { - context.setNextLocation(value.tokenLocation(i)); - context.message(ParserMessages::invalidEntityAttribute, - StringMessageArg(value.token(i))); - valid = 0; - } - else if (!entities[i]->isDataOrSubdoc()) { - context.Messenger::setNextLocation(value.tokenLocation(i)); - context.message(ParserMessages::notDataOrSubdocEntity, - StringMessageArg(value.token(i))); - valid = 0; - } - } - if (valid) - return new EntityAttributeSemantics(entities); - else - return 0; -} - -DeclaredValue *EntityDeclaredValue::copy() const -{ - return new EntityDeclaredValue(*this); -} - -IdDeclaredValue::IdDeclaredValue() -: TokenizedDeclaredValue(name, 0) -{ -} - -Boolean IdDeclaredValue::isId() const -{ - return 1; -} - -AttributeSemantics * -IdDeclaredValue::makeSemantics(const TokenizedAttributeValue &value, - AttributeContext &context, - const StringC &, - unsigned &, - unsigned &) const -{ - Location prevLoc; - if (!context.defineId(value.string(), value.tokenLocation(0), prevLoc)) { - context.setNextLocation(value.tokenLocation(0)); - context.message(ParserMessages::duplicateId, - StringMessageArg(value.string()), - prevLoc); - } - return 0; -} - -void IdDeclaredValue::buildDesc(AttributeDefinitionDesc &desc) const -{ - desc.declaredValue = AttributeDefinitionDesc::id; -} - -DeclaredValue *IdDeclaredValue::copy() const -{ - return new IdDeclaredValue(*this); -} - -IdrefDeclaredValue::IdrefDeclaredValue(Boolean isList) -: TokenizedDeclaredValue(name, isList) -{ -} - -AttributeSemantics * -IdrefDeclaredValue::makeSemantics(const TokenizedAttributeValue &value, - AttributeContext &context, - const StringC &, - unsigned &nIdrefs, - unsigned &) const -{ - size_t nTokens = value.nTokens(); - nIdrefs += nTokens; - for (size_t i = 0; i < nTokens; i++) - context.noteIdref(value.token(i), value.tokenLocation(i)); - return 0; -} - -Boolean IdrefDeclaredValue::isIdref() const -{ - return 1; -} - -void IdrefDeclaredValue::buildDesc(AttributeDefinitionDesc &desc) const -{ - TokenizedDeclaredValue::buildDesc(desc); - if (desc.declaredValue == AttributeDefinitionDesc::name) - desc.declaredValue = AttributeDefinitionDesc::idref; - else - desc.declaredValue = AttributeDefinitionDesc::idrefs; -} - -DeclaredValue *IdrefDeclaredValue::copy() const -{ - return new IdrefDeclaredValue(*this); -} - - -AttributeDefinition::AttributeDefinition(const StringC &name, - DeclaredValue *value) -: name_(name), declaredValue_(value) -{ -} - -AttributeDefinition::~AttributeDefinition() -{ -} - -AttributeValue *AttributeDefinition::checkValue(AttributeValue *p, - AttributeContext &) const -{ - return p; -} - -Boolean AttributeDefinition::missingValueWouldMatch(const Text &, - const AttributeContext &) const -{ - return 0; -} - -const AttributeValue * -AttributeDefinition::defaultValue(const AttributeValue *) const -{ - return 0; -} - -void AttributeDefinition::getDesc(AttributeDefinitionDesc &desc) const -{ - desc.allowedValues.clear(); - desc.defaultValue.clear(); - desc.currentIndex = 0; - buildDesc(desc); - declaredValue_->buildDesc(desc); -} - -Boolean AttributeDefinition::isConref() const -{ - return 0; -} - -Boolean AttributeDefinition::isCurrent() const -{ - return 0; -} - -Boolean AttributeDefinition::isFixed() const -{ - return 0; -} - -RequiredAttributeDefinition::RequiredAttributeDefinition(const StringC &name, - DeclaredValue *value) -: AttributeDefinition(name, value) -{ -} - -ConstPtr -RequiredAttributeDefinition::makeMissingValue(AttributeContext &context) const -{ - context.message(ParserMessages::requiredAttributeMissing, - StringMessageArg(name())); - return 0; -} - -void RequiredAttributeDefinition::buildDesc(AttributeDefinitionDesc &desc) const -{ - desc.defaultValueType = AttributeDefinitionDesc::required; -} - -AttributeDefinition *RequiredAttributeDefinition::copy() const -{ - return new RequiredAttributeDefinition(*this); -} - -CurrentAttributeDefinition::CurrentAttributeDefinition(const StringC &name, DeclaredValue *value, size_t index) -: AttributeDefinition(name, value), currentIndex_(index) -{ -} - -ConstPtr -CurrentAttributeDefinition::makeMissingValue(AttributeContext &context) const -{ - if (context.mayDefaultAttribute()) { - ConstPtr currentValue - = context.getCurrentAttribute(currentIndex_); - if (currentValue.isNull()) - context.message(ParserMessages::currentAttributeMissing, - StringMessageArg(name())); - return currentValue; - } - else { - context.message(ParserMessages::attributeMissing, - StringMessageArg(name())); - return 0; - } -} - -Boolean CurrentAttributeDefinition::missingValueWouldMatch(const Text &text, - const AttributeContext &context) const -{ - if (!context.mayDefaultAttribute()) - return 0; - ConstPtr currentValue - = context.getCurrentAttribute(currentIndex_); - if (currentValue.isNull()) - return 0; - return text.fixedEqual(*currentValue->text()); -} - -AttributeValue * -CurrentAttributeDefinition::checkValue(AttributeValue *value, - AttributeContext &context) const -{ - context.noteCurrentAttribute(currentIndex_, value); - return value; -} - -void CurrentAttributeDefinition::buildDesc(AttributeDefinitionDesc &desc) const -{ - desc.defaultValueType = AttributeDefinitionDesc::current; - desc.currentIndex = currentIndex_; -} - -AttributeDefinition *CurrentAttributeDefinition::copy() const -{ - return new CurrentAttributeDefinition(*this); -} - -Boolean CurrentAttributeDefinition::isCurrent() const -{ - return 1; -} - -ImpliedAttributeDefinition::ImpliedAttributeDefinition(const StringC &name, - DeclaredValue *value) -: AttributeDefinition(name, value) -{ -} - -ConstPtr -ImpliedAttributeDefinition::makeMissingValue(AttributeContext &context) const -{ - return context.makeImpliedAttributeValue(); -} - -void ImpliedAttributeDefinition::buildDesc(AttributeDefinitionDesc &desc) const -{ - desc.defaultValueType = AttributeDefinitionDesc::implied; -} - -AttributeDefinition *ImpliedAttributeDefinition::copy() const -{ - return new ImpliedAttributeDefinition(*this); -} - -const AttributeValue * -ImpliedAttributeDefinition::defaultValue(const AttributeValue *impliedValue) - const -{ - return impliedValue; -} - -ConrefAttributeDefinition::ConrefAttributeDefinition(const StringC &name, - DeclaredValue *value) -: ImpliedAttributeDefinition(name, value) -{ -} - -Boolean ConrefAttributeDefinition::isConref() const -{ - return 1; -} - -void ConrefAttributeDefinition::buildDesc(AttributeDefinitionDesc &desc) const -{ - desc.defaultValueType = AttributeDefinitionDesc::conref; -} - -AttributeDefinition *ConrefAttributeDefinition::copy() const -{ - return new ConrefAttributeDefinition(*this); -} - -DefaultAttributeDefinition::DefaultAttributeDefinition(const StringC &name, - DeclaredValue *declaredValue, - AttributeValue *defaultValue) -: AttributeDefinition(name, declaredValue), - value_(defaultValue) -{ -} - -ConstPtr -DefaultAttributeDefinition::makeMissingValue(AttributeContext &context) const -{ - if (context.mayDefaultAttribute()) - return value_; - else { - context.message(ParserMessages::attributeMissing, - StringMessageArg(name())); - return 0; - } -} - -Boolean DefaultAttributeDefinition::missingValueWouldMatch(const Text &text, - const AttributeContext &context) const -{ - return context.mayDefaultAttribute() && text.fixedEqual(*value_->text()); -} - -void DefaultAttributeDefinition::buildDesc(AttributeDefinitionDesc &desc) const -{ - desc.defaultValueType = AttributeDefinitionDesc::defaulted; - desc.defaultValue = value_; -} - -AttributeDefinition *DefaultAttributeDefinition::copy() const -{ - return new DefaultAttributeDefinition(*this); -} - -FixedAttributeDefinition:: FixedAttributeDefinition(const StringC &name, - DeclaredValue *declaredValue, - AttributeValue *defaultValue) -: DefaultAttributeDefinition(name, declaredValue, defaultValue) -{ -} - -Boolean FixedAttributeDefinition::isFixed() const -{ - return 1; -} - -AttributeValue *FixedAttributeDefinition::checkValue(AttributeValue *value, - AttributeContext &context) - const -{ - const AttributeValue *fixedValue - = DefaultAttributeDefinition::defaultValue(0); - if (value && fixedValue) { - const Text *text; - const StringC *str; - const Text *fixedText; - const StringC *fixedStr; - switch (value->info(text, str)) { - case AttributeValue::implied: - CANNOT_HAPPEN(); - case AttributeValue::cdata: - if (fixedValue->info(fixedText, fixedStr) == AttributeValue::cdata) { - if (!text->fixedEqual(*fixedText)) - context.message(ParserMessages::notFixedValue, StringMessageArg(name())); - } - break; - case AttributeValue::tokenized: - if (fixedValue->info(fixedText, fixedStr) == AttributeValue::tokenized) { - if (*str != *fixedStr) - context.message(ParserMessages::notFixedValue, StringMessageArg(name())); - } - break; - } - } - return value; -} - -void FixedAttributeDefinition::buildDesc(AttributeDefinitionDesc &desc) const -{ - // get the fixed value - DefaultAttributeDefinition::buildDesc(desc); - desc.defaultValueType = AttributeDefinitionDesc::fixed; -} - -AttributeDefinition *FixedAttributeDefinition::copy() const -{ - return new FixedAttributeDefinition(*this); -} - -AttributeDefinitionList -::AttributeDefinitionList(Vector > &vec, - size_t index, - Boolean anyCurrent, - size_t idIndex, - size_t notationIndex) -: index_(index), anyCurrent_(anyCurrent), idIndex_(idIndex), - notationIndex_(notationIndex) -{ - defs_.swap(vec); -} - -Boolean AttributeDefinitionList::tokenIndex(const StringC &token, unsigned &index) const -{ - for (size_t i = 0; i < defs_.size(); i++) - if (defs_[i]->containsToken(token)) { - index = i; - return 1; - } - return 0; -} - -Boolean AttributeDefinitionList::attributeIndex(const StringC &name, - unsigned &index) const -{ - for (size_t i = 0; i < defs_.size(); i++) - if (defs_[i]->name() == name) { - index = i; - return 1; - } - return 0; -} - -void AttributeDefinitionList::append(AttributeDefinition *def) -{ - if (def->isId() && idIndex_ == size_t(-1)) - idIndex_ = defs_.size(); - if (def->isNotation() && notationIndex_ == size_t(-1)) - notationIndex_ = defs_.size(); - if (def->isCurrent()) - anyCurrent_ = 1; - defs_.resize(defs_.size() + 1); - defs_.back() = def; -} - -AttributeSemantics::AttributeSemantics() -{ -} - -AttributeSemantics::~AttributeSemantics() -{ -} - -size_t AttributeSemantics::nEntities() const -{ - return 0; -} - -ConstPtr AttributeSemantics::entity(size_t) const -{ - return 0; -} - -ConstPtr AttributeSemantics::notation() const -{ - return 0; -} - - -NotationAttributeSemantics::NotationAttributeSemantics(const ConstPtr ¬ation) -: notation_(notation) -{ -} - -ConstPtr NotationAttributeSemantics::notation() const -{ - return notation_; -} - -AttributeSemantics *NotationAttributeSemantics::copy() const -{ - return new NotationAttributeSemantics(*this); -} - -EntityAttributeSemantics::EntityAttributeSemantics(Vector > &entity) -{ - entity.swap(entity_); -} - -size_t EntityAttributeSemantics::nEntities() const -{ - return entity_.size(); -} - -ConstPtr EntityAttributeSemantics::entity(size_t i) const -{ - return entity_[i]; -} - -AttributeSemantics *EntityAttributeSemantics::copy() const -{ - return new EntityAttributeSemantics(*this); -} - -AttributeValue::AttributeValue() -{ -} - -AttributeValue::~AttributeValue() -{ -} - -AttributeSemantics *AttributeValue::makeSemantics(const DeclaredValue *, - AttributeContext &, - const StringC &, - unsigned &, - unsigned &) const -{ - return 0; -} - -const Text *AttributeValue::text() const -{ - return 0; -} - -Boolean AttributeValue::recoverUnquoted(const StringC &, const Location &, - AttributeContext &, const StringC &) -{ - return 0; -} - -ImpliedAttributeValue::ImpliedAttributeValue() -{ -} - -AttributeValue::Type ImpliedAttributeValue::info(const Text *&, - const StringC *&) const -{ - return implied; -} - -TokenizedAttributeValue::TokenizedAttributeValue(Text &text, - const Vector &spaceIndex) -: spaceIndex_(spaceIndex) -{ - text.swap(text_); -} - -AttributeValue::Type TokenizedAttributeValue::info(const Text *&, - const StringC *&string) const -{ - string = &text_.string(); - return tokenized; -} - -const Text *TokenizedAttributeValue::text() const -{ - return &text_; -} - -AttributeSemantics * -TokenizedAttributeValue::makeSemantics(const DeclaredValue *value, - AttributeContext &context, - const StringC &name, - unsigned &nIdrefs, - unsigned &nEntityNames) const -{ - return value->makeSemantics(*this, context, name, nIdrefs, nEntityNames); -} - -CdataAttributeValue::CdataAttributeValue(Text &text) -{ - text.swap(text_); -} - -AttributeValue::Type CdataAttributeValue::info(const Text *&text, - const StringC *&) const -{ - text = &text_; - return cdata; -} - -const Text *CdataAttributeValue::text() const -{ - return &text_; -} - -Boolean CdataAttributeValue::recoverUnquoted(const StringC &str, - const Location &strLoc, - AttributeContext &context, - const StringC &) -{ - TextIter iter(text_); - TextItem::Type type; - const Char *s; - size_t len; - const Location *loc; - if (iter.next(type, s, len, loc) - && type == TextItem::data - && len == text_.size() - && loc->origin().pointer() == strLoc.origin().pointer() - && loc->index() + len == strLoc.index() - && !iter.next(type, s, len, loc)) { - text_.addChars(str, strLoc); - context.Messenger::setNextLocation(strLoc); - context.message(ParserMessages::unquotedAttributeValue); - return 1; - } - return 0; -} - -Attribute::Attribute() -: specIndexPlus_(0) -{ -} - -void Attribute::clear() -{ - specIndexPlus_ = 0; - value_.clear(); - semantics_.clear(); -} - -AttributeList::AttributeList(const ConstPtr &def) -: def_(def), vec_(def.isNull() ? 0 : def->size()), nSpec_(0), conref_(0), - nIdrefs_(0), nEntityNames_(0) -{ -} - -AttributeList::AttributeList() -: nSpec_(0), conref_(0), nIdrefs_(0), nEntityNames_(0) -{ -} - -void AttributeList::init(const ConstPtr &def) -{ - def_ = def; - nSpec_ = 0; - conref_ = 0; - nIdrefs_ = 0; - nEntityNames_ = 0; - if (def_.isNull()) - vec_.resize(0); - else { - size_t newLength = def_->size(); - size_t clearLim = vec_.size(); - if (clearLim > newLength) - clearLim = newLength; - vec_.resize(newLength); - for (size_t i = 0; i < clearLim; i++) - vec_[i].clear(); - } -} - -void AttributeList::swap(AttributeList &to) -{ - vec_.swap(to.vec_); - def_.swap(to.def_); - { - unsigned tem = to.nIdrefs_; - to.nIdrefs_ = nIdrefs_; - nIdrefs_ = tem; - } - { - unsigned tem = to.nEntityNames_; - to.nEntityNames_ = nEntityNames_; - nEntityNames_ = tem; - } - { - size_t tem = to.nSpec_; - to.nSpec_ = nSpec_; - nSpec_ = tem; - } - { - PackedBoolean tem = to.conref_; - to.conref_ = conref_; - conref_ = tem; - } -} - -void AttributeList::finish(AttributeContext &context) -{ - for (size_t i = 0; i < vec_.size(); i++) - if (!vec_[i].specified()) { - ConstPtr value - = def(i)->makeMissingValue(context); - vec_[i].setValue(value); - if (!value.isNull()) - vec_[i].setSemantics(def(i)->makeSemantics(value.pointer(), - context, - nIdrefs_, - nEntityNames_)); - } - const Syntax &syntax = context.attributeSyntax(); - if (nIdrefs_ > syntax.grpcnt()) - context.message(ParserMessages::idrefGrpcnt, - NumberMessageArg(syntax.grpcnt())); - if (nEntityNames_ > syntax.grpcnt()) - context.message(ParserMessages::entityNameGrpcnt, - NumberMessageArg(syntax.grpcnt())); - if (conref_ - && def_->notationIndex() != size_t(-1) - && specified(def_->notationIndex())) - context.message(ParserMessages::conrefNotation); -} - -void AttributeList::setSpec(unsigned i, AttributeContext &context) -{ - if (vec_[i].specified()) - context.message(ParserMessages::duplicateAttributeSpec, - StringMessageArg(def(i)->name())); - else - vec_[i].setSpec(nSpec_++); -} - -void AttributeList::noteInvalidSpec() -{ - nSpec_++; -} - -Boolean AttributeList::setValue(unsigned i, Text &text, - AttributeContext &context, - unsigned &specLength) -{ - AttributeValue *value = def(i)->makeValue(text, context, specLength); - if (def(i)->isConref()) - conref_ = 1; - vec_[i].setValue(value); - if (value) - vec_[i].setSemantics(def(i)->makeSemantics(value, context, - nIdrefs_, nEntityNames_)); - else if (AttributeValue::handleAsUnterminated(text, context)) - return 0; - return 1; -} - -void AttributeList::setValueToken(unsigned i, Text &text, - AttributeContext &context, - unsigned &specLength) -{ - AttributeValue *value = def(i)->makeValueFromToken(text, context, - specLength); - if (def(i)->isConref()) - conref_ = 1; - vec_[i].setValue(value); - if (value) - vec_[i].setSemantics(def(i)->makeSemantics(value, context, - nIdrefs_, nEntityNames_)); -} - -const StringC *AttributeList::getId() const -{ - // Check for no attributes - if (def_.isNull()) - return 0; - // Check for no ID declared - size_t i = def_->idIndex(); - if (i == size_t(-1)) - return 0; - // Check for invalid value - const AttributeValue *v = value(i); - if (!v) - return 0; - // Check for implied value - const Text *t = v->text(); - if (!t) - return 0; - return &t->string(); -} - -Boolean AttributeList::recoverUnquoted(const StringC &str, - const Location &strLoc, - AttributeContext &context) -{ - if (nSpec_ > 0) { - for (size_t i = 0; i < vec_.size(); i++) - if (vec_[i].specified() && vec_[i].specIndex() == nSpec_ - 1) { - const AttributeValue *val = vec_[i].value(); - if (val) - // I wish I could avoid casting away const here. - return ((AttributeValue *)val)->recoverUnquoted(str, strLoc, context, - name(i)); - break; - } - return 1; - } - return 0; -} - -Boolean AttributeList::handleAsUnterminated(AttributeContext &context) -{ - if (nSpec_ > 0) { - for (size_t i = 0; i < vec_.size(); i++) { - if (vec_[i].specified() && vec_[i].specIndex() == nSpec_ - 1) { - const AttributeValue *val = vec_[i].value(); - const Text *ptr; - if (val && (ptr = val->text()) != 0 - && AttributeValue::handleAsUnterminated(*ptr, context)) - return 1; - break; - } - } - } - return 0; -} - -// This tries to guess this attribute value looks like if it had -// a missing ending quote. - -Boolean AttributeValue::handleAsUnterminated(const Text &text, - AttributeContext &context) -{ - TextIter iter(text); - const Char *lastStr = 0; - size_t lastLen; - Location startLoc; - const Location *loc; - TextItem::Type type; - const Char *str; - size_t len; - while (iter.next(type, str, len, loc)) { - if (startLoc.origin().isNull() && !loc->origin().isNull()) - startLoc = *loc; - switch (type) { - case TextItem::data: - if (len != 1 || *str != context.attributeSyntax().space()) { - lastStr = str; - lastLen = len; - } - break; - case TextItem::endDelim: - case TextItem::endDelimA: - case TextItem::ignore: - break; - default: - lastStr = 0; - break; - } - } - if (lastStr) { - while (lastLen > 0 - && lastStr[lastLen - 1] == context.attributeSyntax().space()) - lastLen--; - const StringC &vi = context.attributeSyntax().delimGeneral(Syntax::dVI); - if (lastLen >= vi.size() - && (vi - == StringC(lastStr + (lastLen - vi.size()), vi.size()))) { - context.Messenger::setNextLocation(startLoc); - context.message(ParserMessages::literalClosingDelimiter); - return 1; - } - } - return 0; -} - -AttributeContext::AttributeContext() -: mayDefaultAttribute_(0) -{ -} - -AttributeContext::~AttributeContext() -{ -} - -Boolean AttributeContext::defineId(const StringC &, const Location &, - Location &) -{ - return 1; -} - -void AttributeContext::noteIdref(const StringC &, const Location &) -{ -} - -void AttributeContext::noteCurrentAttribute(size_t, AttributeValue *) -{ -} - -ConstPtr AttributeContext::getCurrentAttribute(size_t) const -{ - return 0; -} - -ConstPtr AttributeContext::getAttributeEntity(const StringC &, - const Location &) -{ - return 0; -} - -ConstPtr AttributeContext::getAttributeNotation(const StringC &, - const Location &) -{ - return 0; -} - -ConstPtr AttributeContext::makeImpliedAttributeValue() -{ - if (impliedAttributeValue_.isNull()) - impliedAttributeValue_ = new ImpliedAttributeValue; - return impliedAttributeValue_; -} - -#ifdef SP_NAMESPACE -} -#endif diff --git a/cde/programs/nsgmls/Attribute.h b/cde/programs/nsgmls/Attribute.h deleted file mode 100644 index 2a2e64893..000000000 --- a/cde/programs/nsgmls/Attribute.h +++ /dev/null @@ -1,903 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: Attribute.h /main/1 1996/07/29 16:46:39 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#ifndef Attribute_INCLUDED -#define Attribute_INCLUDED 1 -#ifdef __GNUG__ -#pragma interface -#endif - -#include -#include "Resource.h" -#include "Owner.h" -#include "StringC.h" -#include "Vector.h" -#include "CopyOwner.h" -#include "Boolean.h" -#include "Text.h" -#include "Ptr.h" -#include "Message.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -class Entity; -class Notation; -class DeclaredValue; -class AttributeValue; -class TokenizedAttributeValue; -class AttributeSemantics; -class AttributeContext; -class Syntax; - -class SP_API AttributeDefinitionDesc { -public: - AttributeDefinitionDesc() { } - enum DeclaredValue { - cdata, - name, - number, - nmtoken, - nutoken, - entity, - idref, - names, - numbers, - nmtokens, - nutokens, - entities, - idrefs, - id, - notation, - nameTokenGroup - }; - DeclaredValue declaredValue; - enum DefaultValueType { - required, - current, - implied, - conref, - defaulted, - fixed - }; - DefaultValueType defaultValueType; - ConstPtr defaultValue; - Vector allowedValues; - // Attribute definitions whose default value type is current and - // which have the same currentIndex share current values. - size_t currentIndex; -private: - AttributeDefinitionDesc(const AttributeDefinitionDesc &); // undefined - void operator=(const AttributeDefinitionDesc &); // undefined -}; - -class DeclaredValue { -public: - DeclaredValue(); - virtual ~DeclaredValue(); - // This performs syntactic checking on the value. - virtual AttributeValue *makeValue(Text &, AttributeContext &, - const StringC &name, - unsigned &specLength) const = 0; - // This is used to avoid unnecessary syntactic checking in the - // case where the attribute name and vi have been omitted. - virtual AttributeValue *makeValueFromToken(Text &, - AttributeContext &, - const StringC &name, - unsigned &specLength) const; - // This performs semantic checking on the value. - virtual AttributeSemantics *makeSemantics(const TokenizedAttributeValue &, - AttributeContext &, - const StringC &, - unsigned &nIdrefs, - unsigned &nEntityNames) const; - virtual Boolean containsToken(const StringC &) const; - virtual Boolean tokenized() const = 0; - virtual Boolean isNotation() const; - virtual Boolean isEntity() const; - virtual Boolean isId() const; - virtual Boolean isIdref() const; - virtual const Vector *getTokens() const; - virtual void buildDesc(AttributeDefinitionDesc &) const = 0; - virtual DeclaredValue *copy() const = 0; -}; - -class CdataDeclaredValue : public DeclaredValue { -public: - CdataDeclaredValue(); - Boolean tokenized() const; - AttributeValue *makeValue(Text &, AttributeContext &, const StringC &, - unsigned &) const; - void buildDesc(AttributeDefinitionDesc &) const; - DeclaredValue *copy() const; -}; - -class TokenizedDeclaredValue : public DeclaredValue { -public: - // must be in same order as AttributeDefinitionDesc - enum TokenType { - name, - number, - nameToken, - numberToken, - entityName - }; - TokenizedDeclaredValue(TokenType type, Boolean isList); - AttributeValue *makeValue(Text &, AttributeContext &, const StringC &, - unsigned &) const; - TokenizedAttributeValue *makeTokenizedValue(Text &, AttributeContext &, - const StringC &, unsigned &) const; - Boolean tokenized() const; - void buildDesc(AttributeDefinitionDesc &) const; - DeclaredValue *copy() const; -private: - TokenType type_; - Boolean isList_; - unsigned initialCategories_; - unsigned subsequentCategories_; -}; - -class GroupDeclaredValue : public TokenizedDeclaredValue { -public: - GroupDeclaredValue(TokenType, Vector &); - Boolean containsToken(const StringC &) const; - AttributeValue *makeValue(Text &, AttributeContext &, const StringC &, - unsigned &) const; - AttributeValue *makeValueFromToken(Text &, - AttributeContext &, - const StringC &name, - unsigned &) const; - const Vector *getTokens() const; - void buildDesc(AttributeDefinitionDesc &) const; - DeclaredValue *copy() const; -private: - Vector allowedValues_; -}; - -class NameTokenGroupDeclaredValue : public GroupDeclaredValue { -public: - NameTokenGroupDeclaredValue(Vector &); - void buildDesc(AttributeDefinitionDesc &) const; - DeclaredValue *copy() const; -}; - -class NotationDeclaredValue : public GroupDeclaredValue { -public: - NotationDeclaredValue(Vector &); - AttributeSemantics *makeSemantics(const TokenizedAttributeValue &, - AttributeContext &, - const StringC &, - unsigned &nIdrefs, - unsigned &nEntityNames) const; - Boolean isNotation() const; - void buildDesc(AttributeDefinitionDesc &) const; - DeclaredValue *copy() const; -}; - -class EntityDeclaredValue : public TokenizedDeclaredValue { -public: - EntityDeclaredValue(Boolean isList); - AttributeSemantics *makeSemantics(const TokenizedAttributeValue &, - AttributeContext &, - const StringC &, - unsigned &nIdrefs, - unsigned &nEntityNames) const; - Boolean isEntity() const; - DeclaredValue *copy() const; -}; - -class IdDeclaredValue : public TokenizedDeclaredValue { -public: - IdDeclaredValue(); - AttributeSemantics *makeSemantics(const TokenizedAttributeValue &, - AttributeContext &, - const StringC &, - unsigned &nIdrefs, - unsigned &nEntityNames) const; - Boolean isId() const; - void buildDesc(AttributeDefinitionDesc &) const; - DeclaredValue *copy() const; -}; - -class IdrefDeclaredValue : public TokenizedDeclaredValue { -public: - IdrefDeclaredValue(Boolean isList); - AttributeSemantics *makeSemantics(const TokenizedAttributeValue &, - AttributeContext &, - const StringC &, - unsigned &nIdrefs, - unsigned &nEntityNames) const; - Boolean isIdref() const; - void buildDesc(AttributeDefinitionDesc &) const; - DeclaredValue *copy() const; -}; - -class SP_API AttributeDefinition { -public: - AttributeDefinition(const StringC &, DeclaredValue *); - virtual ~AttributeDefinition(); - virtual ConstPtr - makeMissingValue(AttributeContext &) const = 0; - virtual Boolean missingValueWouldMatch(const Text &, - const AttributeContext &) const; - virtual const AttributeValue * - defaultValue(const AttributeValue *impliedValue) const; - AttributeValue *makeValue(Text &, AttributeContext &, unsigned &) const; - AttributeValue *makeValueFromToken(Text &, - AttributeContext &, - unsigned &) const; - - virtual Boolean isConref() const; - virtual Boolean isCurrent() const; - virtual Boolean isFixed() const; - AttributeSemantics *makeSemantics(const AttributeValue *, - AttributeContext &, - unsigned &nIdrefs, - unsigned &nEntityNames) const; - Boolean tokenized() const; - const StringC &name() const; - Boolean containsToken(const StringC &) const; - Boolean isNotation() const; - Boolean isEntity() const; - Boolean isId() const; - Boolean isIdref() const; - void getDesc(AttributeDefinitionDesc &) const; - const Vector *getTokens() const; - virtual AttributeDefinition *copy() const = 0; - void setDeclaredValue(DeclaredValue *); -private: - virtual void buildDesc(AttributeDefinitionDesc &) const = 0; - virtual AttributeValue *checkValue(AttributeValue *, AttributeContext &) const; - StringC name_; - CopyOwner declaredValue_; -}; - -class RequiredAttributeDefinition : public AttributeDefinition { -public: - RequiredAttributeDefinition(const StringC &, DeclaredValue *); - ConstPtr makeMissingValue(AttributeContext &) const; - void buildDesc(AttributeDefinitionDesc &) const; - AttributeDefinition *copy() const; -}; - -class CurrentAttributeDefinition : public AttributeDefinition { -public: - CurrentAttributeDefinition(const StringC &, DeclaredValue *, size_t index); - ConstPtr makeMissingValue(AttributeContext &) const; - Boolean missingValueWouldMatch(const Text &, const AttributeContext &) const; - AttributeValue *checkValue(AttributeValue *, AttributeContext &) const; - void buildDesc(AttributeDefinitionDesc &) const; - Boolean isCurrent() const; - AttributeDefinition *copy() const; -private: - size_t currentIndex_; -}; - -class ImpliedAttributeDefinition : public AttributeDefinition { -public: - ImpliedAttributeDefinition(const StringC &, DeclaredValue *); - ConstPtr makeMissingValue(AttributeContext &) const; - const AttributeValue *defaultValue(const AttributeValue *) const; - void buildDesc(AttributeDefinitionDesc &) const; - AttributeDefinition *copy() const; -}; - -class ConrefAttributeDefinition : public ImpliedAttributeDefinition { -public: - ConrefAttributeDefinition(const StringC &, DeclaredValue *); - Boolean isConref() const; - void buildDesc(AttributeDefinitionDesc &) const; - AttributeDefinition *copy() const; -}; - -class DefaultAttributeDefinition : public AttributeDefinition { -public: - DefaultAttributeDefinition(const StringC &, DeclaredValue *, - AttributeValue *); - ConstPtr makeMissingValue(AttributeContext &) const; - Boolean missingValueWouldMatch(const Text &, const AttributeContext &) const; - void buildDesc(AttributeDefinitionDesc &) const; - AttributeDefinition *copy() const; - const AttributeValue *defaultValue(const AttributeValue *) const; -private: - ConstPtr value_; -}; - -class FixedAttributeDefinition : public DefaultAttributeDefinition { -public: - FixedAttributeDefinition(const StringC &, DeclaredValue *, - AttributeValue *); - // check that it's equal to the default - AttributeValue *checkValue(AttributeValue *, AttributeContext &) const; - void buildDesc(AttributeDefinitionDesc &) const; - Boolean isFixed() const; - AttributeDefinition *copy() const; -}; - -class SP_API AttributeDefinitionList : public Resource { -public: - AttributeDefinitionList(Vector > &, - size_t listIndex, - Boolean anyCurrent = 0, - size_t idIndex = size_t(-1), - size_t notationIndex = size_t(-1)); - size_t size() const; - AttributeDefinition *def(size_t); - const AttributeDefinition *def(size_t) const; - Boolean tokenIndex(const StringC &, unsigned &) const; - Boolean attributeIndex(const StringC &, unsigned &) const; - size_t index() const; - size_t idIndex() const; - size_t notationIndex() const; - Boolean anyCurrent() const; - void append(AttributeDefinition *); -private: - Vector > defs_; - size_t index_; - size_t idIndex_; // -1 if no ID attribute - size_t notationIndex_; // -1 if no notation attribute - Boolean anyCurrent_; -}; - -class AttributeSemantics { -public: - AttributeSemantics(); - virtual ~AttributeSemantics(); - virtual size_t nEntities() const; - virtual ConstPtr entity(size_t) const; - virtual ConstPtr notation() const; - virtual AttributeSemantics *copy() const = 0; -}; - -class EntityAttributeSemantics : public AttributeSemantics { -public: - EntityAttributeSemantics(Vector > &); - size_t nEntities() const; - ConstPtr entity(size_t) const; - AttributeSemantics *copy() const; -private: - Vector > entity_; -}; - -class NotationAttributeSemantics : public AttributeSemantics { -public: - NotationAttributeSemantics(const ConstPtr &); - ConstPtr notation() const; - AttributeSemantics *copy() const; -private: - ConstPtr notation_; -}; - -class AttributeValue : public Resource { -public: - enum Type { - implied, - cdata, - tokenized - }; - AttributeValue(); - virtual ~AttributeValue(); - virtual AttributeSemantics *makeSemantics(const DeclaredValue *, - AttributeContext &, - const StringC &, - unsigned &, - unsigned &) const; - virtual Type info(const Text *&, const StringC *&) const = 0; - virtual const Text *text() const; - virtual Boolean recoverUnquoted(const StringC &, const Location &, - AttributeContext &, const StringC &); - static Boolean handleAsUnterminated(const Text &, AttributeContext &); -}; - -class SP_API ImpliedAttributeValue : public AttributeValue { -public: - ImpliedAttributeValue(); - Type info(const Text *&, const StringC *&) const; -}; - -class CdataAttributeValue : public AttributeValue { -public: - CdataAttributeValue(Text &); - Type info(const Text *&, const StringC *&) const; - const Text *text() const; - Boolean recoverUnquoted(const StringC &, const Location &, - AttributeContext &, const StringC &); -private: - Text text_; -}; - -class TokenizedAttributeValue : public AttributeValue { -public: - TokenizedAttributeValue(Text &, const Vector &); - size_t nTokens() const; - AttributeSemantics *makeSemantics(const DeclaredValue *, - AttributeContext &, - const StringC &, - unsigned &, - unsigned &) const; - Type info(const Text *&, const StringC *&) const; - const Text *text() const; - const StringC &string() const; - StringC token(size_t) const; - void token(size_t, const Char *&, size_t &) const; - Location tokenLocation(size_t) const; - Boolean recoverUnquoted(const StringC &, const Location &, - AttributeContext &, const StringC &); -private: - TokenizedAttributeValue(const TokenizedAttributeValue &); // undefined - void operator=(const TokenizedAttributeValue &); // undefined - Text text_; - // index into value of each space - // length is number of tokens - 1 - Vector spaceIndex_; -}; - -class SP_API Attribute { -public: - Attribute(); - Boolean specified() const; - size_t specIndex() const; - const AttributeValue *value() const; - const ConstPtr &valuePointer() const; - const AttributeSemantics *semantics() const; - void setSpec(size_t); - void setValue(const ConstPtr &); - void setSemantics(AttributeSemantics *); - void clear(); -private: - size_t specIndexPlus_; - ConstPtr value_; - CopyOwner semantics_; -}; - -class SP_API AttributeList { -public: - AttributeList(); - AttributeList(const ConstPtr &); - void init(const ConstPtr &); - // was a conref attribute specified? - Boolean conref() const; - size_t size() const; - const StringC &name(unsigned) const; - const AttributeValue *value(unsigned) const; - size_t specIndex(size_t) const; - const ConstPtr &valuePointer(unsigned) const; - const AttributeSemantics *semantics(unsigned) const; - Boolean tokenized(unsigned index) const; - Boolean tokenIndex(const StringC &, unsigned &) const; - Boolean attributeIndex(const StringC &, unsigned &) const; - void finish(AttributeContext &); - Boolean setValue(unsigned index, Text &, AttributeContext &, - unsigned &specLength); - void setValueToken(unsigned index, Text &, AttributeContext &, - unsigned &specLength); - void setSpec(unsigned index, AttributeContext &); - Boolean recoverUnquoted(const StringC &, const Location &, - AttributeContext &); - Boolean handleAsUnterminated(AttributeContext &context); - void swap(AttributeList &); - size_t nSpec() const; - size_t defIndex() const; - // is the attribute #current - Boolean current(unsigned) const; - Boolean anyCurrent() const; - Boolean specified(unsigned) const; - Boolean id(unsigned) const; - Boolean idref(unsigned) const; - const Vector *getAllowedTokens(unsigned) const; - const StringC *getId() const; // null if none - Boolean idIndex(unsigned &) const; - void noteInvalidSpec(); -private: - const AttributeDefinition *def(size_t) const; - PackedBoolean conref_; - unsigned nIdrefs_; - unsigned nEntityNames_; - size_t nSpec_; - Vector vec_; - ConstPtr def_; -}; - -class SP_API AttributeContext : public Messenger { -public: - AttributeContext(); - virtual ~AttributeContext(); - virtual Boolean defineId(const StringC &, const Location &, Location &); - virtual void noteIdref(const StringC &, const Location &); - virtual void noteCurrentAttribute(size_t, AttributeValue *); - virtual ConstPtr getCurrentAttribute(size_t) const; - virtual ConstPtr getAttributeEntity(const StringC &, - const Location &); - virtual ConstPtr getAttributeNotation(const StringC &, - const Location &); - virtual const Syntax &attributeSyntax() const = 0; - - ConstPtr makeImpliedAttributeValue(); - Boolean mayDefaultAttribute() const; -protected: - Boolean mayDefaultAttribute_; -private: - ConstPtr impliedAttributeValue_; -}; - -inline -Boolean AttributeDefinition::tokenized() const -{ - return declaredValue_->tokenized(); -} - -inline -Boolean AttributeDefinition::isNotation() const -{ - return declaredValue_->isNotation(); -} - -inline -Boolean AttributeDefinition::isEntity() const -{ - return declaredValue_->isEntity(); -} - -inline -Boolean AttributeDefinition::isId() const -{ - return declaredValue_->isId(); -} - -inline -Boolean AttributeDefinition::isIdref() const -{ - return declaredValue_->isIdref(); -} - -inline -const Vector *AttributeDefinition::getTokens() const -{ - return declaredValue_->getTokens(); -} - -inline -AttributeSemantics * -AttributeDefinition::makeSemantics(const AttributeValue *value, - AttributeContext &context, - unsigned &nIdrefs, - unsigned &nEntityNames) const -{ - return value->makeSemantics(declaredValue_.pointer(), context, name_, - nIdrefs, nEntityNames); -} - -inline -AttributeValue *AttributeDefinition::makeValue(Text &text, - AttributeContext &context, - unsigned &specLength) const -{ - return checkValue(declaredValue_->makeValue(text, context, name_, - specLength), - context); -} - -inline -AttributeValue * -AttributeDefinition::makeValueFromToken(Text &text, - AttributeContext &context, - unsigned &specLength) const -{ - return checkValue(declaredValue_->makeValueFromToken(text, context, - name_, specLength), - context); -} - -inline -Boolean AttributeDefinition::containsToken(const StringC &token) const -{ - return declaredValue_->containsToken(token); -} - -inline -const StringC &AttributeDefinition::name() const -{ - return name_; -} - -inline -void AttributeDefinition::setDeclaredValue(DeclaredValue *declaredValue) -{ - declaredValue_ = declaredValue; -} - -inline -size_t AttributeDefinitionList::size() const -{ - return defs_.size(); -} - -inline -size_t AttributeDefinitionList::index() const -{ - return index_; -} - -inline -size_t AttributeDefinitionList::idIndex() const -{ - return idIndex_; -} - -inline -size_t AttributeDefinitionList::notationIndex() const -{ - return notationIndex_; -} - -inline -Boolean AttributeDefinitionList::anyCurrent() const -{ - return anyCurrent_; -} - -inline -AttributeDefinition *AttributeDefinitionList::def(size_t i) -{ - return defs_[i].pointer(); -} - -inline -const AttributeDefinition *AttributeDefinitionList::def(size_t i) const -{ - return defs_[i].pointer(); -} - -inline -size_t TokenizedAttributeValue::nTokens() const -{ - return spaceIndex_.size() + 1; -} - -inline -const StringC &TokenizedAttributeValue::string() const -{ - return text_.string(); -} - -inline -void TokenizedAttributeValue::token(size_t i, - const Char *&ptr, size_t &len) const -{ - size_t startIndex = i == 0 ? 0 : spaceIndex_[i - 1] + 1; - ptr = text_.string().data() + startIndex; - len = (i == spaceIndex_.size() ? text_.size() : spaceIndex_[i]) - startIndex; -} - -inline -StringC TokenizedAttributeValue::token(size_t i) const -{ - const Char *ptr; - size_t len; - token(i, ptr, len); - return StringC(ptr, len); -} - -inline -Location TokenizedAttributeValue::tokenLocation(size_t i) const -{ - return text_.charLocation(i == 0 ? 0 : spaceIndex_[i - 1] + 1); -} - -inline -size_t Attribute::specIndex() const -{ - return specIndexPlus_ - 1; -} - -inline -Boolean Attribute::specified() const -{ - return specIndexPlus_ != 0; -} - -inline -const AttributeValue *Attribute::value() const -{ - return value_.pointer(); -} - -inline -const ConstPtr &Attribute::valuePointer() const -{ - return value_; -} - -inline -const AttributeSemantics *Attribute::semantics() const -{ - return semantics_.pointer(); -} - -inline -void Attribute::setSpec(size_t index) -{ - specIndexPlus_ = index + 1; -} - -inline -void Attribute::setValue(const ConstPtr &value) -{ - value_ = value; -} - -inline -void Attribute::setSemantics(AttributeSemantics *semantics) -{ - semantics_ = semantics; -} - -inline -size_t AttributeList::size() const -{ - return vec_.size(); -} - -inline -const AttributeDefinition *AttributeList::def(size_t i) const -{ - return def_->def(i); -} - -inline -Boolean AttributeList::tokenized(unsigned i) const -{ - return def(i)->tokenized(); -} - -inline -Boolean AttributeList::tokenIndex(const StringC &name, unsigned &index) const -{ - return !def_.isNull() && def_->tokenIndex(name, index); -} - -inline -Boolean AttributeList::attributeIndex(const StringC &name, unsigned &index) const -{ - return !def_.isNull() && def_->attributeIndex(name, index); -} - -inline -const StringC &AttributeList::name(unsigned i) const -{ - return def(i)->name(); -} - -inline -const Vector *AttributeList::getAllowedTokens(unsigned i) const -{ - return def(i)->getTokens(); -} - -inline -const AttributeValue *AttributeList::value(unsigned i) const -{ - return vec_[i].value(); -} - -inline -const ConstPtr &AttributeList::valuePointer(unsigned i) - const -{ - return vec_[i].valuePointer(); -} - -inline -const AttributeSemantics *AttributeList::semantics(unsigned i) const -{ - return vec_[i].semantics(); -} - -inline -size_t AttributeList::specIndex(size_t i) const -{ - return vec_[i].specIndex(); -} - -inline -size_t AttributeList::nSpec() const -{ - return nSpec_; -} - -inline -Boolean AttributeList::conref() const -{ - return conref_; -} - -inline -size_t AttributeList::defIndex() const -{ - return def_.isNull() ? size_t(-1) : def_->index(); -} - -inline -Boolean AttributeList::current(unsigned i) const -{ - return def(i)->isCurrent(); -} - -inline -Boolean AttributeList::anyCurrent() const -{ - return !def_.isNull() && def_->anyCurrent(); -} - -inline -const AttributeValue * -DefaultAttributeDefinition::defaultValue(const AttributeValue *) - const -{ - return value_.pointer(); -} - -inline -Boolean AttributeList::idIndex(unsigned &ind) const -{ - if (def_.isNull() || def_->idIndex() == size_t(-1)) - return 0; - else { - ind = def_->idIndex(); - return 1; - } -} - -inline -Boolean AttributeList::id(unsigned i) const -{ - return def(i)->isId(); -} - -inline -Boolean AttributeList::idref(unsigned i) const -{ - return def(i)->isIdref(); -} - -inline -Boolean AttributeList::specified(unsigned i) const -{ - return vec_[i].specified(); -} - -inline -Boolean AttributeContext::mayDefaultAttribute() const -{ - return mayDefaultAttribute_; -} - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* not Attribute_INCLUDED */ diff --git a/cde/programs/nsgmls/Attributed.h b/cde/programs/nsgmls/Attributed.h deleted file mode 100644 index d7dc2677f..000000000 --- a/cde/programs/nsgmls/Attributed.h +++ /dev/null @@ -1,80 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: Attributed.h /main/1 1996/07/29 16:46:44 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#ifndef Attributed_INCLUDED -#define Attributed_INCLUDED 1 - -#include "Ptr.h" -#include "Attribute.h" - -// This is used for things that have attribute definitions -// that notations and elements. - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -class SP_API Attributed { -public: - Attributed() { } - ConstPtr attributeDef() const; - const AttributeDefinitionList *attributeDefTemp() const; - Ptr attributeDef(); - void setAttributeDef(const Ptr &); -private: - Ptr attributeDef_; - -}; - -inline -ConstPtr Attributed::attributeDef() const -{ - return attributeDef_; -} - -inline -const AttributeDefinitionList *Attributed::attributeDefTemp() const -{ - return attributeDef_.pointer(); -} - -inline -Ptr Attributed::attributeDef() -{ - return attributeDef_; -} - -inline -void Attributed::setAttributeDef(const Ptr &def) -{ - attributeDef_ = def; -} - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* not Attributed_INCLUDED */ diff --git a/cde/programs/nsgmls/Boolean.h b/cde/programs/nsgmls/Boolean.h deleted file mode 100644 index aef210bff..000000000 --- a/cde/programs/nsgmls/Boolean.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: Boolean.h /main/1 1996/07/29 16:46:49 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#ifndef Boolean_INCLUDED -#define Boolean_INCLUDED 1 - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -#ifdef SP_HAVE_BOOL - -typedef bool Boolean; -typedef char PackedBoolean; - -#else /* not SP_HAVE_BOOL */ - -typedef int Boolean; -typedef char PackedBoolean; - -#endif /* not SP_HAVE_BOOL */ - -#ifdef SP_NAMESPACE -} -#endif - -#ifndef SP_HAVE_BOOL - -typedef int bool; - -const int true = 1; -const int false = 0; - -#endif /* not SP_HAVE_BOOL */ - -#endif /* not Boolean_INCLUDED */ diff --git a/cde/programs/nsgmls/COPYING b/cde/programs/nsgmls/COPYING deleted file mode 100644 index 02ca705ce..000000000 --- a/cde/programs/nsgmls/COPYING +++ /dev/null @@ -1,25 +0,0 @@ -Copyright (c) 1994, 1995, 1996 James Clark - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -``Software''), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be included -in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS -OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL JAMES CLARK BE LIABLE FOR ANY CLAIM, DAMAGES OR -OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, -ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of James Clark shall -not be used in advertising or otherwise to promote the sale, use or -other dealings in this Software without prior written authorization -from James Clark. diff --git a/cde/programs/nsgmls/CatalogEntry.h b/cde/programs/nsgmls/CatalogEntry.h deleted file mode 100644 index e985edc72..000000000 --- a/cde/programs/nsgmls/CatalogEntry.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: CatalogEntry.h /main/1 1996/07/29 16:46:56 cde-hp $ */ -// Copyright (c) 1994, 1995 James Clark -// See the file COPYING for copying permission. - -#ifndef CatalogEntry_INCLUDED -#define CatalogEntry_INCLUDED 1 - -#include "Location.h" -#include "StringC.h" -#include - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -struct CatalogEntry { - StringC to; - Location loc; - size_t catalogNumber; - size_t baseNumber; - size_t serial; -}; - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* not CatalogEntry_INCLUDED */ diff --git a/cde/programs/nsgmls/CatalogMessages.h b/cde/programs/nsgmls/CatalogMessages.h deleted file mode 100644 index a39e0091e..000000000 --- a/cde/programs/nsgmls/CatalogMessages.h +++ /dev/null @@ -1,203 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: CatalogMessages.h /main/1 1996/07/29 16:47:02 cde-hp $ */ -// This file was automatically generated from CatalogMessages.msg by msggen.pl. -#include "Message.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -struct CatalogMessages { - // 2100 - static const MessageType0 nameExpected; - // 2101 - static const MessageType0 literalExpected; - // 2102 - static const MessageType0 nameOrLiteralExpected; - // 2103 - static const MessageType0 nulChar; - // 2104 - static const MessageType0 minimumData; - // 2105 - static const MessageType0 eofInComment; - // 2106 - static const MessageType0 eofInLiteral; - // 2107 - static const MessageType0 overrideYesOrNo; - // 2108 - static const MessageType0 inLoop; - // 2109 - static const MessageType0 systemShouldQuote; - // 2110 - static const MessageType1 noDocumentEntry; - // 2111 - static const MessageType2 noPublicEntry; -}; -const MessageType0 CatalogMessages::nameExpected( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -2100 -#ifndef SP_NO_MESSAGE_TEXT -,"name expected" -#endif -); -const MessageType0 CatalogMessages::literalExpected( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -2101 -#ifndef SP_NO_MESSAGE_TEXT -,"literal expected" -#endif -); -const MessageType0 CatalogMessages::nameOrLiteralExpected( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -2102 -#ifndef SP_NO_MESSAGE_TEXT -,"name or literal expected" -#endif -); -const MessageType0 CatalogMessages::nulChar( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -2103 -#ifndef SP_NO_MESSAGE_TEXT -,"nul character" -#endif -); -const MessageType0 CatalogMessages::minimumData( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -2104 -#ifndef SP_NO_MESSAGE_TEXT -,"not a minimum data character" -#endif -); -const MessageType0 CatalogMessages::eofInComment( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -2105 -#ifndef SP_NO_MESSAGE_TEXT -,"end of entity in comment" -#endif -); -const MessageType0 CatalogMessages::eofInLiteral( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -2106 -#ifndef SP_NO_MESSAGE_TEXT -,"end of entity in literal" -#endif -); -const MessageType0 CatalogMessages::overrideYesOrNo( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -2107 -#ifndef SP_NO_MESSAGE_TEXT -,"OVERRIDE requires argument of YES or NO" -#endif -); -const MessageType0 CatalogMessages::inLoop( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -2108 -#ifndef SP_NO_MESSAGE_TEXT -,"CATALOG entries cause loop" -#endif -); -const MessageType0 CatalogMessages::systemShouldQuote( -MessageType::warning, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -2109 -#ifndef SP_NO_MESSAGE_TEXT -,"second argument for SYSTEM entry should be quoted to avoid ambiguity" -#endif -); -const MessageType1 CatalogMessages::noDocumentEntry( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -2110 -#ifndef SP_NO_MESSAGE_TEXT -,"no DOCUMENT entry in catalog %1" -#endif -); -const MessageType2 CatalogMessages::noPublicEntry( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -2111 -#ifndef SP_NO_MESSAGE_TEXT -,"no entry for public identifier %1 in catalog %2" -#endif -); -#ifdef SP_NAMESPACE -} -#endif diff --git a/cde/programs/nsgmls/CharsetDecl.C b/cde/programs/nsgmls/CharsetDecl.C deleted file mode 100644 index 6d8227cbb..000000000 --- a/cde/programs/nsgmls/CharsetDecl.C +++ /dev/null @@ -1,293 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: CharsetDecl.C /main/1 1996/07/29 16:47:07 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#ifdef __GNUG__ -#pragma implementation -#endif -#include "splib.h" -#include "CharsetDecl.h" -#include "macros.h" -#include "ISet.h" -#include "constant.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -CharsetDeclRange::CharsetDeclRange() -: descMin_(0), - count_(0), - type_(unused), - baseMin_(0) -{ -} - -CharsetDeclRange::CharsetDeclRange(WideChar descMin, Number count, - WideChar baseMin) -: descMin_(descMin), - count_(count), - type_(number), - baseMin_(baseMin) -{ -} - -CharsetDeclRange::CharsetDeclRange(WideChar descMin, Number count) -: descMin_(descMin), - count_(count), - type_(unused), - baseMin_(0) -{ -} - -CharsetDeclRange::CharsetDeclRange(WideChar descMin, Number count, - const StringC &str) -: descMin_(descMin), - count_(count), - type_(string), - str_(str), - baseMin_(0) -{ -} - -void CharsetDeclRange::rangeDeclared(WideChar min, Number count, - ISet &declared) const -{ - if (count > 0 && min + count > descMin_ && min < descMin_ + count_) { - WideChar commMin = (descMin_ > min) ? descMin_ : min; - WideChar commMax = min + ((min + count < descMin_ + count_ - ? count - : descMin_ + count_ - min) - 1); - ASSERT(commMin <= commMax); - declared.addRange(commMin, commMax); - } -} - -void CharsetDeclRange::usedSet(ISet &set) const -{ - if (type_ != unused && count_ > 0 && descMin_ <= charMax) { - Char max; - if (charMax - descMin_ < count_ - 1) - max = charMax; - else - max = Char(descMin_ + (count_ - 1)); - set.addRange(Char(descMin_), max); - } -} - -void CharsetDeclRange::stringToChar(const StringC &str, ISet &to) - const -{ - if (type_ == string && str_ == str && count_ > 0) - to.addRange(descMin_, descMin_ + (count_ - 1)); -} - -void CharsetDeclRange::numberToChar(Number n, ISet &to, - Number &count) - const -{ - if (type_ == number && n >= baseMin_ && n - baseMin_ < count_) { - Number thisCount = count_ - (n - baseMin_); - if (to.isEmpty() || thisCount < count) - count = thisCount; - to.add(descMin_ + (n - baseMin_)); - } -} - -Boolean CharsetDeclRange::getCharInfo(WideChar fromChar, - CharsetDeclRange::Type &type, - Number &n, - StringC &str, - Number &count) const -{ - if (fromChar >= descMin_ && fromChar - descMin_ < count_) { - type = type_; - if (type == number) - n = baseMin_ + (fromChar - descMin_); - else if (type == string) - str = str_; - count = count_ - (fromChar - descMin_); - return 1; - } - else - return 0; -} - -CharsetDeclSection::CharsetDeclSection() -{ -} - -void CharsetDeclSection::setPublicId(const PublicId &id) -{ - baseset_ = id; -} - -void CharsetDeclSection::addRange(const CharsetDeclRange &range) -{ - ranges_.push_back(range); -} - -void CharsetDeclSection::rangeDeclared(WideChar min, Number count, - ISet &declared) const -{ - for (size_t i = 0; i < ranges_.size(); i++) - ranges_[i].rangeDeclared(min, count, declared); -} - -void CharsetDeclSection::usedSet(ISet &set) const -{ - for (size_t i = 0; i < ranges_.size(); i++) - ranges_[i].usedSet(set); -} - -void CharsetDeclSection::stringToChar(const StringC &str, ISet &to) - const -{ - for (size_t i = 0; i < ranges_.size(); i++) - ranges_[i].stringToChar(str, to); -} - -void CharsetDeclSection::numberToChar(const PublicId *id, Number n, - ISet &to, Number &count) const -{ - PublicId::OwnerType ownerType; - StringC seq1, seq2; - if (id->string() == baseset_.string() - // Assume that 2 ISO character sets are the same if - // their designating sequences are the same. - || (id->getOwnerType(ownerType) - && ownerType == PublicId::ISO - && baseset_.getOwnerType(ownerType) - && ownerType == PublicId::ISO - && id->getDesignatingSequence(seq1) - && baseset_.getDesignatingSequence(seq2) - && seq1 == seq2)) { - for (size_t i = 0; i < ranges_.size(); i++) - ranges_[i].numberToChar(n, to, count); - } -} - -Boolean CharsetDeclSection::getCharInfo(WideChar fromChar, - const PublicId *&id, - CharsetDeclRange::Type &type, - Number &n, - StringC &str, - Number &count) const -{ - for (size_t i = 0; i < ranges_.size(); i++) - if (ranges_[i].getCharInfo(fromChar, type, n, str, count)) { - id = &baseset_; - return 1; - } - return 0; -} - -CharsetDecl::CharsetDecl() -{ -} - -void CharsetDecl::addSection(const PublicId &id) -{ - sections_.resize(sections_.size() + 1); - sections_.back().setPublicId(id); -} - -void CharsetDecl::swap(CharsetDecl &to) -{ - sections_.swap(to.sections_); - declaredSet_.swap(to.declaredSet_); -} - -void CharsetDecl::clear() -{ - sections_.clear(); -} - -void CharsetDecl::addRange(WideChar min, Number count, WideChar baseMin) -{ - if (count > 0) - declaredSet_.addRange(min, min + (count - 1)); - CharsetDeclRange range(min, count, baseMin); - sections_.back().addRange(range); -} - -void CharsetDecl::addRange(WideChar min, Number count) -{ - if (count > 0) - declaredSet_.addRange(min, min + (count - 1)); - CharsetDeclRange range(min, count); - sections_.back().addRange(range); -} - -void CharsetDecl::addRange(WideChar min, Number count, const StringC &str) -{ - if (count > 0) - declaredSet_.addRange(min, min + (count - 1)); - CharsetDeclRange range(min, count, str); - sections_.back().addRange(range); -} - -void CharsetDecl::rangeDeclared(WideChar min, Number count, - ISet &declared) const -{ - for (size_t i = 0; i < sections_.size(); i++) - sections_[i].rangeDeclared(min, count, declared); -} - -void CharsetDecl::usedSet(ISet &set) const -{ - for (size_t i = 0; i < sections_.size(); i++) - sections_[i].usedSet(set); -} - -Boolean CharsetDecl::getCharInfo(WideChar fromChar, - const PublicId *&id, - CharsetDeclRange::Type &type, - Number &n, - StringC &str, - Number &count) const -{ - for (size_t i = 0; i < sections_.size(); i++) - if (sections_[i].getCharInfo(fromChar, id, type, n, str, count)) - return 1; - return 0; -} - -void CharsetDecl::stringToChar(const StringC &str, ISet &to) const -{ - for (size_t i = 0; i < sections_.size(); i++) - sections_[i].stringToChar(str, to); -} - -void CharsetDecl::numberToChar(const PublicId *id, Number n, - ISet &to, Number &count) const -{ - for (size_t i = 0; i < sections_.size(); i++) - sections_[i].numberToChar(id, n, to, count); -} - -#ifdef SP_NAMESPACE -} -#endif diff --git a/cde/programs/nsgmls/CharsetDecl.h b/cde/programs/nsgmls/CharsetDecl.h deleted file mode 100644 index 6323a8a08..000000000 --- a/cde/programs/nsgmls/CharsetDecl.h +++ /dev/null @@ -1,163 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: CharsetDecl.h /main/1 1996/07/29 16:47:13 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#ifndef CharsetDecl_INCLUDED -#define CharsetDecl_INCLUDED 1 -#ifdef __GNUG__ -#pragma interface -#endif - -#include "types.h" -#include "Vector.h" -#include "ExternalId.h" -#include "ISet.h" -#include "Boolean.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -class SP_API CharsetDeclRange { -public: - enum Type { - number, - string, - unused - }; - CharsetDeclRange(); - CharsetDeclRange(WideChar, Number, WideChar); - CharsetDeclRange(WideChar, Number); - CharsetDeclRange(WideChar, Number, const StringC &); - void rangeDeclared(WideChar min, Number count, - ISet &declared) const; - void usedSet(ISet &) const; - Boolean getCharInfo(WideChar fromChar, - CharsetDeclRange::Type &type, - Number &n, - StringC &str, - Number &count) const; - void stringToChar(const StringC &str, ISet &to) const; - void numberToChar(Number n, ISet &to, Number &count) const; -private: - WideChar descMin_; - Number count_; - WideChar baseMin_; - Type type_; - StringC str_; -}; - -class SP_API CharsetDeclSection { -public: - CharsetDeclSection(); - void setPublicId(const PublicId &); - void addRange(const CharsetDeclRange &); - void rangeDeclared(WideChar min, Number count, - ISet &declared) const; - void usedSet(ISet &) const; - Boolean getCharInfo(WideChar fromChar, - const PublicId *&id, - CharsetDeclRange::Type &type, - Number &n, - StringC &str, - Number &cout) const; - void stringToChar(const StringC &str, ISet &to) const; - void numberToChar(const PublicId *id, Number n, - ISet &to, Number &count) const; -private: - PublicId baseset_; - Vector ranges_; -}; - -class SP_API CharsetDecl { -public: - CharsetDecl(); - void addSection(const PublicId &); - void swap(CharsetDecl &); - void clear(); - void usedSet(ISet &) const; - void declaredSet(ISet &set) const; - Boolean charDeclared(WideChar) const; - void rangeDeclared(WideChar min, Number count, - ISet &declared) const; - void addRange(WideChar, Number, WideChar); - void addRange(WideChar, Number); - void addRange(WideChar, Number, const StringC &); - Boolean getCharInfo(WideChar fromChar, - const PublicId *&id, - CharsetDeclRange::Type &type, - Number &n, - StringC &str) const; - Boolean getCharInfo(WideChar fromChar, - const PublicId *&id, - CharsetDeclRange::Type &type, - Number &n, - StringC &str, - Number &count) const; - void stringToChar(const StringC &str, ISet &to) const; - void numberToChar(const PublicId *id, Number n, - ISet &to, Number &count) const; - void numberToChar(const PublicId *id, Number n, ISet &to) const; -private: - Vector sections_; - ISet declaredSet_; -}; - -inline -Boolean CharsetDecl::getCharInfo(WideChar fromChar, - const PublicId *&id, - CharsetDeclRange::Type &type, - Number &n, - StringC &str) const -{ - Number tem; - return getCharInfo(fromChar, id, type, n, str, tem); -} - -inline -void CharsetDecl::numberToChar(const PublicId *id, Number n, - ISet &to) const -{ - Number tem; - numberToChar(id, n, to, tem); -} - -inline -void CharsetDecl::declaredSet(ISet &set) const -{ - set = declaredSet_; -} - -inline -Boolean CharsetDecl::charDeclared(WideChar c) const -{ - return declaredSet_.contains(c); -} - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* not CharsetDecl_INCLUDED */ diff --git a/cde/programs/nsgmls/CharsetInfo.C b/cde/programs/nsgmls/CharsetInfo.C deleted file mode 100644 index 747a4a22b..000000000 --- a/cde/programs/nsgmls/CharsetInfo.C +++ /dev/null @@ -1,156 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: CharsetInfo.C /main/1 1996/07/29 16:47:17 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#ifdef __GNUG__ -#pragma implementation -#endif -#include "splib.h" -#include "CharsetInfo.h" -#include "ISet.h" -#include "constant.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -CharsetInfo::CharsetInfo(const UnivCharsetDesc &desc) -: desc_(desc) -{ - // FIXME remove mappings from desc for characters greater charMax - init(); -} - -CharsetInfo::CharsetInfo() -{ - for (size_t i = 0; i < nSmall; i++) { - smallUnivValid_[i] = 0; - smallDescValid_[i] = 0; - } -} - -void CharsetInfo::set(const UnivCharsetDesc &desc) -{ - desc_ = desc; - init(); -} - -void CharsetInfo::init() -{ - size_t i; - for (i = 0; i < nSmall; i++) { - smallUnivValid_[i] = 0; - smallDescValid_[i] = 0; - } - - UnivCharsetDescIter iter(desc_); - - WideChar descMin, descMax; - UnivChar univMin; - while (iter.next(descMin, descMax, univMin)) { - WideChar j = descMin; - do { - UnivChar k = univMin + (j - descMin); - if (k >= nSmall) - break; - if (!smallUnivValid_[k]) { - smallUnivValid_[k] = 1; - smallUnivToDesc_[k] = j; - } - else - smallUnivValid_[k] = 2; - } while (j++ != descMax); - j = descMin; - do { - if (j >= nSmall) - break; - if (!smallDescValid_[j]) { - smallDescValid_[j] = 1; - smallDescToUniv_[j] = univMin + (j - descMin); - } - } while (j++ != descMax); - } - // These are the characters that the ANSI C - // standard guarantees will be in the basic execution - // character set. - static char execChars[] = - "\t\n\r " - "ABCDEFGHIJKLMNOPQRSTUVWXYZ" - "abcdefghijklmnopqrstuvwxyz" - "0123456789" - "!\"#%&'()*+,-./:" - ";<=>?[\\]^_{|}~"; - // These are the corresponding ISO 646 codes. - static char univCodes[] = { - 9, 10, 13, 32, - 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, - 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, - 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, - 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, - 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, - 33, 34, 35, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 58, - 59, 60, 61, 62, 63, 91, 92, 93, 94, 95, 123, 124, 125, 126, - }; - for (i = 0; execChars[i] != '\0'; i++) { - WideChar c; - ISet set; - if (univToDesc(univCodes[i], c, set) > 0 && c <= Char(-1)) - execToDesc_[(unsigned char)execChars[i]] = Char(c); - } -} - -void CharsetInfo::getDescSet(ISet &set) const -{ - UnivCharsetDescIter iter(desc_); - WideChar descMin, descMax; - UnivChar univMin; - while (iter.next(descMin, descMax, univMin)) { - if (descMin > charMax) - break; - if (descMax > charMax) - descMax = charMax; - set.addRange(Char(descMin), Char(descMax)); - } -} - -int CharsetInfo::digitWeight(Char c) const -{ - for (int i = 0; i < 10; i++) - if (c == execToDesc('0' + i)) - return i; - return -1; -} - -StringC CharsetInfo::execToDesc(const char *s) const -{ - StringC result; - while (*s != '\0') - result += execToDesc(*s++); - return result; -} - -#ifdef SP_NAMESPACE -} -#endif diff --git a/cde/programs/nsgmls/CharsetInfo.h b/cde/programs/nsgmls/CharsetInfo.h deleted file mode 100644 index fdad942f4..000000000 --- a/cde/programs/nsgmls/CharsetInfo.h +++ /dev/null @@ -1,142 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: CharsetInfo.h /main/1 1996/07/29 16:47:24 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#ifndef CharsetInfo_INCLUDED -#define CharsetInfo_INCLUDED 1 -#ifdef __GNUG__ -#pragma interface -#endif - -#include -#include "UnivCharsetDesc.h" -#include "Boolean.h" -#include "types.h" -#include "StringC.h" -#include "ISet.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -class SP_API CharsetInfo { -public: - CharsetInfo(); - CharsetInfo(const UnivCharsetDesc &); - void set(const UnivCharsetDesc &); - // Use only for characters guaranteed to me in the C basic execution - // character set and which have been verified to be in this - // character set. - Char execToDesc(char) const; - StringC execToDesc(const char *s) const; - Boolean descToUniv(WideChar from, UnivChar &to) const; - Boolean descToUniv(WideChar from, UnivChar &to, WideChar &alsoMax) const; - // Return 0 for no matches, 1 for 1, 2 for more than 1 - // to gets the first character; toSet gets all the characters - // if there's more than 1. - unsigned univToDesc(UnivChar from, WideChar &to, ISet &toSet) - const; - unsigned univToDesc(UnivChar from, WideChar &to, ISet &toSet, - WideChar &count) - const; - void getDescSet(ISet &) const; - int digitWeight(Char) const; - const UnivCharsetDesc &desc() const; -private: - void init(); - UnivCharsetDesc desc_; - enum { nSmall = 128 }; - // 0 for no matches, 1 for 1, 2 for more than 1 - unsigned smallUnivValid_[nSmall]; - WideChar smallUnivToDesc_[nSmall]; - PackedBoolean smallDescValid_[nSmall]; - UnivChar smallDescToUniv_[nSmall]; - Char execToDesc_[UCHAR_MAX + 1]; -}; - -inline -unsigned CharsetInfo::univToDesc(UnivChar from, WideChar &to, - ISet &toSet) - const -{ - if (from < nSmall && smallUnivValid_[from] <= 1) { - if (smallUnivValid_[from]) { - to = smallUnivToDesc_[from]; - return 1; - } - else - return 0; - } - else - return desc_.univToDesc(from, to, toSet); -} - -inline -Boolean CharsetInfo::descToUniv(UnivChar from, WideChar &to) const -{ - if (from < nSmall) { - if (smallDescValid_[from]) { - to = smallDescToUniv_[from]; - return 1; - } - else - return 0; - } - else - return desc_.descToUniv(from, to); -} - -inline -Char CharsetInfo::execToDesc(char c) const -{ - return execToDesc_[(unsigned char)c]; -} - -inline -Boolean CharsetInfo::descToUniv(WideChar from, UnivChar &to, - WideChar &alsoMax) const -{ - return desc_.descToUniv(from, to, alsoMax); -} - -inline -unsigned CharsetInfo::univToDesc(UnivChar from, WideChar &to, - ISet &toSet, WideChar &count) - const -{ - return desc_.univToDesc(from, to, toSet, count); -} - -inline -const UnivCharsetDesc &CharsetInfo::desc() const -{ - return desc_; -} - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* not CharsetInfo_INCLUDED */ diff --git a/cde/programs/nsgmls/CharsetRegistry.C b/cde/programs/nsgmls/CharsetRegistry.C deleted file mode 100644 index 3dc75c062..000000000 --- a/cde/programs/nsgmls/CharsetRegistry.C +++ /dev/null @@ -1,105 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: CharsetRegistry.C /main/1 1996/07/29 16:47:29 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#ifdef __GNUG__ -#pragma implementation -#endif -#include "splib.h" -#include "CharsetRegistry.h" -#include "ExternalId.h" -#include "CharsetInfo.h" -#include "UnivCharsetDesc.h" -#include "StringC.h" -#include "types.h" -#include "macros.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -static UnivCharsetDesc::Range iso646_irv[] = { - { 0, 128, 0 } -}; - -static UnivCharsetDesc::Range iso646_C0[] = { - { 0, 32, 0 }, - { 127, 1, 127 }, -}; - -static struct { - const char *sequence; - const UnivCharsetDesc::Range *ranges; - size_t nRanges; -} table[] = { - { "ESC 2/5 4/0", iso646_irv, SIZEOF(iso646_irv) }, - { "ESC 2/8 4/0", iso646_irv, SIZEOF(iso646_irv) }, - { "ESC 2/8 4/2", iso646_irv, SIZEOF(iso646_irv) }, // ASCII - { "ESC 2/1 4/0", iso646_C0, SIZEOF(iso646_C0) }, -}; - -Boolean CharsetRegistry::findCharset(const PublicId &id, - const CharsetInfo &charset, - UnivCharsetDesc &desc) -{ - PublicId::OwnerType ownerType; - if (!id.getOwnerType(ownerType) || ownerType != PublicId::ISO) - return 0; - StringC sequence; - if (!id.getDesignatingSequence(sequence)) - return 0; - // Canonicalize the escape sequence by mapping esc -> ESC, - // removing leading zeros from escape sequences, and removing - // initial spaces. - StringC s; - size_t i; - for (i = 0; i < sequence.size(); i++) { - Char c = sequence[i]; - if (c == charset.execToDesc('e')) - s += charset.execToDesc('E'); - else if (c == charset.execToDesc('s')) - s += charset.execToDesc('S'); - else if (c == charset.execToDesc('c')) - s += charset.execToDesc('C'); - else if (charset.digitWeight(c) >= 0 - && s.size() > 0 - && s[s.size() - 1] == charset.execToDesc('0') - && (s.size() == 1 - || charset.digitWeight(s[s.size() - 2]) >= 0)) - s[s.size() - 1] = c; - else if (c != charset.execToDesc(' ') || s.size() > 0) - s += c; - } - for (i = 0; i < SIZEOF(table); i++) - if (s == charset.execToDesc(table[i].sequence)) { - desc.set(table[i].ranges, table[i].nRanges); - return 1; - } - return 0; -} - -#ifdef SP_NAMESPACE -} -#endif diff --git a/cde/programs/nsgmls/CharsetRegistry.h b/cde/programs/nsgmls/CharsetRegistry.h deleted file mode 100644 index 97bd85452..000000000 --- a/cde/programs/nsgmls/CharsetRegistry.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: CharsetRegistry.h /main/1 1996/07/29 16:47:35 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#ifndef CharsetRegistry_INCLUDED -#define CharsetRegistry_INCLUDED 1 -#ifdef __GNUG__ -#pragma interface -#endif - -#include "Boolean.h" -#include "types.h" -#include "StringC.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -class PublicId; -class CharsetInfo; -class UnivCharsetDesc; - -class CharsetRegistry { -public: - static Boolean findCharset(const PublicId &, const CharsetInfo &, - UnivCharsetDesc &); -}; - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* not CharsetRegistry_INCLUDED */ diff --git a/cde/programs/nsgmls/CmdLineApp.C b/cde/programs/nsgmls/CmdLineApp.C deleted file mode 100644 index 3dd4310fe..000000000 --- a/cde/programs/nsgmls/CmdLineApp.C +++ /dev/null @@ -1,467 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: CmdLineApp.C /main/2 1996/08/12 12:36:14 mgreess $ */ -// Copyright (c) 1996 James Clark -// See the file COPYING for copying permission. - -// Need option registration method that allows derived class to change -// option names. - -#ifdef __GNUG__ -#pragma implementation -#endif - -#include "splib.h" -#include "CmdLineApp.h" -#include "CmdLineAppMessages.h" -#include "MessageArg.h" -#include "ErrnoMessageArg.h" -#include "Options.h" -#include "version.h" -#include "xnew.h" -#include "macros.h" -#include "sptchar.h" -#include "MessageTable.h" - -#ifdef SP_MULTI_BYTE -#include "UTF8CodingSystem.h" -#include "Fixed2CodingSystem.h" -#include "UnicodeCodingSystem.h" -#include "EUCJPCodingSystem.h" -#include "SJISCodingSystem.h" -#include "ISO8859InputCodingSystem.h" -#ifdef WIN32 -#include "Win32CodingSystem.h" -#endif -#endif /* SP_MULTI_BYTE */ -#include "IdentityCodingSystem.h" - -#include "ConsoleOutput.h" - -#if defined(__linux__) || defined(CSRG_BASED) || defined(sun) -#include -#include -using namespace std; -#else -#include -#include -#endif -#include -#include -#include -#include - -#ifdef SP_HAVE_LOCALE -#include -#endif -#ifdef SP_HAVE_SETMODE -#include -#include -#endif -#ifdef SP_HAVE_SETMODE -#define IOS_BINARY ios::binary -#else -#define IOS_BINARY 0 -#endif -#ifdef SP_WIDE_SYSTEM - -#include - -#else /* not SP_WIDE_SYSTEM */ - -#include -#ifdef SP_INCLUDE_UNISTD_H -#include -#endif -#ifdef SP_INCLUDE_IO_H -#include -#endif - -#endif /* not SP_WIDE_SYSTEM */ - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -#ifdef SP_MULTI_BYTE -static UTF8CodingSystem utf8CodingSystem; -static Fixed2CodingSystem fixed2CodingSystem; -static UnicodeCodingSystem unicodeCodingSystem; -static EUCJPCodingSystem eucjpCodingSystem; -static SJISCodingSystem sjisCodingSystem; -#ifdef WIN32 -static Win32CodingSystem ansiCodingSystem(Win32CodingSystem::codePageAnsi); -static Win32CodingSystem oemCodingSystem(Win32CodingSystem::codePageOEM); -static UnicodeCodingSystem maybeUnicodeCodingSystem(&ansiCodingSystem); -#endif -#endif /* SP_MULTI_BYTE */ -static IdentityCodingSystem identityCodingSystem; - -static struct { - const char *name; - const CodingSystem *cs; -} codingSystems[] = { -#ifdef SP_MULTI_BYTE - { "UTF-8", &utf8CodingSystem }, - { "FIXED-2", &fixed2CodingSystem }, - { "UNICODE", &unicodeCodingSystem }, - { "EUC-JP", &eucjpCodingSystem }, - { "SJIS", &sjisCodingSystem }, -#ifdef WIN32 - { "WINDOWS", &ansiCodingSystem }, - { "MS-DOS", &oemCodingSystem }, - { "WUNICODE", &maybeUnicodeCodingSystem }, -#endif -#endif /* SP_MULTI_BYTE */ - { "IS8859-1", &identityCodingSystem }, - { "IDENTITY", &identityCodingSystem }, -}; - -const CodingSystem *CmdLineApp::codingSystem_ = 0; - -static const SP_TCHAR *progName = 0; - -static const SP_TCHAR versionString[] = SP_VERSION; - -CmdLineApp::CmdLineApp() -: errorFile_(0), - outputCodingSystem_(0), - // Colon at beginning is Posix.2ism that says to return : rather than ? for - // missing option argument. - optstr_(SP_T(":"), 1), - MessageReporter(makeStdErr()) -{ - registerOption('b', SP_T("bctf")); - registerOption('f', SP_T("error_file")); - registerOption('v'); -} - -void CmdLineApp::registerOption(AppChar c, const AppChar *argName) -{ - optstr_ += c; - if (argName) { - optstr_ += SP_T(':'); - optArgNames_.push_back(argName); - } -} - -StringC CmdLineApp::usageString() -{ - String result; - size_t i; - - if (progName) - result.assign(progName, tcslen(progName)); - PackedBoolean hadOption[128]; - for (i = 0; i < 128; i++) - hadOption[i] = 0; - Boolean hadNoArgOption = 0; - for (i = 1; i < optstr_.size(); i++) { - if (optstr_[i] == 0) - break; - if (i + 1 < optstr_.size() && optstr_[i + 1] == ':') - i++; - else if (!hadOption[optstr_[i]]) { - hadOption[optstr_[i]] = 1; - if (!hadNoArgOption) { - hadNoArgOption = 1; - result.append(SP_T(" [-"), 3); - } - result += optstr_[i]; - } - } - if (hadNoArgOption) - result += SP_T(']'); - size_t j = 0; - for (i = 1; i < optstr_.size(); i++) { - if (i + 1 < optstr_.size() && optstr_[i + 1] == ':') { - if (!hadOption[optstr_[i]]) { - hadOption[optstr_[i]] = 1; - result += SP_T(' '); - result += SP_T('['); - result += SP_T('-'); - result += optstr_[i]; - result += SP_T(' '); - result.append(optArgNames_[j], tcslen(optArgNames_[j])); - result += SP_T(']'); - } - i++; - j++; - } - } - result.append(SP_T(" sysid..."), tcslen(SP_T(" sysid..."))); - result += 0; - return convertInput(result.data()); -} - -static -void ewrite(const AppChar *s) -{ -#ifdef SP_WIDE_SYSTEM - fputts(s, stderr); -#else - int n = (int)strlen(s); - while (n > 0) { - int nw = write(2, s, n); - if (nw < 0) - break; - n -= nw; - s += nw; - } -#endif -} - -static -#ifdef SP_FANCY_NEW_HANDLER -int outOfMemory(size_t) -#else -void outOfMemory() -#endif -{ - if (progName) { - ewrite(progName); - ewrite(SP_T(": ")); - } - ewrite(SP_T(": out of memory\n")); - exit(1); -#ifdef SP_FANCY_NEW_HANDLER - return 0; -#endif -} - -int CmdLineApp::init(int, AppChar **argv) -{ - set_new_handler(outOfMemory); -#ifdef SP_HAVE_LOCALE - setlocale(LC_ALL, ""); -#endif -#ifdef SP_HAVE_SETMODE - _setmode(1, _O_BINARY); - _setmode(2, _O_BINARY); -#endif - progName = argv[0]; - if (progName) - setProgramName(convertInput(progName)); -#ifdef __GNUG__ - // cout is a performance disaster in libg++ unless we do this. - ios::sync_with_stdio(0); -#endif - return 0; -} - -int CmdLineApp::run(int argc, AppChar **argv) -{ - int ret = init(argc, argv); - if (ret) - return ret; - int firstArg; - ret = processOptions(argc, argv, firstArg); - if (ret) - return ret; - ret = processArguments(argc - firstArg, argv + firstArg); - progName = 0; - return ret; -} - -Boolean CmdLineApp::openFilebufWrite(filebuf &file, - const AppChar *filename) -{ -#ifdef SP_WIDE_SYSTEM - int fd = _wopen(filename, _O_CREAT|_O_WRONLY|_O_TRUNC|_O_BINARY); - if (fd < 0) - return 0; - return file.attach(fd) != 0; -#else -#if defined(__linux__) || defined(CSRG_BASED) || defined(sun) - return file.open(filename, ios::out|ios::trunc) != 0; -#else - return file.open(filename, ios::out|ios::trunc|IOS_BINARY) != 0; - #endif -#endif -} - -int CmdLineApp::processOptions(int argc, AppChar **argv, int &nextArg) -{ - AppChar ostr[2]; - optstr_ += SP_T('\0'); - Options options(argc, argv, optstr_.data()); - AppChar opt; - while (options.get(opt)) { - switch (opt) { - case ':': - ostr[0] = options.opt(); - ostr[1] = SP_T('\0'); - message(CmdLineAppMessages::missingOptionArgError, - StringMessageArg(convertInput(ostr))); - message(CmdLineAppMessages::usage, - StringMessageArg(usageString())); - return 1; - case '?': - ostr[0] = options.opt(); - ostr[1] = SP_T('\0'); - message(CmdLineAppMessages::invalidOptionError, - StringMessageArg(convertInput(ostr))); - message(CmdLineAppMessages::usage, - StringMessageArg(usageString())); - return 1; - default: - processOption(opt, options.arg()); - break; - } - } - nextArg = options.ind(); - if (errorFile_) { - static filebuf file; - if (!openFilebufWrite(file, errorFile_)) { - message(CmdLineAppMessages::cannotOpenOutputError, - StringMessageArg(convertInput(errorFile_)), - ErrnoMessageArg(errno)); - return 1; - } - setMessageStream(new IosOutputCharStream(&file, codingSystem())); - } - if (!outputCodingSystem_) - outputCodingSystem_ = codingSystem(); - return 0; -} - -void CmdLineApp::processOption(AppChar opt, const AppChar *arg) -{ - switch (opt) { - case 'b': - outputCodingSystem_ = lookupCodingSystem(arg); - if (!outputCodingSystem_) - message(CmdLineAppMessages::unknownBctf, - StringMessageArg(convertInput(arg))); - break; - case 'f': - errorFile_ = arg; - break; - case 'v': - // print the version number - message(CmdLineAppMessages::versionInfo, - StringMessageArg(convertInput(versionString))); - break; - default: - CANNOT_HAPPEN(); - } -} - -Boolean CmdLineApp::getMessageText(const MessageFragment &frag, - StringC &text) -{ - String str; - if (!MessageTable::instance()->getText(frag, str)) - return 0; -#ifdef SP_WIDE_SYSTEM - text.assign((const Char *)str.data(), str.size()); -#else - str += 0; - text = codingSystem()->convertIn(str.data()); -#endif - return 1; -} - -const CodingSystem *CmdLineApp::codingSystem() -{ - if (!codingSystem_) { - const SP_TCHAR *codingName = tgetenv(SP_T("SP_BCTF")); - if (codingName) - codingSystem_ = lookupCodingSystem(codingName); - if (!codingSystem_ -#ifndef SP_WIDE_SYSTEM - || codingSystem_->fixedBytesPerChar() > 1 -#endif - ) - codingSystem_ = &identityCodingSystem; - } - return codingSystem_; -} - -const CodingSystem * -CmdLineApp::lookupCodingSystem(const SP_TCHAR *codingName) -{ -#define MAX_CS_NAME 50 - if (tcslen(codingName) < MAX_CS_NAME) { - char buf[MAX_CS_NAME]; - int i; - for (i = 0; codingName[i] != SP_T('\0'); i++) { - SP_TUCHAR c = totupper((SP_TUCHAR)(codingName[i])); -#ifdef SP_WIDE_SYSTEM - if (c > (unsigned char)-1) - return 0; -#endif - buf[i] = char(c); - } - buf[i] = SP_T('\0'); - { - for (size_t i = 0; i < SIZEOF(codingSystems); i++) - if (strcmp(buf, codingSystems[i].name) == 0) - return codingSystems[i].cs; - } - } - return 0; -} - -const CodingSystem * -CmdLineApp::codingSystem(size_t i, const char *&name) -{ - if (i < SIZEOF(codingSystems)) { - name = codingSystems[i].name; - return codingSystems[i].cs; - } - return 0; -} - -StringC CmdLineApp::convertInput(const SP_TCHAR *s) -{ -#ifdef SP_WIDE_SYSTEM - StringC str(s, wcslen(s)); -#else - StringC str(codingSystem()->convertIn(s)); -#endif - for (size_t i = 0; i < str.size(); i++) - if (str[i] == '\n') - str[i] = '\r'; - return str; -} - -OutputCharStream *CmdLineApp::makeStdErr() -{ - OutputCharStream *os = ConsoleOutput::makeOutputCharStream(2); - if (os) - return os; - return new IosOutputCharStream(cerr.rdbuf(), codingSystem()); -} - -OutputCharStream *CmdLineApp::makeStdOut() -{ - OutputCharStream *os = ConsoleOutput::makeOutputCharStream(1); - if (os) - return os; - return new IosOutputCharStream(cout.rdbuf(), outputCodingSystem_); -} - -#ifdef SP_NAMESPACE -} -#endif diff --git a/cde/programs/nsgmls/CmdLineApp.h b/cde/programs/nsgmls/CmdLineApp.h deleted file mode 100644 index 3a5850176..000000000 --- a/cde/programs/nsgmls/CmdLineApp.h +++ /dev/null @@ -1,102 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: CmdLineApp.h /main/1 1996/07/29 16:47:46 cde-hp $ */ -// Copyright (c) 1996 James Clark -// See the file COPYING for copying permission. - -#ifndef CmdLineApp_INCLUDED -#define CmdLineApp_INCLUDED 1 - -#ifdef __GNUG__ -#pragma interface -#endif - -#include "MessageReporter.h" -#include "Vector.h" -#include "StringOf.h" -#include "Boolean.h" -#include "CodingSystem.h" -#include "OutputCharStream.h" - -#ifdef SP_WIDE_SYSTEM -// for wchar_t -#include -#endif - -#if defined(__linux__) || defined(CSRG_BASED) || defined(sun) -#include -using namespace std; -#else -class filebuf; -#endif - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -class SP_API CmdLineApp : public MessageReporter { -public: -#ifdef SP_WIDE_SYSTEM -#define AppChar wchar_t -#else -#define AppChar char -#endif - CmdLineApp(); - int run(int argc, AppChar **argv); - virtual int processOptions(int argc, AppChar **argv, int &nextArg); - virtual void processOption(AppChar opt, const AppChar *arg); - virtual int processArguments(int argc, AppChar **files) = 0; - static Boolean openFilebufWrite(filebuf &file, const AppChar *filename); - StringC usageString(); - static const CodingSystem *codingSystem(); - static const CodingSystem *lookupCodingSystem(const AppChar *); - static const CodingSystem *codingSystem(size_t, const char *&); - static StringC convertInput(const AppChar *s); - OutputCharStream *makeStdOut(); - static OutputCharStream *makeStdErr(); -protected: - virtual void registerOption(AppChar c, const AppChar *argName = 0); - virtual int init(int argc, AppChar **argv); - const AppChar *errorFile_; - const CodingSystem *outputCodingSystem_; - String optstr_; - Vector optArgNames_; -private: - Boolean getMessageText(const MessageFragment &, StringC &); - static const CodingSystem *codingSystem_; -}; - -#ifdef SP_WIDE_SYSTEM -#define SP_DEFINE_APP(CLASS) \ - extern "C" \ - wmain(int argc, wchar_t **argv) { CLASS app; return app.run(argc, argv); } -#else -#define SP_DEFINE_APP(CLASS) \ - int main(int argc, char **argv) { CLASS app; return app.run(argc, argv); } -#endif - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* not CmdLineApp_INCLUDED */ diff --git a/cde/programs/nsgmls/CmdLineAppMessages.h b/cde/programs/nsgmls/CmdLineAppMessages.h deleted file mode 100644 index d5430b885..000000000 --- a/cde/programs/nsgmls/CmdLineAppMessages.h +++ /dev/null @@ -1,119 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: CmdLineAppMessages.h /main/1 1996/07/29 16:47:51 cde-hp $ */ -// This file was automatically generated from CmdLineAppMessages.msg by msggen.pl. -#include "Message.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -struct CmdLineAppMessages { - // 4000 - static const MessageType1 invalidOptionError; - // 4001 - static const MessageType1 missingOptionArgError; - // 4002 - static const MessageType1 usage; - // 4003 - static const MessageType1 versionInfo; - // 4004 - static const MessageType1 unknownBctf; - // 4005 - static const MessageType2 cannotOpenOutputError; -}; -const MessageType1 CmdLineAppMessages::invalidOptionError( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -4000 -#ifndef SP_NO_MESSAGE_TEXT -,"invalid option %1" -#endif -); -const MessageType1 CmdLineAppMessages::missingOptionArgError( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -4001 -#ifndef SP_NO_MESSAGE_TEXT -,"missing argument for option %1" -#endif -); -const MessageType1 CmdLineAppMessages::usage( -MessageType::info, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -4002 -#ifndef SP_NO_MESSAGE_TEXT -,"usage is %1" -#endif -); -const MessageType1 CmdLineAppMessages::versionInfo( -MessageType::info, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -4003 -#ifndef SP_NO_MESSAGE_TEXT -,"version %1" -#endif -); -const MessageType1 CmdLineAppMessages::unknownBctf( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -4004 -#ifndef SP_NO_MESSAGE_TEXT -,"unknown BCTF %1" -#endif -); -const MessageType2 CmdLineAppMessages::cannotOpenOutputError( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -4005 -#ifndef SP_NO_MESSAGE_TEXT -,"cannot open output file %1 (%2)" -#endif -); -#ifdef SP_NAMESPACE -} -#endif diff --git a/cde/programs/nsgmls/CodingSystem.C b/cde/programs/nsgmls/CodingSystem.C deleted file mode 100644 index b29916439..000000000 --- a/cde/programs/nsgmls/CodingSystem.C +++ /dev/null @@ -1,135 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: CodingSystem.C /main/2 1996/08/08 12:10:51 mgreess $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#ifdef __GNUG__ -#pragma implementation -#endif - -#include "splib.h" -#include "CodingSystem.h" -#ifdef SP_SHORT_HEADERS -#include -#else -#if defined(__linux__) || defined(CSRG_BASED) || defined(sun) -#include -#else -#include -#endif -#endif -#include -#include - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -InputCodingSystem::~InputCodingSystem() -{ -} - -StringC InputCodingSystem::convertIn(const char *s) const -{ - Decoder *decoder = makeDecoder(); - StringC str; - str.resize(strlen(s)); - str.resize(decoder->decode(&str[0], s, strlen(s), &s)); - delete decoder; - return str; -} - -Boolean InputCodingSystem::isIdentity() const -{ - return 0; -} - -OutputCodingSystem::~OutputCodingSystem() -{ -} - -unsigned OutputCodingSystem::fixedBytesPerChar() const -{ - return 0; -} - -String OutputCodingSystem::convertOut(const StringC &str) const -{ - Encoder *encoder = makeEncoder(); - strstreambuf stream(MAXPATHLEN); - StringC copy(str); - encoder->output(copy.data(), copy.size(), &stream); - delete encoder; - char *s = stream.str(); -#if defined(__linux__) || defined(CSRG_BASED) || defined(sun) - String result(s, stream.pcount()); -#else - String result(s, stream.out_waiting()); -#endif - result += '\0'; - stream.freeze(0); -#ifdef __lucid - // Workaround lcc bug (3.1p2 with -O -XF). - String temp(result); - return temp; -#else - return result; -#endif -} - -Decoder::Decoder(unsigned minBytesPerChar) -: minBytesPerChar_(minBytesPerChar) -{ -} - -Decoder::~Decoder() -{ -} - -Boolean Decoder::convertOffset(unsigned long &) const -{ - return false; -} - -Encoder::Encoder() -: unencodableHandler_(0) -{ -} - -Encoder::~Encoder() -{ -} - -void Encoder::output(Char *s, size_t n, streambuf *sp) -{ - output((const Char *)s, n, sp); -} - -void Encoder::startFile(streambuf *) -{ -} - -#ifdef SP_NAMESPACE -} -#endif diff --git a/cde/programs/nsgmls/CodingSystem.h b/cde/programs/nsgmls/CodingSystem.h deleted file mode 100644 index 5aaf35ef4..000000000 --- a/cde/programs/nsgmls/CodingSystem.h +++ /dev/null @@ -1,130 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: CodingSystem.h /main/1 1996/07/29 16:48:04 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#ifndef CodingSystem_INCLUDED -#define CodingSystem_INCLUDED 1 - -#ifdef __GNUG__ -#pragma interface -#endif - -#ifndef SP_API -#define SP_API -#endif - -#include "types.h" -#include "Boolean.h" -#include "StringC.h" - -#include - -#if defined(__linux__) || defined(CSRG_BASED) || defined(sun) -#include -using namespace std; -#else -class streambuf; -#endif - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -class SP_API Decoder { -public: - Decoder(unsigned minBytesPerChar = 1); - virtual ~Decoder(); - virtual size_t decode(Char *, const char *, size_t, const char **) = 0; - virtual Boolean convertOffset(unsigned long &offset) const; - // Decoder assumes that for every decoded Char there must be at least - // minBytesPerChar bytes - unsigned minBytesPerChar() const; -protected: - unsigned minBytesPerChar_; -}; - - -class SP_API Encoder { -public: - class SP_API Handler { - public: - virtual void handleUnencodable(Char, streambuf *) = 0; - }; - Encoder(); - virtual ~Encoder(); - virtual void output(const Char *, size_t, streambuf *) = 0; - // This outputs a byte order mark with Unicode. - virtual void startFile(streambuf *); - virtual void output(Char *, size_t, streambuf *); - void setUnencodableHandler(Handler *); -protected: - void handleUnencodable(Char, streambuf *); -private: - Handler *unencodableHandler_; -}; - -class SP_API InputCodingSystem { -public: - virtual ~InputCodingSystem(); - virtual Decoder *makeDecoder() const = 0; - StringC convertIn(const char *) const; - virtual Boolean isIdentity() const; -}; - -class SP_API OutputCodingSystem { -public: - virtual ~OutputCodingSystem(); - virtual Encoder *makeEncoder() const = 0; - virtual unsigned fixedBytesPerChar() const; - String convertOut(const StringC &) const; -}; - -class SP_API CodingSystem : public InputCodingSystem, public OutputCodingSystem { -}; - -inline -unsigned Decoder::minBytesPerChar() const -{ - return minBytesPerChar_; -} - -inline -void Encoder::handleUnencodable(Char c, streambuf *sbufp) -{ - if (unencodableHandler_) - unencodableHandler_->handleUnencodable(c, sbufp); -} - -inline -void Encoder::setUnencodableHandler(Handler *handler) -{ - unencodableHandler_ = handler; -} - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* not CodingSystem_INCLUDED */ diff --git a/cde/programs/nsgmls/ConsoleOutput.C b/cde/programs/nsgmls/ConsoleOutput.C deleted file mode 100644 index 31b8bd3fd..000000000 --- a/cde/programs/nsgmls/ConsoleOutput.C +++ /dev/null @@ -1,91 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: ConsoleOutput.C /main/1 1996/07/29 16:48:10 cde-hp $ */ -// Copyright (c) 1996 James Clark -// See the file COPYING for copying permission. - -#ifdef __GNUG__ -#pragma implementation -#endif - -#include "splib.h" -#include "ConsoleOutput.h" - -#ifdef SP_WIDE_SYSTEM -#include -#include -#endif - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -#ifdef SP_WIDE_SYSTEM - -class ConsoleOutputCharStream : public OutputCharStream { -public: - ConsoleOutputCharStream(HANDLE h); - void flush(); - void flushBuf(Char); -private: - HANDLE h_; -}; - -OutputCharStream *ConsoleOutput::makeOutputCharStream(int fd) -{ - HANDLE h = (HANDLE)_get_osfhandle(fd); - DWORD flags; - if (GetConsoleMode(h, &flags)) - return new ConsoleOutputCharStream(h); - else - return 0; -} - -ConsoleOutputCharStream::ConsoleOutputCharStream(HANDLE h) -: h_(h) -{ -} - -void ConsoleOutputCharStream::flush() -{ -} - -void ConsoleOutputCharStream::flushBuf(Char c) -{ - DWORD nWritten; - unsigned short ch = c; - WriteConsoleW(h_, &ch, 1, &nWritten, 0); -} - -#else /* not SP_WIDE_SYSTEM */ - -OutputCharStream *ConsoleOutput::makeOutputCharStream(int) -{ - return 0; -} - -#endif /* not SP_WIDE_SYSTEM */ - -#ifdef SP_NAMESPACE -} -#endif diff --git a/cde/programs/nsgmls/ConsoleOutput.h b/cde/programs/nsgmls/ConsoleOutput.h deleted file mode 100644 index 59aec934b..000000000 --- a/cde/programs/nsgmls/ConsoleOutput.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: ConsoleOutput.h /main/1 1996/07/29 16:48:15 cde-hp $ */ -// Copyright (c) 1996 James Clark -// See the file COPYING for copying permission. - -#ifndef ConsoleOutput_INCLUDED -#define ConsoleOutput_INCLUDED 1 - -#ifdef __GNUG__ -#pragma interface -#endif - -#include "OutputCharStream.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -class SP_API ConsoleOutput { -public: - // Returns null if fd is not a console. - static OutputCharStream *makeOutputCharStream(int fd); -}; - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* not ConsoleOutput_INCLUDED */ diff --git a/cde/programs/nsgmls/ContentState.C b/cde/programs/nsgmls/ContentState.C deleted file mode 100644 index 689fe94b2..000000000 --- a/cde/programs/nsgmls/ContentState.C +++ /dev/null @@ -1,196 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: ContentState.C /main/1 1996/07/29 16:48:21 cde-hp $ */ -// Copyright (c) 1994, 1996 James Clark -// See the file COPYING for copying permission. - -#ifdef __GNUG__ -#pragma implementation -#endif - -#include "splib.h" -#include "ContentState.h" -#include "IListIter.h" -#include "NCVector.h" -#include "macros.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -const ShortReferenceMap ContentState::theEmptyMap; - -#ifdef __GNUG__ -typedef IListIter Dummy_IListIter_OpenElement; -#endif - -ContentState::ContentState() -: documentElementContainer_(StringC(), size_t(-1)), -totalExcludeCount_(0), -tagLevel_(0), -netEnablingCount_(0), -lastEndedElementType_(NULL) -{ -} - -void ContentState::startContent(const Dtd &dtd) -{ - NCVector > tokens(1); - tokens[0] = new ElementToken(dtd.documentElementType(), - ContentToken::none); - Owner model(new SeqModelGroup(tokens, ContentToken::none)); - Owner compiledModel(new CompiledModelGroup(model)); - Vector ambiguities; - Boolean pcdataUnreachable; - compiledModel->compile(dtd.nElementTypeIndex(), ambiguities, - pcdataUnreachable); - ASSERT(ambiguities.size() == 0); - ConstPtr def - = new ElementDefinition(Location(), - 0, - 0, - ElementDefinition::modelGroup, - compiledModel); - documentElementContainer_.setElementDefinition(def, 0); - tagLevel_ = 0; - while (!openElements_.empty()) - delete openElements_.get(); - openElements_.insert(new OpenElement(&documentElementContainer_, - 0, - 0, - &theEmptyMap, - Location())); - includeCount_.assign(dtd.nElementTypeIndex(), 0); - excludeCount_.assign(dtd.nElementTypeIndex(), 0); - openElementCount_.assign(dtd.nElementTypeIndex(), 0); - netEnablingCount_ = 0; - totalExcludeCount_ = 0; - lastEndedElementType_ = 0; - undefinedElementTypeTable_.clear(); -} - -void ContentState::pushElement(OpenElement *e) -{ - tagLevel_++; - openElementCount_[e->type()->index()]++; - const ElementDefinition *def = e->type()->definition(); - if (def) { - size_t i; - for (i = 0; i < def->nInclusions(); i++) - includeCount_[def->inclusion(i)->index()]++; - for (i = 0; i < def->nExclusions(); i++) { - excludeCount_[def->exclusion(i)->index()]++; - totalExcludeCount_++; - } - } - if (e->netEnabling()) - netEnablingCount_++; - openElements_.insert(e); -} - -OpenElement *ContentState::popSaveElement() -{ - ASSERT(tagLevel_ > 0); - OpenElement *e = openElements_.get(); - tagLevel_--; - openElementCount_[e->type()->index()]--; - const ElementDefinition *def = e->type()->definition(); - if (def) { - size_t i; - for (i = 0; i < def->nInclusions(); i++) - includeCount_[def->inclusion(i)->index()]--; - for (i = 0; i < def->nExclusions(); i++) { - excludeCount_[def->exclusion(i)->index()]--; - totalExcludeCount_--; - } - } - if (e->netEnabling()) - netEnablingCount_--; - lastEndedElementType_ = e->type(); - return e; -} - -void ContentState::popElement() -{ - delete popSaveElement(); -} - -Boolean ContentState::checkImplyLoop(unsigned count) -{ - for (IListIter iter(openElements_); - count > 0; - iter.next(), count--) - if (iter.cur()->type() == openElements_.head()->type() - // I'm not sure whether this is necessary. - && iter.cur()->matchState() == openElements_.head()->matchState()) - return 0; - return 1; -} - -void ContentState::getOpenElementInfo(Vector &v, - const StringC &rniPcdata) const -{ - v.clear(); - v.resize(tagLevel_); - unsigned i = tagLevel_; - for (IListIter iter(openElements_); - !iter.done() && i > 0; - iter.next()) { - OpenElementInfo &e = v[--i]; - e.gi = iter.cur()->type()->name(); - const LeafContentToken *token = iter.cur()->currentPosition(); - if (token && !token->isInitial()) { - e.matchIndex = token->typeIndex() + 1; - const ElementType *type = token->elementType(); - e.matchType = type ? type->name() : rniPcdata; - } - e.included = iter.cur()->included(); - } -} - -const ElementType * -ContentState::lookupCreateUndefinedElement(const StringC &name, - const Location &loc) -{ - const ElementType *e = undefinedElementTypeTable_.lookup(name); - if (e) - return e; - ElementType *p = new ElementType(name, - openElementCount_.size()); - p->setElementDefinition(new ElementDefinition(loc, - ElementDefinition::undefinedIndex, - (ElementDefinition::omitStart - |ElementDefinition::omitEnd), - ElementDefinition::any), - 0); - undefinedElementTypeTable_.insert(p); - includeCount_.push_back(0); - excludeCount_.push_back(0); - openElementCount_.push_back(0); - return p; -} - - -#ifdef SP_NAMESPACE -} -#endif diff --git a/cde/programs/nsgmls/ContentState.h b/cde/programs/nsgmls/ContentState.h deleted file mode 100644 index c5ed22c39..000000000 --- a/cde/programs/nsgmls/ContentState.h +++ /dev/null @@ -1,140 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: ContentState.h /main/1 1996/07/29 16:48:27 cde-hp $ */ -// Copyright (c) 1994, 1996 James Clark -// See the file COPYING for copying permission. - -#ifndef ContentState_INCLUDED -#define ContentState_INCLUDED 1 - -#ifdef __GNUG__ -#pragma interface -#endif - -#include -#include "OpenElement.h" -#include "IList.h" -#include "Vector.h" -#include "Message.h" -#include "Dtd.h" -#include "Mode.h" -#include "Boolean.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -class SP_API ContentState { -public: - ContentState(); - void startContent(const Dtd &); - void pushElement(OpenElement *); - OpenElement *popSaveElement(); - void popElement(); - OpenElement ¤tElement(); - const OpenElement ¤tElement() const; - void getOpenElementInfo(Vector &, - const StringC &rniPcdata) const; - unsigned tagLevel() const; - Boolean elementIsIncluded(const ElementType *) const; - Boolean elementIsExcluded(const ElementType *) const; - Boolean elementIsOpen(const ElementType *) const; - Boolean afterDocumentElement() const; - const ElementType *lastEndedElementType() const; - Mode contentMode() const; - const ElementType *lookupCreateUndefinedElement(const StringC &, - const Location &); - Boolean checkImplyLoop(unsigned); - static const ShortReferenceMap theEmptyMap; -private: - IList openElements_; - Vector openElementCount_; - Vector includeCount_; - Vector excludeCount_; - unsigned totalExcludeCount_; - unsigned tagLevel_; - unsigned netEnablingCount_; - const ElementType *lastEndedElementType_; - NamedTable undefinedElementTypeTable_; - ElementType documentElementContainer_; -}; - -inline -OpenElement &ContentState::currentElement() -{ - return *openElements_.head(); -} - -inline -const OpenElement &ContentState::currentElement() const -{ - return *openElements_.head(); -} - -inline -Boolean ContentState::elementIsOpen(const ElementType *e) const -{ - return openElementCount_[e->index()] != 0; -} - -inline -Boolean ContentState::elementIsIncluded(const ElementType *e) const -{ - return includeCount_[e->index()] != 0 && excludeCount_[e->index()] == 0; -} - -inline -Boolean ContentState::elementIsExcluded(const ElementType *e) const -{ - return excludeCount_[e->index()] != 0; -} - -inline -const ElementType *ContentState::lastEndedElementType() const -{ - return lastEndedElementType_; -} - -inline -unsigned ContentState::tagLevel() const -{ - return tagLevel_; -} - -inline -Boolean ContentState::afterDocumentElement() const -{ - return tagLevel() == 0 && currentElement().isFinished(); -} - -inline -Mode ContentState::contentMode() const -{ - return openElements_.head()->mode(netEnablingCount_ > 0); -} - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* not ContentState_INCLUDED */ diff --git a/cde/programs/nsgmls/ContentToken.C b/cde/programs/nsgmls/ContentToken.C deleted file mode 100644 index 066171814..000000000 --- a/cde/programs/nsgmls/ContentToken.C +++ /dev/null @@ -1,815 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: ContentToken.C /main/2 1996/08/13 13:59:08 drk $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#ifdef __GNUG__ -#pragma implementation -#endif -#include "splib.h" -#include -#include "ContentToken.h" -#include "macros.h" -#include "ElementType.h" -#include "Vector.h" -#include "Dtd.h" -#include "MessageArg.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -AndModelGroup::AndModelGroup(NCVector > &v, - ContentToken::OccurrenceIndicator oi) -: ModelGroup(v, oi), andDepth_(0), andIndex_(0), andGroupIndex_(0), - andAncestor_(NULL) -{ -} - -ModelGroup::Connector AndModelGroup::connector() const -{ - return andConnector; -} - -OrModelGroup::OrModelGroup(NCVector > &v, - ContentToken::OccurrenceIndicator oi) -: ModelGroup(v, oi) -{ - setOrGroup(); -} - -ModelGroup::Connector OrModelGroup::connector() const -{ - return orConnector; -} - - -SeqModelGroup::SeqModelGroup(NCVector > &v, - ContentToken::OccurrenceIndicator oi) -: ModelGroup(v, oi) -{ -} - -ModelGroup::Connector SeqModelGroup::connector() const -{ - return seqConnector; -} - - -ModelGroup::ModelGroup(NCVector > &v, - OccurrenceIndicator oi) -: ContentToken(oi) -{ - members_.swap(v); -} - -unsigned long ModelGroup::grpgtcnt() const -{ - unsigned long cnt = 1; - for (size_t i = 0; i < members_.size(); i++) - cnt += members_[i]->grpgtcnt(); - return cnt; -} - -void ModelGroup::setOrGroup() -{ - for (size_t i = 0; i < members_.size(); i++) - members_[i]->setOrGroupMember(); -} - -const ModelGroup *ModelGroup::asModelGroup() const -{ - return this; -} - -ElementToken::ElementToken(const ElementType *element, OccurrenceIndicator oi) -: LeafContentToken(element, oi) -{ -} - -ContentToken::ContentToken(OccurrenceIndicator oi) -: occurrenceIndicator_(oi), -inherentlyOptional_(0) -{ -} - -unsigned long ContentToken::grpgtcnt() const -{ - return 1; -} - -void ContentToken::setOrGroupMember() -{ -} - -const ModelGroup *ContentToken::asModelGroup() const -{ - return 0; -} - -const LeafContentToken *ContentToken::asLeafContentToken() const -{ - return 0; -} - -LeafContentToken::LeafContentToken(const ElementType *element, - OccurrenceIndicator oi) -: element_(element), ContentToken(oi), isFinal_(0), orGroupMember_(0), - requiredIndex_(size_t(-1)), leafIndex_(0), typeIndex_(0), pcdataTransitionType_(0), - simplePcdataTransition_(NULL) -{ -} - -Boolean LeafContentToken::isInitial() const -{ - return 0; -} - -void LeafContentToken::setOrGroupMember() -{ - orGroupMember_ = 1; -} - -const LeafContentToken *LeafContentToken::asLeafContentToken() const -{ - return this; -} - -PcdataToken::PcdataToken() -: LeafContentToken(0, rep) -{ -} - -InitialPseudoToken::InitialPseudoToken() -: LeafContentToken(0, none) -{ -} - -Boolean InitialPseudoToken::isInitial() const -{ - return 1; -} - -DataTagGroup::DataTagGroup(NCVector > &vec, - OccurrenceIndicator oi) -: SeqModelGroup(vec, oi) -{ -} - -DataTagElementToken::DataTagElementToken(const ElementType *element, - Vector &templates, - Text &paddingTemplate) -: ElementToken(element, ContentToken::none), - havePaddingTemplate_(1) -{ - templates.swap(templates_); - paddingTemplate.swap(paddingTemplate_); -} - -DataTagElementToken::DataTagElementToken(const ElementType *element, - Vector &templates) -: ElementToken(element, ContentToken::none), - havePaddingTemplate_(0) -{ - templates.swap(templates_); -} - -ContentToken::~ContentToken() -{ -} - -struct GroupInfo { - unsigned nextLeafIndex; - PackedBoolean containsPcdata; - unsigned andStateSize; - Vector nextTypeIndex; - GroupInfo(size_t); -}; - - -GroupInfo::GroupInfo(size_t nType) -: nextTypeIndex(nType, 0), nextLeafIndex(0), containsPcdata(0), andStateSize(0) -{ -} - -CompiledModelGroup::CompiledModelGroup(Owner &modelGroup) -: modelGroup_(modelGroup.extract()), andStateSize_(0), containsPcdata_(false) -{ -} - -void CompiledModelGroup::compile(size_t nElementTypeIndex, - Vector &ambiguities, - Boolean &pcdataUnreachable) -{ - FirstSet first; - LastSet last; - GroupInfo info(nElementTypeIndex); - modelGroup_->analyze(info, 0, 0, first, last); - for (unsigned i = 0; i < last.size(); i++) - last[i]->setFinal(); - andStateSize_ = info.andStateSize; - containsPcdata_ = info.containsPcdata; - initial_ = new InitialPseudoToken; - LastSet initialSet(1); - initialSet[0] = initial_.pointer(); - ContentToken::addTransitions(initialSet, first, 1, 0, 0); - if (modelGroup_->inherentlyOptional()) - initial_->setFinal(); - pcdataUnreachable = 0; - Vector minAndDepth(info.nextLeafIndex); - Vector elementTransition(nElementTypeIndex); - initial_->finish(minAndDepth, elementTransition, ambiguities, - pcdataUnreachable); - modelGroup_->finish(minAndDepth, elementTransition, ambiguities, - pcdataUnreachable); - if (!containsPcdata_) - pcdataUnreachable = 0; -} - -void ModelGroup::finish(Vector &minAndDepth, - Vector &elementTransition, - Vector &ambiguities, - Boolean &pcdataUnreachable) -{ - for (unsigned i = 0; i < nMembers(); i++) - member(i).finish(minAndDepth, elementTransition, ambiguities, - pcdataUnreachable); -} - -void LeafContentToken::finish(Vector &minAndDepthVec, - Vector &elementTransitionVec, - Vector &ambiguities, - Boolean &pcdataUnreachable) -{ - if (andInfo_) { - andFinish(minAndDepthVec, elementTransitionVec, ambiguities, - pcdataUnreachable); - return; - } - Vector::iterator elementTransition = elementTransitionVec.begin(); - Vector::iterator minAndDepth = minAndDepthVec.begin(); - minAndDepthVec.assign(minAndDepthVec.size(), unsigned(-1)); - elementTransitionVec.assign(elementTransitionVec.size(), size_t(-1)); - pcdataTransitionType_ = 0; - simplePcdataTransition_ = 0; - // follow_ is in decreasing order of andDepth because of how it's - // constructed. - size_t n = follow_.size(); - Vector::iterator follow = follow_.begin(); - size_t j = 0; - for (size_t i = 0; i < n; i++) { - unsigned &minDepth = minAndDepth[follow[i]->index()]; - if (minDepth) { - minDepth = 0; - if (j != i) - follow[j] = follow[i]; - if (i == requiredIndex_) - requiredIndex_ = j; - const ElementType *e = follow[i]->elementType(); - unsigned ei; - if (e == 0) { - if (!follow[i]->andInfo_) { - simplePcdataTransition_ = follow[i]; - pcdataTransitionType_ = 1; - } - else - pcdataTransitionType_ = 2; - ei = 0; - } - else - ei = e->index(); - if (elementTransition[ei] != size_t(-1)) { - const LeafContentToken *prev = follow[elementTransition[ei]]; - // This might not be true: consider (a & b?)*; after the - // a there are two different ways to get to the same b, - // with the same and depth. - if (follow[i] != prev) { - ambiguities.resize(ambiguities.size() + 1); - ContentModelAmbiguity &a = ambiguities.back(); - a.from = this; - a.to1 = prev; - a.to2 = follow[i]; - a.andDepth = 0; - } - } - elementTransition[ei] = j; - j++; - } - } - if (pcdataTransitionType_ == 0) - pcdataUnreachable = 1; - follow_.resize(j); -} - -void LeafContentToken::andFinish(Vector &minAndDepthVec, - Vector &elementTransitionVec, - Vector &ambiguities, - Boolean &pcdataUnreachable) -{ - // Vector mapping element type index to index of leaf content token - // of that type to which there is a transition, which is the "worst" - // from the point of view of ambiguity. - Vector::iterator elementTransition = elementTransitionVec.begin(); - // Vector mapping index of leaf content token - // to minimum AND depth of transition to that token. - Vector::iterator minAndDepth = minAndDepthVec.begin(); - minAndDepthVec.assign(minAndDepthVec.size(), unsigned(-1)); - elementTransitionVec.assign(elementTransitionVec.size(), size_t(-1)); - pcdataTransitionType_ = 0; - simplePcdataTransition_ = 0; - unsigned pcdataMinCovered = 0; - - // follow_ is in decreasing order of andDepth because of how it's - // constructed. - size_t n = follow_.size(); - size_t j = 0; - Vector::iterator andFollow = andInfo_->follow.begin(); - for (size_t i = 0; i < n; i++) { - unsigned &minDepth = minAndDepth[follow_[i]->index()]; - // ignore transitions to the same token with the same and depth. - if (andFollow[i].andDepth < minDepth) { - minDepth = andFollow[i].andDepth; - if (j != i) { - follow_[j] = follow_[i]; - andFollow[j] = andFollow[i]; - } - if (i == requiredIndex_) - requiredIndex_ = j; - const ElementType *e = follow_[i]->elementType(); - unsigned ei; - if (e == 0) { - if (pcdataTransitionType_ == 0) { - const AndModelGroup *andAncestor = andInfo_->andAncestor; - unsigned groupIndex = andInfo_->andGroupIndex; - do { - Boolean hasNonNull = 0; - for (unsigned k = 0; k < andAncestor->nMembers(); k++) - if (k != groupIndex - && !andAncestor->member(k).inherentlyOptional()) { - hasNonNull = 1; - break; - } - if (hasNonNull) { - if (minDepth <= andAncestor->andDepth()) - pcdataUnreachable = 1; - break; - } - groupIndex = andAncestor->andGroupIndex(); - andAncestor = andAncestor->andAncestor(); - } while (andAncestor); - if (andFollow[i].isolated) - pcdataMinCovered = minDepth; - pcdataTransitionType_ = 2; - } - else { - if (pcdataMinCovered > minDepth + 1) - pcdataUnreachable = 1; - pcdataMinCovered = andFollow[i].isolated ? minDepth : 0; - } - ei = 0; - } - else - ei = e->index(); - // If we have transitions t1, t2, ... tN to tokens having - // the same element type, with - // and-depths d1, d2, ... dN, where d1 >= d2 >= ... >= dN, - // then there is an ambiguity unless - // d1 > d2 > ... > dN and t1, t2, ... , tN-1 are all isolated. - size_t previ = elementTransition[ei]; - if (previ != size_t(-1)) { - const LeafContentToken *prev = follow_[previ]; - // This might not be true: consider (a & b?)*; after the - // a there are two different ways to get to the same b, - // with the same and depth. - if (follow_[i] != prev - && (andFollow[previ].andDepth == andFollow[i].andDepth - || !andFollow[previ].isolated)) { - ambiguities.resize(ambiguities.size() + 1); - ContentModelAmbiguity &a = ambiguities.back(); - a.from = this; - a.to1 = prev; - a.to2 = follow_[i]; - a.andDepth = andFollow[i].andDepth; - } - if (andFollow[previ].isolated) - elementTransition[ei] = j; - } - else - elementTransition[ei] = j; - j++; - } - } - if (pcdataMinCovered > 0 || pcdataTransitionType_ == 0) - pcdataUnreachable = 1; - follow_.resize(j); - andInfo_->follow.resize(j); -} - -void ContentToken::analyze(GroupInfo &info, - const AndModelGroup *andAncestor, - unsigned andGroupIndex, - FirstSet &first, - LastSet &last) -{ - analyze1(info, andAncestor, andGroupIndex, first, last); - if (occurrenceIndicator_ & opt) - inherentlyOptional_ = 1; - if (inherentlyOptional_) - first.setNotRequired(); - if (occurrenceIndicator_ & plus) - addTransitions(last, first, 0, - andIndex(andAncestor), andDepth(andAncestor)); -} - -void LeafContentToken::analyze1(GroupInfo &info, - const AndModelGroup *andAncestor, - unsigned andGroupIndex, - FirstSet &first, - LastSet &last) -{ - leafIndex_ = info.nextLeafIndex++; - typeIndex_ = info.nextTypeIndex[element_ ? element_->index() : 0]++; - if (andAncestor) { - andInfo_ = new AndInfo; - andInfo_->andAncestor = andAncestor; - andInfo_->andGroupIndex = andGroupIndex; - } - first.init(this); - last.assign(1, this); - inherentlyOptional_ = 0; -} - -void PcdataToken::analyze1(GroupInfo &info, - const AndModelGroup *andAncestor, - unsigned andGroupIndex, - FirstSet &first, - LastSet &last) -{ - info.containsPcdata = 1; - LeafContentToken::analyze1(info, andAncestor, andGroupIndex, first, last); -} - -void OrModelGroup::analyze1(GroupInfo &info, - const AndModelGroup *andAncestor, - unsigned andGroupIndex, - FirstSet &first, - LastSet &last) -{ - member(0).analyze(info, andAncestor, andGroupIndex, first, last); - first.setNotRequired(); - inherentlyOptional_ = member(0).inherentlyOptional(); - for (unsigned i = 1; i < nMembers(); i++) { - FirstSet tempFirst; - LastSet tempLast; - member(i).analyze(info, andAncestor, andGroupIndex, tempFirst, tempLast); - first.append(tempFirst); - first.setNotRequired(); - last.append(tempLast); - inherentlyOptional_ |= member(i).inherentlyOptional(); - } -} - -void SeqModelGroup::analyze1(GroupInfo &info, - const AndModelGroup *andAncestor, - unsigned andGroupIndex, - FirstSet &first, - LastSet &last) -{ - member(0).analyze(info, andAncestor, andGroupIndex, first, last); - inherentlyOptional_ = member(0).inherentlyOptional(); - for (unsigned i = 1; i < nMembers(); i++) { - FirstSet tempFirst; - LastSet tempLast; - member(i).analyze(info, andAncestor, andGroupIndex, tempFirst, tempLast); - addTransitions(last, tempFirst, 1, - andIndex(andAncestor), andDepth(andAncestor)); - if (inherentlyOptional_) - first.append(tempFirst); - if (member(i).inherentlyOptional()) - last.append(tempLast); - else - tempLast.swap(last); - inherentlyOptional_ &= member(i).inherentlyOptional(); - } -} - -void AndModelGroup::analyze1(GroupInfo &info, - const AndModelGroup *andAncestor, - unsigned andGroupIndex, - FirstSet &first, - LastSet &last) -{ - andDepth_ = ContentToken::andDepth(andAncestor); - andIndex_ = ContentToken::andIndex(andAncestor); - andAncestor_ = andAncestor; - andGroupIndex_ = andGroupIndex; - if (andIndex_ + nMembers() > info.andStateSize) - info.andStateSize = andIndex_ + nMembers(); - Vector firstVec(nMembers()); - Vector lastVec(nMembers()); - member(0).analyze(info, this, 0, firstVec[0], lastVec[0]); - first = firstVec[0]; - first.setNotRequired(); - last = lastVec[0]; - inherentlyOptional_ = member(0).inherentlyOptional(); - unsigned i; - for (i = 1; i < nMembers(); i++) { - member(i).analyze(info, this, i, firstVec[i], lastVec[i]); - first.append(firstVec[i]); - first.setNotRequired(); - last.append(lastVec[i]); - inherentlyOptional_ &= member(i).inherentlyOptional(); - } - for (i = 0; i < nMembers(); i++) { - for (unsigned j = 0; j < nMembers(); j++) - if (j != i) - addTransitions(lastVec[i], firstVec[j], 0, - andIndex() + nMembers(), - andDepth() + 1, - !member(j).inherentlyOptional(), - andIndex() + j, andIndex() + i); - } -} - -void ContentToken::addTransitions(const LastSet &from, - const FirstSet &to, - Boolean maybeRequired, - unsigned andClearIndex, - unsigned andDepth, - Boolean isolated, - unsigned requireClear, - unsigned toSet) -{ - size_t length = from.size(); - for (unsigned i = 0; i < length; i++) - from[i]->addTransitions(to, - maybeRequired, - andClearIndex, - andDepth, - isolated, - requireClear, - toSet); -} - -void LeafContentToken::addTransitions(const FirstSet &to, - Boolean maybeRequired, - unsigned andClearIndex, - unsigned andDepth, - Boolean isolated, - unsigned requireClear, - unsigned toSet) -{ - if (maybeRequired && to.requiredIndex() != size_t(-1)) { - ASSERT(requiredIndex_ == size_t(-1)); - requiredIndex_ = to.requiredIndex() + follow_.size(); - } - size_t length = follow_.size(); - size_t n = to.size(); - follow_.resize(length + n); - for (size_t i = 0; i < n; i++) - follow_[length + i] = to.token(i); - if (andInfo_) { - andInfo_->follow.resize(length + n); - for (size_t i = 0; i < n; i++) { - Transition &t = andInfo_->follow[length + i]; - t.clearAndStateStartIndex = andClearIndex; - t.andDepth = andDepth; - t.isolated = isolated; - t.requireClear = requireClear; - t.toSet = toSet; - } - } -} - -AndState::AndState(unsigned n) -: v_(n, PackedBoolean(0)), clearFrom_(0) -{ -} - -void AndState::clearFrom1(unsigned i) -{ - while (clearFrom_ > i) - v_[--clearFrom_] = 0; -} - -MatchState::MatchState() -: andState_(0), pos_(NULL), minAndDepth_(0) -{ -} - -MatchState::MatchState(const CompiledModelGroup *model) -: pos_(model ? model->initial() : 0), - andState_(model ? model->andStateSize() : 0), - minAndDepth_(0) -{ -} - -const LeafContentToken *MatchState::invalidExclusion(const ElementType *e) - const -{ - const LeafContentToken *token = pos_->transitionToken(e, andState_, - minAndDepth_); - if (token && !token->inherentlyOptional() && !token->orGroupMember()) - return token; - else - return 0; -} - -Boolean MatchState::operator==(const MatchState &state) const -{ - return (pos_ == state.pos_ && andState_ == state.andState_ - && minAndDepth_ == state.minAndDepth_); -} - -Boolean AndState::operator==(const AndState &state) const -{ - ASSERT(v_.size() == state.v_.size()); - for (size_t i = 0; i < v_.size(); i++) { - if (i >= clearFrom_ && i >= state.clearFrom_) - break; - if (v_[i] != state.v_[i]) - return 0; - } - return 1; -} - -const LeafContentToken * -LeafContentToken::transitionToken(const ElementType *to, - const AndState &andState, - unsigned minAndDepth) const -{ - Vector::const_iterator p = follow_.begin(); - if (!andInfo_) { - for (size_t n = follow_.size(); n > 0; n--, p++) - if ((*p)->elementType() == to) - return *p; - } - else { - Vector::const_iterator q = andInfo_->follow.begin(); - for (size_t n = follow_.size(); n > 0; n--, p++, q++) - if ((*p)->elementType() == to - && ((q->requireClear == unsigned(Transition::invalidIndex) - || andState.isClear(q->requireClear)) - && q->andDepth >= minAndDepth)) - return (*p); - } - return 0; -} - -Boolean -LeafContentToken::tryTransition(const ElementType *to, - AndState &andState, - unsigned &minAndDepth, - const LeafContentToken *&newpos) const -{ - Vector::const_iterator p = follow_.begin(); - if (!andInfo_) { - for (size_t n = follow_.size(); n > 0; n--, p++) { - if ((*p)->elementType() == to) { - newpos = *p; - minAndDepth = newpos->computeMinAndDepth(andState); - return 1; - } - } - } - else { - Vector::const_iterator q = andInfo_->follow.begin(); - for (size_t n = follow_.size(); n > 0; n--, p++, q++) { - if ((*p)->elementType() == to - && ((q->requireClear == unsigned(Transition::invalidIndex) - || andState.isClear(q->requireClear)) - && q->andDepth >= minAndDepth)) { - if (q->toSet != unsigned(Transition::invalidIndex)) - andState.set(q->toSet); - andState.clearFrom(q->clearAndStateStartIndex); - newpos = *p; - minAndDepth = newpos->computeMinAndDepth(andState); - return 1; - } - } - } - return 0; -} - -void -LeafContentToken::possibleTransitions(const AndState &andState, - unsigned minAndDepth, - Vector &v) const -{ - Vector::const_iterator p = follow_.begin(); - if (!andInfo_) { - for (size_t n = follow_.size(); n > 0; n--, p++) - v.push_back((*p)->elementType()); - } - else { - Vector::const_iterator q = andInfo_->follow.begin(); - for (size_t n = follow_.size(); n > 0; n--, p++, q++) - if ((q->requireClear == unsigned(Transition::invalidIndex) - || andState.isClear(q->requireClear)) - && q->andDepth >= minAndDepth) - v.push_back((*p)->elementType()); - } -} - -unsigned LeafContentToken::computeMinAndDepth1(const AndState &andState) const -{ - ASSERT(andInfo_); - unsigned groupIndex = andInfo_->andGroupIndex; - for (const AndModelGroup *group = andInfo_->andAncestor; - group; - groupIndex = group->andGroupIndex(), group = group->andAncestor()) - for (unsigned i = 0; i < group->nMembers(); i++) - if (i != groupIndex && !group->member(i).inherentlyOptional() - && andState.isClear(group->andIndex() + i)) - return group->andDepth() + 1; - return 0; -} - -const LeafContentToken * -LeafContentToken::impliedStartTag(const AndState &andState, - unsigned minAndDepth) const -{ - if (requiredIndex_ != size_t(-1)) { - if (!andInfo_) - return follow_[requiredIndex_]; - const Transition &t = andInfo_->follow[requiredIndex_]; - if ((t.requireClear == unsigned(Transition::invalidIndex) - || andState.isClear(t.requireClear)) - && t.andDepth >= minAndDepth) - return follow_[requiredIndex_]; - } - return 0; -} - -void LeafContentToken::doRequiredTransition(AndState &andState, - unsigned &minAndDepth, - const LeafContentToken *&newpos) - const -{ - ASSERT(requiredIndex_ != size_t(-1)); - if (andInfo_) { - const Transition &t = andInfo_->follow[requiredIndex_]; - if (t.toSet != unsigned(Transition::invalidIndex)) - andState.set(t.toSet); - andState.clearFrom(t.clearAndStateStartIndex); - } - newpos = follow_[requiredIndex_]; - minAndDepth = newpos->computeMinAndDepth(andState); -} - -FirstSet::FirstSet() -: requiredIndex_(size_t(-1)) -{ -} - -void FirstSet::init(LeafContentToken *p) -{ - v_.assign(1, p); - v_.reserve(256); - requiredIndex_ = 0; -} - -void FirstSet::append(const FirstSet &set) -{ - if (set.requiredIndex_ != size_t(-1)) { - ASSERT(requiredIndex_ == size_t(-1)); - requiredIndex_ = set.requiredIndex_ + v_.size(); - } - size_t oldSize = v_.size(); - v_.resize(v_.size() + set.v_.size()); - for (size_t i = 0; i < set.v_.size(); i++) - v_[oldSize + i] = set.v_[i]; -} - -void LastSet::append(const LastSet &set) -{ - size_t oldSize = size(); - resize(size() + set.size()); - for (size_t i = 0; i < set.size(); i++) - (*this)[oldSize + i] = set[i]; -} - -#ifdef SP_NAMESPACE -} -#endif diff --git a/cde/programs/nsgmls/ContentToken.h b/cde/programs/nsgmls/ContentToken.h deleted file mode 100644 index 1bbda7002..000000000 --- a/cde/programs/nsgmls/ContentToken.h +++ /dev/null @@ -1,657 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: ContentToken.h /main/1 1996/07/29 16:48:40 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#ifndef ContentToken_INCLUDED -#define ContentToken_INCLUDED 1 -#ifdef __GNUG__ -#pragma interface -#endif - -#include "Owner.h" -#include "Text.h" -#include "Vector.h" -#include "NCVector.h" -#include "Boolean.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -class LeafContentToken; - -struct SP_API Transition { - Transition() { } - ~Transition() { } - enum { invalidIndex = -1 }; - // When performing this transition, reset all andState with index >= this. - unsigned clearAndStateStartIndex; - // This transition is possible only if all AND groups whose AND depth - // is >= this (and contains the LeafContentToken that this transition is - // from) have had all their non-nullable members matched. - unsigned andDepth; - // If this is 1, then this transition requires that the AND group - // whose AND depth is andDepth - 1 have a non-nullable member unmatched, - // and thus this transition is not ambiguous with a transition whose - // AND depth is < andDepth. - PackedBoolean isolated; - // Index in andState that must be clear for this transition to be - // allowed. - unsigned requireClear; - // Index in andState that is to be set after performing this transition. - unsigned toSet; -}; - -class SP_API FirstSet { -public: - FirstSet(); - void init(LeafContentToken *); - void append(const FirstSet &); - size_t size() const; - LeafContentToken *token(size_t i) const; - size_t requiredIndex() const; - void setNotRequired(); -private: - Vector v_; - // index of contextually required token or -1 if none - size_t requiredIndex_; -}; - -class SP_API LastSet : public Vector { -public: - LastSet() { } - LastSet(size_t n) : Vector(n) { } - void append(const LastSet &); -}; - -class ElementType; -class AndModelGroup; -struct GroupInfo; - -struct SP_API ContentModelAmbiguity { - ContentModelAmbiguity () { } - ~ContentModelAmbiguity () { } - const LeafContentToken *from; - const LeafContentToken *to1; - const LeafContentToken *to2; - unsigned andDepth; -}; - -class ModelGroup; - -class SP_API ContentToken { -public: - enum OccurrenceIndicator { none = 0, opt = 01, plus = 02, rep = 03 }; - ContentToken(OccurrenceIndicator); - virtual ~ContentToken(); - OccurrenceIndicator occurrenceIndicator() const; - Boolean inherentlyOptional() const; - static unsigned andDepth(const AndModelGroup *); - static unsigned andIndex(const AndModelGroup *); - void analyze(GroupInfo &, const AndModelGroup *, unsigned, - FirstSet &, LastSet &); - static void addTransitions(const LastSet &from, - const FirstSet &to, - Boolean maybeRequired, - unsigned andClearIndex, - unsigned andDepth, - Boolean isolated = 0, - unsigned requireClear - = (unsigned)Transition::invalidIndex, - unsigned toSet - = (unsigned)Transition::invalidIndex); - virtual void finish(Vector &minAndDepth, - Vector &elementTransition, - Vector &, - Boolean &pcdataUnreachable) = 0; - virtual unsigned long grpgtcnt() const; - virtual void setOrGroupMember(); - unsigned andGroupIndex() const; - virtual const ModelGroup *asModelGroup() const; - virtual const LeafContentToken *asLeafContentToken() const; -protected: - PackedBoolean inherentlyOptional_; -private: - ContentToken(const ContentToken &); // undefined - void operator=(const ContentToken &); // undefined - virtual void analyze1(GroupInfo &, const AndModelGroup *, unsigned, - FirstSet &, LastSet &) = 0; - OccurrenceIndicator occurrenceIndicator_; -}; - -class SP_API ModelGroup : public ContentToken { -public: - enum Connector { andConnector, orConnector, seqConnector }; - ModelGroup(NCVector > &, OccurrenceIndicator); - virtual Connector connector() const = 0; - unsigned nMembers() const; - void finish(Vector &minAndDepth, - Vector &elementTransition, - Vector &, - Boolean &pcdataUnreachable); - ContentToken &member(unsigned i); - const ContentToken &member(unsigned i) const; - unsigned long grpgtcnt() const; - const ModelGroup *asModelGroup() const; -protected: - void setOrGroup(); -private: - ModelGroup(const ModelGroup &); // undefined - void operator=(const ModelGroup &); // undefined - NCVector > members_; -}; - -class AndModelGroup : public ModelGroup { -public: - AndModelGroup(NCVector > &, OccurrenceIndicator); - Connector connector() const; - unsigned andDepth() const; - unsigned andIndex() const; - unsigned andGroupIndex() const; - const AndModelGroup *andAncestor() const; -private: - AndModelGroup(const AndModelGroup &); // undefined - void operator=(const AndModelGroup &); // undefined - unsigned andDepth_; // number of and groups that contain this - unsigned andIndex_; - unsigned andGroupIndex_; - const AndModelGroup *andAncestor_; - void analyze1(GroupInfo &, const AndModelGroup *, unsigned, - FirstSet &, LastSet &); -}; - -class OrModelGroup : public ModelGroup { -public: - OrModelGroup(NCVector > &, OccurrenceIndicator); - Connector connector() const; -private: - OrModelGroup(const OrModelGroup &); // undefined - void operator=(const OrModelGroup &); // undefined - void analyze1(GroupInfo &, const AndModelGroup *, unsigned, - FirstSet &, LastSet &); -}; - -class SeqModelGroup : public ModelGroup { -public: - SeqModelGroup(NCVector > &, OccurrenceIndicator); - Connector connector() const; -private: - SeqModelGroup(const SeqModelGroup &); // undefined - void operator=(const SeqModelGroup &); // undefined - void analyze1(GroupInfo &, const AndModelGroup *, unsigned, - FirstSet &, LastSet &); -}; - -class AndState; - -class SP_API AndInfo { -public: - AndInfo() : andAncestor(NULL), andGroupIndex(0) { } - const AndModelGroup *andAncestor; - unsigned andGroupIndex; - Vector follow; -private: - AndInfo(const AndInfo &); // undefined - void operator=(const AndInfo &); // undefined -}; - -// A LeafContentToken is not quite the same as a primitive content token. -// A data tag group is a primitive content token but not a LeafContentToken. - -class SP_API LeafContentToken : public ContentToken { -public: - LeafContentToken(const ElementType *, OccurrenceIndicator); - unsigned index() const; - unsigned typeIndex() const; - const ElementType *elementType() const; - virtual Boolean isInitial() const; - void addTransitions(const FirstSet &to, - Boolean maybeRequired, - unsigned andClearIndex, - unsigned andDepth, - Boolean isolated, - unsigned requireClear, - unsigned toSet); - void setFinal(); - void finish(Vector &minAndDepth, - Vector &elementTransition, - Vector &, - Boolean &pcdataUnreachable); - Boolean isFinal() const; - Boolean tryTransition(const ElementType *, AndState &, - unsigned &minAndDepth, - const LeafContentToken *&newpos) const; - Boolean tryTransitionPcdata(AndState &, unsigned &minAndDepth, - const LeafContentToken *&newpos) const; - void possibleTransitions(const AndState &, unsigned minAndDepth, Vector &) const; - const LeafContentToken *impliedStartTag(const AndState &andpos, - unsigned minAndDepth) const; - const LeafContentToken *transitionToken(const ElementType *to, - const AndState &andState, - unsigned minAndDepth) const; - void doRequiredTransition(AndState &andState, - unsigned &minAndDepth, - const LeafContentToken *&newpos) const; - unsigned computeMinAndDepth(const AndState&) const; - Boolean orGroupMember() const; - void setOrGroupMember(); - const AndModelGroup *andAncestor() const; - unsigned andDepth() const; - const LeafContentToken *asLeafContentToken() const; -protected: - void analyze1(GroupInfo &, const AndModelGroup *, unsigned, - FirstSet &, LastSet &); - const ElementType *element_; -private: - LeafContentToken(const LeafContentToken &); // undefined - void operator=(const LeafContentToken &); // undefined - void andFinish(Vector &minAndDepth, - Vector &elementTransition, - Vector &, - Boolean &pcdataUnreachable); - unsigned computeMinAndDepth1(const AndState&) const; - unsigned leafIndex_; - unsigned typeIndex_; - Vector follow_; - PackedBoolean isFinal_; - PackedBoolean orGroupMember_; - // 0 none, 1 yes - simple, 2 - compled - char pcdataTransitionType_; - const LeafContentToken *simplePcdataTransition_; - size_t requiredIndex_; - Owner andInfo_; -}; - -class PcdataToken : public LeafContentToken { -public: - PcdataToken(); - void analyze1(GroupInfo &, const AndModelGroup *, unsigned, - FirstSet &, LastSet &); -private: - PcdataToken(const PcdataToken &); // undefined - void operator=(const PcdataToken &); // undefined -}; - -class InitialPseudoToken : public LeafContentToken { -public: - InitialPseudoToken(); - Boolean isInitial() const; -private: - InitialPseudoToken(const InitialPseudoToken &); // undefined - void operator=(const InitialPseudoToken &); // undefined -}; - -class ElementToken : public LeafContentToken { -public: - ElementToken(const ElementType *, OccurrenceIndicator); -private: - ElementToken(const ElementToken &); // undefined - void operator=(const ElementToken &); // undefined -}; - -class DataTagGroup : public SeqModelGroup { -public: - // first content token is a DataTagElementToken, second is PcdataToken - DataTagGroup(NCVector > &, OccurrenceIndicator); -private: - DataTagGroup(const DataTagGroup &); // undefined - void operator=(const DataTagGroup &); // undefined -}; - -class DataTagElementToken : public ElementToken { -public: - DataTagElementToken(const ElementType *, Vector &templates); - DataTagElementToken(const ElementType *, Vector &templates, - Text &paddingTemplate); -private: - DataTagElementToken(const DataTagElementToken &); // undefined - void operator=(const DataTagElementToken &); // undefined - Vector templates_; - Boolean havePaddingTemplate_; - Text paddingTemplate_; -}; - -class SP_API CompiledModelGroup { -public: - CompiledModelGroup(Owner &); - void compile(size_t nElementTypeIndex, - Vector &, - Boolean &pcdataUnreachable); - CompiledModelGroup *copy() const; - const LeafContentToken *initial() const; - unsigned andStateSize() const; - Boolean containsPcdata() const; - const ModelGroup *modelGroup() const; -private: - CompiledModelGroup(const CompiledModelGroup &); // undefined - void operator=(const CompiledModelGroup &); // undefined - Owner modelGroup_; - Owner initial_; - unsigned andStateSize_; - Boolean containsPcdata_; -}; - -class SP_API AndState { -public: - AndState(unsigned); - Boolean isClear(unsigned) const; - void clearFrom(unsigned); - void set(unsigned); - Boolean operator==(const AndState &) const; - Boolean operator!=(const AndState &) const; -private: - void clearFrom1(unsigned); - unsigned clearFrom_; - Vector v_; -}; - -class SP_API MatchState { -public: - MatchState(); - MatchState(const CompiledModelGroup *); // may be 0 - Boolean tryTransition(const ElementType *); - Boolean tryTransitionPcdata(); - void possibleTransitions(Vector &) const; - Boolean isFinished() const; - const LeafContentToken *impliedStartTag() const; - const LeafContentToken *invalidExclusion(const ElementType *) const; - void doRequiredTransition(); - const LeafContentToken *currentPosition() const; - Boolean operator==(const MatchState &) const; - Boolean operator!=(const MatchState &) const; -private: - const LeafContentToken *pos_; - AndState andState_; - unsigned minAndDepth_; -}; - -inline -ContentToken::OccurrenceIndicator ContentToken::occurrenceIndicator() const -{ - return occurrenceIndicator_; -} - -inline -unsigned LeafContentToken::index() const -{ - return leafIndex_; -} - -inline -unsigned LeafContentToken::typeIndex() const -{ - return typeIndex_; -} - -inline -Boolean ContentToken::inherentlyOptional() const -{ - return inherentlyOptional_; -} - -inline -const ElementType *LeafContentToken::elementType() const -{ - return element_; -} - -inline -unsigned AndModelGroup::andDepth() const -{ - return andDepth_; -} - -inline -unsigned AndModelGroup::andIndex() const -{ - return andIndex_; -} - -inline -unsigned ModelGroup::nMembers() const -{ - return members_.size(); -} - -inline -unsigned ContentToken::andDepth(const AndModelGroup *andAncestor) -{ - return andAncestor ? andAncestor->andDepth() + 1 : 0; -} - -inline -unsigned ContentToken::andIndex(const AndModelGroup *andAncestor) -{ - return (andAncestor - ? andAncestor->andIndex() + andAncestor->nMembers() - : 0); -} - -inline -ContentToken &ModelGroup::member(unsigned i) -{ - return *members_[i]; -} - -inline -const ContentToken &ModelGroup::member(unsigned i) const -{ - return *members_[i]; -} - -inline -void LeafContentToken::setFinal() -{ - isFinal_ = 1; -} - -inline -Boolean LeafContentToken::isFinal() const -{ - return isFinal_; -} - -inline -Boolean LeafContentToken::orGroupMember() const -{ - return orGroupMember_; -} - -inline -unsigned CompiledModelGroup::andStateSize() const -{ - return andStateSize_; -} - -inline -Boolean CompiledModelGroup::containsPcdata() const -{ - return containsPcdata_; -} - -inline -const AndModelGroup *AndModelGroup::andAncestor() const -{ - return andAncestor_; -} - -inline -unsigned AndModelGroup::andGroupIndex() const -{ - return andGroupIndex_; -} - -inline -const LeafContentToken *CompiledModelGroup::initial() const -{ - return initial_.pointer(); -} - -inline -const ModelGroup *CompiledModelGroup::modelGroup() const -{ - return modelGroup_.pointer(); -} - -inline -const AndModelGroup *LeafContentToken::andAncestor() const -{ - return andInfo_ ? andInfo_->andAncestor : 0; -} - -inline -unsigned LeafContentToken::andDepth() const -{ - return andInfo_ ? ContentToken::andDepth(andInfo_->andAncestor) : 0; -} - -inline -unsigned LeafContentToken::computeMinAndDepth(const AndState &andState) const -{ - return andInfo_ ? computeMinAndDepth1(andState) : 0; -} - -inline -Boolean LeafContentToken::tryTransitionPcdata(AndState &andState, - unsigned &minAndDepth, - const LeafContentToken *&newpos) - const -{ - if (pcdataTransitionType_ == 1) { - newpos = simplePcdataTransition_; - return 1; - } - else if (pcdataTransitionType_ == 0) - return 0; - else - return tryTransition(0, andState, minAndDepth, newpos); -} - -inline -Boolean MatchState::tryTransition(const ElementType *to) -{ - return pos_->tryTransition(to, andState_, minAndDepth_, pos_); -} - -inline -Boolean MatchState::tryTransitionPcdata() -{ - return pos_->tryTransitionPcdata(andState_, minAndDepth_, pos_); -} - -inline -void MatchState::possibleTransitions(Vector &v) const -{ - pos_->possibleTransitions(andState_, minAndDepth_, v); -} - -inline -Boolean MatchState::isFinished() const -{ - return pos_->isFinal() && minAndDepth_ == 0; -} - -inline -const LeafContentToken * -MatchState::impliedStartTag() const -{ - return pos_->impliedStartTag(andState_, minAndDepth_); -} - -inline -void MatchState::doRequiredTransition() -{ - pos_->doRequiredTransition(andState_, minAndDepth_, pos_); -} - -inline -const LeafContentToken *MatchState::currentPosition() const -{ - return pos_; -} - -inline -Boolean MatchState::operator!=(const MatchState &state) const -{ - return !(*this == state); -} - -inline -Boolean AndState::isClear(unsigned i) const -{ - return v_[i] == 0; -} - -inline -void AndState::set(unsigned i) -{ - v_[i] = 1; - if (i >= clearFrom_) - clearFrom_ = i + 1; -} - -inline -void AndState::clearFrom(unsigned i) -{ - if (i < clearFrom_) - clearFrom1(i); -} - -inline -Boolean AndState::operator!=(const AndState &state) const -{ - return !(*this == state); -} - - -inline -size_t FirstSet::size() const -{ - return v_.size(); -} - -inline -LeafContentToken *FirstSet::token(size_t i) const -{ - return v_[i]; -} - -inline -size_t FirstSet::requiredIndex() const -{ - return requiredIndex_; -} - -inline -void FirstSet::setNotRequired() -{ - requiredIndex_ = size_t(-1); -} - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* not ContentToken_INCLUDED */ diff --git a/cde/programs/nsgmls/CopyOwner.C b/cde/programs/nsgmls/CopyOwner.C deleted file mode 100644 index 90fa89f00..000000000 --- a/cde/programs/nsgmls/CopyOwner.C +++ /dev/null @@ -1,50 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: CopyOwner.C /main/1 1996/07/29 16:48:46 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#ifndef CopyOwner_DEF_INCLUDED -#define CopyOwner_DEF_INCLUDED 1 - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -template -CopyOwner::CopyOwner(const CopyOwner &o) -: Owner(o.pointer() ? o.pointer()->copy() : 0) -{ -} - -template -void CopyOwner::operator=(const CopyOwner &o) -{ - Owner::operator=(o.pointer() ? o.pointer()->copy() : 0); -} - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* not CopyOwner_DEF_INCLUDED */ diff --git a/cde/programs/nsgmls/CopyOwner.h b/cde/programs/nsgmls/CopyOwner.h deleted file mode 100644 index fbabf4e76..000000000 --- a/cde/programs/nsgmls/CopyOwner.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: CopyOwner.h /main/1 1996/07/29 16:48:51 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#ifndef CopyOwner_INCLUDED -#define CopyOwner_INCLUDED 1 - -#include "Owner.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -template -class CopyOwner : public Owner { -public: - CopyOwner() { } - CopyOwner(T *p) : Owner(p) { } - CopyOwner(const CopyOwner &); - void operator=(const CopyOwner &o); - void operator=(T *p) { Owner::operator=(p); } -}; - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* not CopyOwner_INCLUDED */ - -#ifdef SP_DEFINE_TEMPLATES -#include "CopyOwner.C" -#endif diff --git a/cde/programs/nsgmls/DescriptorManager.C b/cde/programs/nsgmls/DescriptorManager.C deleted file mode 100644 index 5759d2f49..000000000 --- a/cde/programs/nsgmls/DescriptorManager.C +++ /dev/null @@ -1,113 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: DescriptorManager.C /main/1 1996/07/29 16:48:58 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#include "splib.h" -#include "DescriptorManager.h" -#include "ListIter.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -DescriptorUser::DescriptorUser(DescriptorManager *manager) -: manager_(manager) -{ - if (manager_) - manager_->addUser(this); -} - -DescriptorUser::~DescriptorUser() -{ - if (manager_) - manager_->removeUser(this); -} - -void DescriptorUser::managerDeleted() -{ - manager_ = 0; -} - -Boolean DescriptorUser::suspend() -{ - return 0; -} - -void DescriptorUser::acquireD() -{ - if (manager_) - manager_->acquireD(); -} - -void DescriptorUser::releaseD() -{ - if (manager_) - manager_->releaseD(); -} - -DescriptorManager::DescriptorManager(int maxD) -: maxD_(maxD), usedD_(0) -{ -} - -DescriptorManager::~DescriptorManager() -{ - for (ListIter iter(users_); - !iter.done(); - iter.next()) - iter.cur()->managerDeleted(); -} - -void DescriptorManager::addUser(DescriptorUser *p) -{ - users_.insert(p); -} - -void DescriptorManager::removeUser(DescriptorUser *p) -{ - users_.remove(p); -} - -void DescriptorManager::acquireD() -{ - if (usedD_ >= maxD_) { - for (ListIter iter(users_); - !iter.done(); - iter.next()) { - if (iter.cur()->suspend()) - break; - } - } - usedD_++; -} - -void DescriptorManager::releaseD() -{ - usedD_--; -} - -#ifdef SP_NAMESPACE -} -#endif diff --git a/cde/programs/nsgmls/DescriptorManager.h b/cde/programs/nsgmls/DescriptorManager.h deleted file mode 100644 index 056e27df8..000000000 --- a/cde/programs/nsgmls/DescriptorManager.h +++ /dev/null @@ -1,73 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: DescriptorManager.h /main/1 1996/07/29 16:49:04 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#ifndef DescriptorManager_INCLUDED -#define DescriptorManager_INCLUDED 1 - -#include "Boolean.h" -#include "List.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -class DescriptorManager; - -class SP_API DescriptorUser { -public: - DescriptorUser(DescriptorManager *); - virtual ~DescriptorUser(); - virtual Boolean suspend(); - void managerDeleted(); - void acquireD(); - void releaseD(); - DescriptorManager *manager() const; -private: - DescriptorManager *manager_; -}; - -class SP_API DescriptorManager { -public: - DescriptorManager(int maxD); - ~DescriptorManager(); - void acquireD(); - void releaseD(); - void addUser(DescriptorUser *); - void removeUser(DescriptorUser *); -private: - DescriptorManager(const DescriptorManager &); // undefined - void operator=(const DescriptorManager &); // undefined - - int usedD_; - int maxD_; - List users_; -}; - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* not DescriptorManager_INCLUDED */ diff --git a/cde/programs/nsgmls/Dtd.C b/cde/programs/nsgmls/Dtd.C deleted file mode 100644 index 0b8a8ba9a..000000000 --- a/cde/programs/nsgmls/Dtd.C +++ /dev/null @@ -1,113 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: Dtd.C /main/1 1996/07/29 16:49:10 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#ifdef __GNUG__ -#pragma implementation -#endif -#include "splib.h" -#include "Dtd.h" -#include "Syntax.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -Dtd::Dtd(const StringC &name, Boolean isBase) -: name_(new StringResource(name)), - nCurrentAttribute_(0), - nElementDefinition_(0), - nAttributeDefinitionList_(0), - isBase_(isBase) -{ - documentElementType_ = new ElementType(name, nElementTypeIndex()); - insertElementType(documentElementType_); -} - -Boolean Dtd::shortrefIndex(const StringC &str, const Syntax &syntax, - size_t &index) -{ - const int *indexP = shortrefTable_.lookup(str); - if (indexP) { - index = *indexP; - return 1; - } - if (!syntax.isValidShortref(str)) - return 0; - shortrefTable_.insert(str, int(shortrefs_.size())); - index = shortrefs_.size(); - shortrefs_.push_back(str); - return 1; -} - -void Dtd::addNeededShortref(const StringC &str) -{ - if (!shortrefTable_.lookup(str)) { - shortrefTable_.insert(str, shortrefs_.size()); - shortrefs_.push_back(str); - } -} - -void Dtd::setDefaultEntity(const Ptr &entity, - ParserState &parser) -{ - defaultEntity_ = entity; - - // If the new default entity was defined in a DTD, then - // any defaulted entities must have come from an LPD - // on the first pass, in which case we shouldn't replace them. - // Otherwise we need to replace all the defaulted entities. - if (entity->declInActiveLpd()) { - NamedResourceTable tem; - { - EntityIter iter(generalEntityTable_); - for (;;) { - Ptr old(iter.next()); - if (old.isNull()) - break; - if (old->defaulted()) { - Ptr e(defaultEntity_->copy()); - e->setDefaulted(); - e->setName(old->name()); - e->generateSystemId(parser); - tem.insert(e); - } - } - } - { - EntityIter iter(tem); - for (;;) { - Ptr e(iter.next()); - if (e.isNull()) - break; - generalEntityTable_.insert(e, 1); - } - } - } -} - -#ifdef SP_NAMESPACE -} -#endif diff --git a/cde/programs/nsgmls/Dtd.h b/cde/programs/nsgmls/Dtd.h deleted file mode 100644 index a3f307cb5..000000000 --- a/cde/programs/nsgmls/Dtd.h +++ /dev/null @@ -1,435 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: Dtd.h /main/1 1996/07/29 16:49:16 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#ifndef Dtd_INCLUDED -#define Dtd_INCLUDED 1 -#ifdef __GNUG__ -#pragma interface -#endif - -#include "NamedTable.h" -#include "NamedResourceTable.h" -#include "ElementType.h" -#include "Notation.h" -#include "Entity.h" -#include "ShortReferenceMap.h" -#include "Resource.h" -#include "StringC.h" -#include "StringResource.h" -#include "Boolean.h" -#include "Vector.h" -#include "HashTable.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -class Syntax; -class ParserState; - -class SP_API Dtd : public Resource { -public: - typedef NamedTableIter ElementTypeIter; - typedef ConstNamedTableIter ConstElementTypeIter; - typedef NamedTableIter ShortReferenceMapIter; - typedef ConstNamedResourceTableIter ConstNotationIter; - typedef NamedResourceTableIter NotationIter; - typedef ConstNamedResourceTableIter ConstEntityIter; - typedef NamedResourceTableIter EntityIter; - Dtd(const StringC &name, Boolean isBase); - ConstPtr lookupEntity(Boolean isParameter, const StringC &) const; - const Entity *lookupEntityTemp(Boolean isParameter, const StringC &) const; - Ptr lookupEntity(Boolean isParameter, const StringC &); - Ptr insertEntity(const Ptr &, Boolean replace = 0); - Ptr removeEntity(Boolean isParameter, const StringC &); - ConstEntityIter generalEntityIter() const; - EntityIter generalEntityIter(); - ConstEntityIter parameterEntityIter() const; - EntityIter parameterEntityIter(); - - ConstPtr defaultEntity() const; - const Entity *defaultEntityTemp() const; - void setDefaultEntity(const Ptr &, ParserState &); - const ConstPtr > &namePointer() const; - const StringC &name() const; - - const ElementType *lookupElementType(const StringC &) const; - ElementType *lookupElementType(const StringC &); - ElementType *removeElementType(const StringC &); - ElementType *insertElementType(ElementType *); - size_t nElementTypeIndex() const; - ConstElementTypeIter elementTypeIter() const; - ElementTypeIter elementTypeIter(); - - const RankStem *lookupRankStem(const StringC &) const; - RankStem *lookupRankStem(const StringC &); - RankStem *insertRankStem(RankStem *); - size_t nRankStem() const; - - const ShortReferenceMap *lookupShortReferenceMap(const StringC &) const; - ShortReferenceMap *lookupShortReferenceMap(const StringC &); - ShortReferenceMap *insertShortReferenceMap(ShortReferenceMap *); - ShortReferenceMapIter shortReferenceMapIter(); - - Boolean shortrefIndex(const StringC &, const Syntax &, size_t &index); - size_t nShortref() const; - const StringC &shortref(size_t i) const; - void addNeededShortref(const StringC &); - - ConstPtr lookupNotation(const StringC &) const; - const Notation *lookupNotationTemp(const StringC &) const; - Ptr lookupNotation(const StringC &); - Ptr insertNotation(const Ptr &); - Ptr removeNotation(const StringC &); - ConstNotationIter notationIter() const; - NotationIter notationIter(); - - size_t allocCurrentAttributeIndex(); - size_t nCurrentAttribute() const; - size_t allocElementDefinitionIndex(); - size_t nElementDefinition() const; - size_t allocAttributeDefinitionListIndex(); - size_t nAttributeDefinitionList() const; - const ElementType *documentElementType() const; - Boolean isBase() const; -private: - Dtd(const Dtd &); // undefined - void operator=(const Dtd &); // undefined - NamedResourceTable generalEntityTable_; - NamedResourceTable parameterEntityTable_; - ConstPtr defaultEntity_; - ConstPtr > name_; - NamedTable elementTypeTable_; - NamedTable rankStemTable_; - NamedTable shortReferenceMapTable_; - NamedResourceTable notationTable_; - size_t nCurrentAttribute_; - size_t nElementDefinition_; - size_t nAttributeDefinitionList_; - ElementType *documentElementType_; - Vector shortrefs_; - HashTable shortrefTable_; - Boolean isBase_; -}; - -inline -ConstPtr Dtd::lookupEntity(Boolean isParameter, const StringC &name) - const -{ - return (isParameter - ? ¶meterEntityTable_ - : &generalEntityTable_)->lookupConst(name); -} - -inline -const Entity *Dtd::lookupEntityTemp(Boolean isParameter, const StringC &name) - const -{ - return (isParameter - ? ¶meterEntityTable_ - : &generalEntityTable_)->lookupTemp(name); -} - -inline -Ptr Dtd::lookupEntity(Boolean isParameter, const StringC &name) -{ - return (isParameter - ? ¶meterEntityTable_ - : &generalEntityTable_)->lookup(name); -} - -inline -Ptr -Dtd::insertEntity(const Ptr &entity, Boolean replace) -{ - return (entity->declType() == Entity::parameterEntity - ? ¶meterEntityTable_ - : &generalEntityTable_)->insert(entity, replace); -} - -inline -Ptr Dtd::removeEntity(Boolean isParameter, const StringC &name) -{ - return (isParameter - ? ¶meterEntityTable_ - : &generalEntityTable_)->remove(name); -} - -inline -Dtd::ConstEntityIter Dtd::generalEntityIter() const -{ - // Avoid use of typedef to work around MSVC 2.0 bug. - return ConstNamedResourceTableIter(generalEntityTable_); -} - -inline -Dtd::EntityIter Dtd::generalEntityIter() -{ - // Avoid use of typedef to work around MSVC 2.0 bug. - return NamedResourceTableIter(generalEntityTable_); -} - -inline -Dtd::ConstEntityIter Dtd::parameterEntityIter() const -{ - // Avoid use of typedef to work around MSVC 2.0 bug. - return ConstNamedResourceTableIter(parameterEntityTable_); -} - -inline -Dtd::EntityIter Dtd::parameterEntityIter() -{ - // Avoid use of typedef to work around MSVC 2.0 bug. - return NamedResourceTableIter(parameterEntityTable_); -} - -inline -ConstPtr Dtd::defaultEntity() const -{ - return defaultEntity_; -} - -inline -const Entity *Dtd::defaultEntityTemp() const -{ - return defaultEntity_.pointer(); -} - -inline -const ConstPtr > &Dtd::namePointer() const -{ - return name_; -} - -inline -const StringC &Dtd::name() const -{ - return *name_; -} - -inline -size_t Dtd::allocCurrentAttributeIndex() -{ - return nCurrentAttribute_++; -} - -inline -size_t Dtd::nCurrentAttribute() const -{ - return nCurrentAttribute_; -} - -inline -size_t Dtd::allocElementDefinitionIndex() -{ - return nElementDefinition_++; -} - -inline -size_t Dtd::nElementDefinition() const -{ - return nElementDefinition_; -} - -inline -size_t Dtd::allocAttributeDefinitionListIndex() -{ - return nAttributeDefinitionList_++; -} - -inline -size_t Dtd::nAttributeDefinitionList() const -{ - return nAttributeDefinitionList_; -} - -inline -const ElementType *Dtd::lookupElementType(const StringC &name) const -{ - return elementTypeTable_.lookup(name); -} - -inline -ElementType *Dtd::lookupElementType(const StringC &name) -{ - return elementTypeTable_.lookup(name); -} - -inline -ElementType *Dtd::insertElementType(ElementType *e) -{ - return elementTypeTable_.insert(e); -} - -inline -Dtd::ElementTypeIter Dtd::elementTypeIter() -{ - // Avoid use of typedef to work around MSVC 2.0 bug. - return NamedTableIter(elementTypeTable_); -} - -inline -Dtd::ConstElementTypeIter Dtd::elementTypeIter() const -{ - // Avoid use of typedef to work around MSVC 2.0 bug. - return ConstNamedTableIter(elementTypeTable_); -} - -inline -ElementType *Dtd::removeElementType(const StringC &name) -{ - return elementTypeTable_.remove(name); -} - -inline -size_t Dtd::nElementTypeIndex() const -{ - // index 0 is reserved for #pcdata - return 1 + elementTypeTable_.count(); -} - -inline -const RankStem *Dtd::lookupRankStem(const StringC &name) const -{ - return rankStemTable_.lookup(name); -} - -inline -RankStem *Dtd::lookupRankStem(const StringC &name) -{ - return rankStemTable_.lookup(name); -} - -inline -RankStem *Dtd::insertRankStem(RankStem *e) -{ - return rankStemTable_.insert(e); -} - -inline -size_t Dtd::nRankStem() const -{ - return rankStemTable_.count(); -} - -inline -ConstPtr Dtd::lookupNotation(const StringC &name) const -{ - return notationTable_.lookupConst(name); -} - -inline -const Notation *Dtd::lookupNotationTemp(const StringC &name) const -{ - return notationTable_.lookupTemp(name); -} - -inline -Ptr Dtd::lookupNotation(const StringC &name) -{ - return notationTable_.lookup(name); -} - -inline -Ptr Dtd::insertNotation(const Ptr &nt) -{ - return notationTable_.insert(nt); -} - -inline -Dtd::ConstNotationIter Dtd::notationIter() const -{ - // Avoid use of typedef to work around MSVC 2.0 bug. - return ConstNamedResourceTableIter(notationTable_); -} - -inline -Dtd::NotationIter Dtd::notationIter() -{ - // Avoid use of typedef to work around MSVC 2.0 bug. - return NamedResourceTableIter(notationTable_); -} - -inline -Ptr Dtd::removeNotation(const StringC &name) -{ - return notationTable_.remove(name); -} - -inline -const ElementType *Dtd::documentElementType() const -{ - return documentElementType_; -} - -inline -const ShortReferenceMap *Dtd::lookupShortReferenceMap(const StringC &name) const -{ - return shortReferenceMapTable_.lookup(name); -} - -inline -ShortReferenceMap *Dtd::lookupShortReferenceMap(const StringC &name) -{ - return shortReferenceMapTable_.lookup(name); -} - -inline -ShortReferenceMap *Dtd::insertShortReferenceMap(ShortReferenceMap *map) -{ - return shortReferenceMapTable_.insert(map); -} - -inline -Dtd::ShortReferenceMapIter Dtd::shortReferenceMapIter() -{ - // Avoid use of typedef to work around MSVC 2.0 bug. - return NamedTableIter(shortReferenceMapTable_); -} - -inline -Boolean Dtd::isBase() const -{ - return isBase_; -} - -inline -size_t Dtd::nShortref() const -{ - return shortrefs_.size(); -} - -inline -const StringC &Dtd::shortref(size_t i) const -{ - return shortrefs_[i]; -} - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* not Dtd_INCLUDED */ diff --git a/cde/programs/nsgmls/EUCJPCodingSystem.C b/cde/programs/nsgmls/EUCJPCodingSystem.C deleted file mode 100644 index 6c46ecfd6..000000000 --- a/cde/programs/nsgmls/EUCJPCodingSystem.C +++ /dev/null @@ -1,144 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: EUCJPCodingSystem.C /main/1 1996/07/29 16:49:22 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#include "splib.h" - -#ifdef SP_MULTI_BYTE - -#include "EUCJPCodingSystem.h" -#if defined(__linux__) || defined(CSRG_BASED) || defined(sun) -#include -#else -#include -#endif - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -class EUCJPDecoder : public Decoder { -public: - EUCJPDecoder() { } - size_t decode(Char *, const char *, size_t, const char **); -private: -}; - -class EUCJPEncoder : public Encoder { -public: - EUCJPEncoder() { } - void output(const Char *, size_t, streambuf *); -}; - -Decoder *EUCJPCodingSystem::makeDecoder() const -{ - return new EUCJPDecoder; -} - -Encoder *EUCJPCodingSystem::makeEncoder() const -{ - return new EUCJPEncoder; -} - -size_t EUCJPDecoder::decode(Char *to, const char *s, - size_t slen, const char **rest) -{ - Char *start = to; - const unsigned char *us = (const unsigned char *)s; - while (slen > 0) { - if (!(*us & 0x80)) { - // G0 - *to++ = *us++; - slen--; - } - else if (*us == 0x8e) { - // G2 - if (slen < 2) - break; - slen -= 2; - ++us; - *to++ = *us++ | 0x80; - } - else if (*us == 0x8f) { - // G3 - if (slen < 3) - break; - slen -= 3; - ++us; - unsigned short n = (*us++ | 0x80) << 8; - n |= (*us++ & ~0x80); - *to++ = n; - } - else { - // G1 - if (slen < 2) - break; - slen -= 2; - unsigned short n = *us++ << 8; - n |= (*us++ | 0x80); - *to++ = n; - } - } - *rest = (const char *)us; - return to - start; -} - -// FIXME handle errors from streambuf::sputc - -void EUCJPEncoder::output(const Char *s, size_t n, streambuf *sb) -{ - for (; n > 0; s++, n--) { - Char c = *s; - unsigned short mask = (unsigned short)(c & 0x8080); - if (mask == 0) - sb->sputc(char(c & 0xff)); - else if (mask == 0x8080) { - sb->sputc(char((c >> 8) & 0xff)); - sb->sputc(char(c & 0xff)); - } - else if (mask == 0x0080) { - sb->sputc(0x8e); - sb->sputc(char(c & 0xff)); - } - else { - // mask == 0x8000 - sb->sputc(0x8f); - sb->sputc(char((c >> 8) & 0xff)); - sb->sputc(char(c & 0x7f)); - } - } -} - -#ifdef SP_NAMESPACE -} -#endif - -#else /* not SP_MULTI_BYTE */ - -#ifndef __GNUG__ -static char non_empty_translation_unit; // sigh -#endif - -#endif /* not SP_MULTI_BYTE */ diff --git a/cde/programs/nsgmls/EUCJPCodingSystem.h b/cde/programs/nsgmls/EUCJPCodingSystem.h deleted file mode 100644 index 85726c5cc..000000000 --- a/cde/programs/nsgmls/EUCJPCodingSystem.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: EUCJPCodingSystem.h /main/1 1996/07/29 16:49:28 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#ifndef EUCJPCodingSystem_INCLUDED -#define EUCJPCodingSystem_INCLUDED 1 - -#include "CodingSystem.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -class SP_API EUCJPCodingSystem : public CodingSystem { -public: - Decoder *makeDecoder() const; - Encoder *makeEncoder() const; -}; - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* not EUCJPCodingSystem_INCLUDED */ diff --git a/cde/programs/nsgmls/ElementType.C b/cde/programs/nsgmls/ElementType.C deleted file mode 100644 index 8be38b96d..000000000 --- a/cde/programs/nsgmls/ElementType.C +++ /dev/null @@ -1,133 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: ElementType.C /main/1 1996/07/29 16:49:35 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#ifdef __GNUG__ -#pragma implementation -#endif -#include "splib.h" -#include "ElementType.h" -#include "ContentToken.h" -#include "macros.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -ElementType::ElementType(const StringC &name, size_t index) -: Named(name), index_(index), map_(0), defIndex_(0) -{ -} - -ElementDefinition::ElementDefinition(const Location &location, - size_t index, - unsigned char omitFlags, - DeclaredContent declaredContent) -: location_(location), - index_(index), - omitFlags_(omitFlags), - declaredContent_(declaredContent) -{ - computeMode(); -} - -ElementDefinition::ElementDefinition(const Location &location, - size_t index, - unsigned char omitFlags, - DeclaredContent declaredContent, - Owner &modelGroup) -: location_(location), - index_(index), - omitFlags_(omitFlags), - declaredContent_(declaredContent), - modelGroup_(modelGroup.extract()) -{ - computeMode(); -} - -void ElementDefinition::computeMode() -{ - switch (declaredContent_) { - case modelGroup: - if (!modelGroup_->containsPcdata()) { - netMode_ = econnetMode; - mode_ = econMode; - break; - } - // fall through - case any: - netMode_ = mconnetMode; - mode_ = mconMode; - break; - case cdata: - netMode_ = cconnetMode; - mode_ = cconMode; - break; - case rcdata: - netMode_ = rcconnetMode; - mode_ = rcconMode; - break; - case empty: - break; - default: - CANNOT_HAPPEN(); - } -} - -void ElementType::swap(ElementType &to) -{ - Named::swap(to); - { - size_t tem = to.index_; - to.index_ = index_; - index_ = tem; - } - { - size_t tem = to.defIndex_; - to.defIndex_ = defIndex_; - defIndex_ = tem; - } - def_.swap(to.def_); - { - const ShortReferenceMap *tem = to.map_; - to.map_ = map_; - map_ = tem; - } -} - -RankStem::RankStem(const StringC &name, size_t index) -: Named(name), index_(index) -{ -} - -void RankStem::addDefinition(const ConstPtr &p) -{ - def_.push_back(p); -} - - -#ifdef SP_NAMESPACE -} -#endif diff --git a/cde/programs/nsgmls/ElementType.h b/cde/programs/nsgmls/ElementType.h deleted file mode 100644 index b9e192896..000000000 --- a/cde/programs/nsgmls/ElementType.h +++ /dev/null @@ -1,318 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: ElementType.h /main/1 1996/07/29 16:49:41 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#ifndef ElementType_INCLUDED -#define ElementType_INCLUDED 1 -#ifdef __GNUG__ -#pragma interface -#endif - -#include -#include "Boolean.h" -#include "Vector.h" -#include "Owner.h" -#include "Location.h" -#include "Ptr.h" -#include "Named.h" -#include "Vector.h" -#include "Attributed.h" -#include "Mode.h" -#include "ContentToken.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -class ElementType; -class ShortReferenceMap; -class RankStem; - -class SP_API ElementDefinition : public Resource { -public: - enum DeclaredContent { modelGroup, any, cdata, rcdata, empty }; - enum OmitFlags { omitStart = 01, omitEnd = 02, omitSpec = 04 }; - enum { undefinedIndex = -1 }; - ElementDefinition(const Location &location, - size_t index, - unsigned char omitFlags, - DeclaredContent declaredContent); - ElementDefinition(const Location &location, - size_t index, - unsigned char omitFlags, - DeclaredContent declaredContent, - Owner &modelGroup); - const CompiledModelGroup *compiledModelGroup() const; - DeclaredContent declaredContent() const; - // Was the omitted tag minimization specified? - Boolean omittedTagSpec() const; - Boolean canOmitStartTag() const; - Boolean canOmitEndTag() const; - size_t nRankStems() const; - const RankStem *rankStem(size_t i) const; - const StringC &rankSuffix() const; - size_t nInclusions() const; - const ElementType *inclusion(size_t) const; - size_t nExclusions() const; - const ElementType *exclusion(size_t) const; - Boolean undefined() const; - void setInclusions(Vector &inclusions); - void setExclusions(Vector &exclusions); - void setRank(StringC &suffix, Vector &rankStems); - Mode mode(Boolean netEnabled) const; -private: - ElementDefinition(const ElementDefinition &); // undefined - void operator=(const ElementDefinition &); // undefined - void computeMode(); - - Location location_; - size_t index_; - unsigned char omitFlags_; - DeclaredContent declaredContent_; - Owner modelGroup_; - Vector inclusions_; - Vector exclusions_; - // rankStems_ contains all the rank stems in the ranked group in this - // definition. - Vector rankStems_; - StringC rankSuffix_; - Mode mode_; - Mode netMode_; -}; - -class SP_API RankStem : public Named { -public: - RankStem(const StringC &, size_t); - size_t index() const; - void addDefinition(const ConstPtr &); - size_t nDefinitions() const; - const ElementDefinition *definition(size_t) const; -private: - RankStem(const RankStem &); // undefined - void operator=(const RankStem &); // undefined - size_t index_; - Vector > def_; -}; - -class SP_API ElementType : public Named, public Attributed { -public: - ElementType(const StringC &, size_t); - void setElementDefinition(const ConstPtr &, - size_t defIndex); - void setMap(const ShortReferenceMap *); - void setRankStem(RankStem *); - Boolean undefined() const; - const ElementDefinition *definition() const; - Boolean isRankedElement() const; - const RankStem *rankedElementRankStem() const; - size_t index() const; - const ShortReferenceMap *map() const; - void swap(ElementType &); -private: - ElementType(const ElementType &); // undefined - void operator=(const ElementType &); // undefined - size_t index_; - size_t defIndex_; // index in the group having same definition - ConstPtr def_; - const ShortReferenceMap *map_; -}; - -inline -const CompiledModelGroup *ElementDefinition::compiledModelGroup() const -{ - return modelGroup_.pointer(); -} - -inline -ElementDefinition::DeclaredContent ElementDefinition::declaredContent() const -{ - return declaredContent_; -} - -inline -Boolean ElementDefinition::canOmitStartTag() const -{ - return (omitFlags_ & omitStart) != 0; -} - -inline -Boolean ElementDefinition::canOmitEndTag() const -{ - return (omitFlags_ & omitEnd) != 0; -} - -inline -Boolean ElementDefinition::omittedTagSpec() const -{ - return (omitFlags_ & omitSpec) != 0; -} - -inline -size_t ElementDefinition::nRankStems() const -{ - return rankStems_.size(); -} - -inline -const StringC &ElementDefinition::rankSuffix() const -{ - return rankSuffix_; -} - -inline -const RankStem *ElementDefinition::rankStem(size_t i) const -{ - return rankStems_[i]; -} - -inline -const ElementType *ElementDefinition::inclusion(size_t i) const -{ - return inclusions_[i]; -} - -inline -size_t ElementDefinition::nInclusions() const -{ - return inclusions_.size(); -} - -inline -const ElementType *ElementDefinition::exclusion(size_t i) const -{ - return exclusions_[i]; -} - -inline -size_t ElementDefinition::nExclusions() const -{ - return exclusions_.size(); -} - -inline -Boolean ElementDefinition::undefined() const -{ - return index_ == size_t(undefinedIndex); -} - -inline -void ElementDefinition::setInclusions(Vector &inclusions) -{ - inclusions.swap(inclusions_); -} - -inline -void ElementDefinition::setExclusions(Vector &exclusions) -{ - exclusions.swap(exclusions_); -} - -inline -void ElementDefinition::setRank(StringC &rankSuffix, - Vector &rankStems) -{ - rankStems.swap(rankStems_); - rankSuffix.swap(rankSuffix_); -} - -inline -Boolean ElementType::undefined() const -{ - return def_->undefined(); -} - -inline -Boolean ElementType::isRankedElement() const -{ - return def_->nRankStems() > 0; -} - -inline -const ElementDefinition *ElementType::definition() const -{ - return def_.pointer(); -} - -inline -void ElementType::setElementDefinition(const ConstPtr &def, - size_t defIndex) -{ - def_ = def; - defIndex_ = defIndex; -} - -inline -size_t ElementType::index() const -{ - return index_; -} - -inline -const RankStem *ElementType::rankedElementRankStem() const -{ - return def_->rankStem(defIndex_); -} - -inline -void ElementType::setMap(const ShortReferenceMap *map) -{ - map_ = map; -} - -inline -const ShortReferenceMap *ElementType::map() const -{ - return map_; -} - -inline -size_t RankStem::index() const -{ - return index_; -} - -inline -size_t RankStem::nDefinitions() const -{ - return def_.size(); -} - -inline -const ElementDefinition *RankStem::definition(size_t i) const -{ - return def_[i].pointer(); -} - -inline -Mode ElementDefinition::mode(Boolean netEnabled) const -{ - return netEnabled ? netMode_ : mode_; -} - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* not ElementType_INCLUDED */ diff --git a/cde/programs/nsgmls/Entity.C b/cde/programs/nsgmls/Entity.C deleted file mode 100644 index edc99e912..000000000 --- a/cde/programs/nsgmls/Entity.C +++ /dev/null @@ -1,670 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: Entity.C /main/1 1996/07/29 16:49:46 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#ifdef __GNUG__ -#pragma implementation -#endif -#include "splib.h" -#include "Entity.h" -#include "ParserState.h" -#include "macros.h" -#include "InternalInputSource.h" -#include "MessageArg.h" -#include "ParserMessages.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -Entity::Entity(const StringC &name, DeclType declType, DataType dataType, - const Location &defLocation) -: EntityDecl(name, declType, dataType, defLocation), - used_(0), defaulted_(0) -{ -} - -void Entity::generateSystemId(ParserState &) -{ -} - -InternalEntity::InternalEntity(const StringC &name, - DeclType declType, - DataType dataType, - const Location &defLocation, - Text &text) -: Entity(name, declType, dataType, defLocation) -{ - text.swap(text_); -} - -PiEntity::PiEntity(const StringC &name, DeclType declType, - const Location &defLocation, Text &text) -: InternalEntity(name, declType, pi, defLocation, text) -{ -} - -Entity *PiEntity::copy() const -{ - return new PiEntity(*this); -} - -InternalDataEntity::InternalDataEntity(const StringC &name, DataType dataType, - const Location &defLocation, Text &text) -: InternalEntity(name, generalEntity, dataType, defLocation, text) -{ -} - - -InternalCdataEntity::InternalCdataEntity(const StringC &name, - const Location &defLocation, - Text &text) -: InternalDataEntity(name, cdata, defLocation, text) -{ -} - -Entity *InternalCdataEntity::copy() const -{ - return new InternalCdataEntity(*this); -} - -InternalSdataEntity::InternalSdataEntity(const StringC &name, - const Location &defLocation, - Text &text) -: InternalDataEntity(name, sdata, defLocation, text) -{ -} - -Entity *InternalSdataEntity::copy() const -{ - return new InternalSdataEntity(*this); -} - -InternalTextEntity::InternalTextEntity(const StringC &name, DeclType declType, - const Location &defLocation, Text &text, - Bracketed bracketed) -: InternalEntity(name, declType, sgmlText, defLocation, text), - bracketed_(bracketed) -{ -} - -Entity *InternalTextEntity::copy() const -{ - return new InternalTextEntity(*this); -} - - -ExternalEntity::ExternalEntity(const StringC &name, - DeclType declType, - DataType dataType, - const Location &defLocation, - const ExternalId &id) -: Entity(name, declType, dataType, defLocation), externalId_(id) -{ -} - -const ExternalEntity *ExternalEntity::asExternalEntity() const -{ - return this; -} - -const StringC *ExternalEntity::systemIdPointer() const -{ - return externalId_.systemIdString(); -} - -const StringC *ExternalEntity::effectiveSystemIdPointer() const -{ - if (externalId_.effectiveSystemId().size() > 0) - return &externalId_.effectiveSystemId(); - return 0; -} - -const StringC *ExternalEntity::publicIdPointer() const -{ - return externalId_.publicIdString(); -} - -void ExternalEntity::generateSystemId(ParserState &parser) -{ - StringC str; - if (parser.entityCatalog().lookup(*this, - parser.syntax(), - parser.sd().docCharset(), - parser.messenger(), - str)) - externalId_.setEffectiveSystem(str); - else if (externalId_.publicIdString()) - parser.message(ParserMessages::cannotGenerateSystemIdPublic, - StringMessageArg(*externalId_.publicIdString())); - else { - switch (declType()) { - case generalEntity: - parser.message(ParserMessages::cannotGenerateSystemIdGeneral, - StringMessageArg(name())); - break; - case parameterEntity: - parser.message(ParserMessages::cannotGenerateSystemIdParameter, - StringMessageArg(name())); - break; - case doctype: - parser.message(ParserMessages::cannotGenerateSystemIdDoctype, - StringMessageArg(name())); - break; - case linktype: - parser.message(ParserMessages::cannotGenerateSystemIdLinktype, - StringMessageArg(name())); - break; - default: - CANNOT_HAPPEN(); - } - } -} - -ExternalTextEntity::ExternalTextEntity(const StringC &name, - DeclType declType, - const Location &defLocation, - const ExternalId &id) -: ExternalEntity(name, declType, sgmlText, defLocation, id) -{ -} - -Entity *ExternalTextEntity::copy() const -{ - return new ExternalTextEntity(*this); -} - -ExternalNonTextEntity::ExternalNonTextEntity(const StringC &name, - DataType dataType, - const Location &defLocation, - const ExternalId &id) -: ExternalEntity(name, generalEntity, dataType, defLocation, id) -{ -} - -ExternalDataEntity::ExternalDataEntity(const StringC &name, - DataType dataType, - const Location &defLocation, - const ExternalId &id, - const ConstPtr &nt, - - AttributeList &attributes) -: ExternalNonTextEntity(name, dataType, defLocation, id), - notation_(nt) -{ - attributes.swap(attributes_); -} - -void ExternalDataEntity::setNotation(const ConstPtr ¬ation, - AttributeList &attributes) -{ - notation_ = notation; - attributes.swap(attributes_); -} - -Entity *ExternalDataEntity::copy() const -{ - return new ExternalDataEntity(*this); -} - -SubdocEntity::SubdocEntity(const StringC &name, - const Location &defLocation, - const ExternalId &id) -: ExternalNonTextEntity(name, subdoc, defLocation, id) -{ -} - -Entity *SubdocEntity::copy() const -{ - return new SubdocEntity(*this); -} - -Boolean Entity::isDataOrSubdoc() const -{ - return 0; -} - -Boolean Entity::isCharacterData() const -{ - return 0; -} - -const ExternalEntity *Entity::asExternalEntity() const -{ - return 0; -} - -const ExternalDataEntity *Entity::asExternalDataEntity() const -{ - return 0; -} - -const SubdocEntity *Entity::asSubdocEntity() const -{ - return 0; -} - -const InternalEntity *Entity::asInternalEntity() const -{ - return 0; -} - -void Entity::dsReference(ParserState &parser, - const Ptr &origin) - const -{ - normalReference(parser, origin, 1); -} - -void Entity::declReference(ParserState &parser, - const Ptr &origin) - const -{ - normalReference(parser, origin, 0); - if (parser.currentMarkup()) - parser.currentMarkup()->addEntityStart(origin); -} - -void Entity::contentReference(ParserState &parser, - const Ptr &origin) - const -{ - normalReference(parser, origin, 1); -} - -void Entity::rcdataReference(ParserState &parser, - const Ptr &origin) - const -{ - normalReference(parser, origin, 1); -} - -void Entity::litReference(Text &, ParserState &parser, - const Ptr &origin, - Boolean) - const -{ - normalReference(parser, origin, 0); -} - -const InternalEntity *InternalEntity::asInternalEntity() const -{ - return this; -} - -void PiEntity::litReference(Text &, ParserState &parser, - const Ptr &, - Boolean) const -{ - parser.message(ParserMessages::piEntityReference); -} - -void PiEntity::normalReference(ParserState &parser, - const Ptr &origin, - Boolean) const -{ - parser.noteMarkup(); - parser.eventHandler().pi(new (parser.eventAllocator()) - PiEntityEvent(this, origin.pointer())); -} - -void PiEntity::declReference(ParserState &parser, - const Ptr &) const -{ - parser.message(ParserMessages::piEntityReference); -} - -void PiEntity::rcdataReference(ParserState &parser, - const Ptr &) const -{ - parser.message(ParserMessages::piEntityRcdata); -} - -void InternalDataEntity::declReference(ParserState &parser, - const Ptr &) const -{ - parser.message(ParserMessages::internalDataEntityReference); -} - -Boolean InternalDataEntity::isDataOrSubdoc() const -{ - return 1; -} - -void InternalCdataEntity::normalReference(ParserState &parser, - const Ptr &origin, - Boolean) const -{ - checkEntlvl(parser); - if (string().size() > 0) { - parser.noteData(); - parser.eventHandler().data(new (parser.eventAllocator()) - CdataEntityEvent(this, origin.pointer())); - } -} - -Boolean InternalCdataEntity::isCharacterData() const -{ - return string().size() > 0; -} - -void InternalCdataEntity::litReference(Text &text, - ParserState &parser, - const Ptr &origin, - Boolean squeeze) const -{ - checkEntlvl(parser); - if (squeeze) { - Location loc(origin.pointer(), 0); - text.addEntityStart(loc); - text.addCharsTokenize(text_.string(), loc, parser.syntax().space()); - loc += text_.size(); - text.addEntityEnd(loc); - } - else - text.addCdata(this, origin.pointer()); -} - - -void InternalSdataEntity::normalReference(ParserState &parser, - const Ptr &origin, - Boolean) const -{ - checkEntlvl(parser); - parser.noteData(); - parser.eventHandler().sdataEntity(new (parser.eventAllocator()) - SdataEntityEvent(this, - origin.pointer())); -} - -Boolean InternalSdataEntity::isCharacterData() const -{ - return 1; -} - -void InternalSdataEntity::litReference(Text &text, - ParserState &parser, - const Ptr &origin, - Boolean squeeze) const -{ - checkEntlvl(parser); - if (squeeze) { - Location loc(origin.pointer(), 0); - text.addEntityStart(loc); - text.addCharsTokenize(text_.string(), loc, parser.syntax().space()); - loc += text_.size(); - text.addEntityEnd(loc); - } - else - text.addSdata(this, origin.pointer()); -} - -void InternalTextEntity::normalReference(ParserState &parser, - const Ptr &origin, - Boolean generateEvent) const -{ - checkEntlvl(parser); - if (checkNotOpen(parser)) { - if (generateEvent && parser.wantMarkup()) - parser.eventHandler().entityStart(new (parser.eventAllocator()) - EntityStartEvent(origin)); - parser.pushInput(new (parser.internalAllocator()) - InternalInputSource(text_.string(), origin.pointer())); - } -} - -void InternalTextEntity::litReference(Text &text, - ParserState &parser, - const Ptr &origin, - Boolean) const -{ - text.addEntityStart(Location(origin.pointer(), 0)); - normalReference(parser, origin, 0); -} - -void ExternalTextEntity::normalReference(ParserState &parser, - const Ptr &origin, - Boolean generateEvent) const -{ - checkEntlvl(parser); - if (checkNotOpen(parser)) { - if (generateEvent && parser.wantMarkup()) - parser.eventHandler().entityStart(new (parser.eventAllocator()) - EntityStartEvent(origin)); - if (externalId().effectiveSystemId().size()) - parser.pushInput(parser.entityManager() - .open(externalId().effectiveSystemId(), - parser.sd().docCharset(), - origin.pointer(), - 0, - parser.messenger())); - else - parser.message(ParserMessages::nonExistentEntityRef, - StringMessageArg(name()), - defLocation()); - } -} - -void ExternalTextEntity::litReference(Text &text, - ParserState &parser, - const Ptr &origin, - Boolean) const -{ - text.addEntityStart(Location(origin.pointer(), 0)); - normalReference(parser, origin, 0); -} - -const ExternalDataEntity *ExternalDataEntity::asExternalDataEntity() const -{ - return this; -} - -void ExternalDataEntity::contentReference(ParserState &parser, - const Ptr &origin) const -{ - checkEntlvl(parser); - parser.noteData(); - parser.eventHandler().externalDataEntity(new (parser.eventAllocator()) - ExternalDataEntityEvent(this, origin.pointer())); -} - -Boolean ExternalNonTextEntity::isDataOrSubdoc() const -{ - return 1; -} - -Boolean ExternalNonTextEntity::isCharacterData() const -{ - return 1; -} - - -void ExternalNonTextEntity::normalReference(ParserState &parser, - const Ptr &, - Boolean) const -{ - parser.message(ParserMessages::externalNonTextEntityReference); -} - -void ExternalNonTextEntity::litReference(Text &, - ParserState &parser, - const Ptr &, - Boolean) const -{ - parser.message(ParserMessages::externalNonTextEntityRcdata); -} - -void ExternalNonTextEntity::rcdataReference(ParserState &parser, - const Ptr &) const -{ - parser.message(ParserMessages::externalNonTextEntityRcdata); -} - -void SubdocEntity::contentReference(ParserState &parser, - const Ptr &origin) const -{ - checkEntlvl(parser); - parser.noteData(); - parser.eventHandler().subdocEntity(new (parser.eventAllocator()) - SubdocEntityEvent(this, origin.pointer())); -} - -const SubdocEntity *SubdocEntity::asSubdocEntity() const -{ - return this; -} - -IgnoredEntity::IgnoredEntity(const StringC &name, DeclType declType) -: Entity(name, declType, sgmlText, Location()) -{ -} - -Entity *IgnoredEntity::copy() const -{ - return new IgnoredEntity(*this); -} - -void IgnoredEntity::declReference(ParserState &parser, - const Ptr &origin) - const -{ - if (parser.currentMarkup()) { - parser.currentMarkup()->addEntityStart(origin); - parser.currentMarkup()->addEntityEnd(); - } -} - -void IgnoredEntity::litReference(Text &text, - ParserState &, - const Ptr &origin, - Boolean) const -{ - text.addEntityStart(Location(origin.pointer(), 0)); - text.addEntityEnd(Location(origin.pointer(), 0)); -} - -void IgnoredEntity::normalReference(ParserState &parser, - const Ptr &origin, - Boolean generateEvent) const -{ - if (generateEvent && parser.wantMarkup()) { - parser.eventHandler().entityStart(new (parser.eventAllocator()) - EntityStartEvent(origin)); - Location loc(origin.pointer(), 0); - parser.eventHandler().entityEnd(new (parser.eventAllocator()) - EntityEndEvent(loc)); - } -} - -void Entity::checkEntlvl(ParserState &parser) -{ - // -1 because document entity isn't counted - if (parser.inputLevel() - 1 == parser.syntax().entlvl()) - parser.message(ParserMessages::entlvl); -} - -Boolean Entity::checkNotOpen(ParserState &parser) const -{ - if (parser.entityIsOpen(this)) { - parser.message(ParserMessages::recursiveEntityReference, - StringMessageArg(name())); - return 0; - } - return 1; -} - -EntityOrigin::EntityOrigin() -: refLength_(0) -{ -} - -EntityOrigin::EntityOrigin(const Location &refLocation) -: InputSourceOrigin(refLocation), refLength_(0) -{ -} - -EntityOrigin::EntityOrigin(const ConstPtr &entity, - const Location &refLocation) -: InputSourceOrigin(refLocation), refLength_(0), entity_(entity) -{ -} - -EntityOrigin::EntityOrigin(const ConstPtr &entity, - const Location &refLocation, - Index refLength, - Owner &markup) -: InputSourceOrigin(refLocation), refLength_(refLength), entity_(entity) -{ - markup.swap(markup_); -} - -EntityOrigin::~EntityOrigin() -{ -} - -InputSourceOrigin *EntityOrigin::copy() const -{ - Owner m; - if (markup_) - m = new Markup(*markup_); - return new EntityOrigin(entity_, parent(), refLength_, m); -} - -const StringC *EntityOrigin::entityName() const -{ - if (entity_.isNull()) - return 0; - return entity_->namePointer(); -} - -Index EntityOrigin::refLength() const -{ - return refLength_; -} - -const EntityOrigin *EntityOrigin::asEntityOrigin() const -{ - return this; -} - -Boolean EntityOrigin::defLocation(Offset off, Location &loc) const -{ - if (entity_.isNull()) - return 0; - const InternalEntity *internal = entity_->asInternalEntity(); - if (!internal) - return 0; - loc = internal->text().charLocation(off); - return 1; -} - -const EntityDecl *EntityOrigin::entityDecl() const -{ - return entity_.pointer(); -} - -#ifdef SP_NAMESPACE -} -#endif diff --git a/cde/programs/nsgmls/Entity.h b/cde/programs/nsgmls/Entity.h deleted file mode 100644 index a878af4d1..000000000 --- a/cde/programs/nsgmls/Entity.h +++ /dev/null @@ -1,383 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: Entity.h /main/1 1996/07/29 16:49:52 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#ifndef Entity_INCLUDED -#define Entity_INCLUDED 1 -#ifdef __GNUG__ -#pragma interface -#endif - -#include "types.h" -#include "StringC.h" -#include "NamedResource.h" -#include "Location.h" -#include "Owner.h" -#include "Attribute.h" -#include "ExternalId.h" -#include "Text.h" -#include "SubstTable.h" -#include "StringResource.h" -#include "Allocator.h" -#include "EntityDecl.h" -#include "Markup.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -class Messenger; -class InputSource; -class EntityOrigin; -class ParserState; -class ExternalEntity; -class ExternalDataEntity; -class SubdocEntity; -class InternalEntity; -class Notation; - -class Entity : public EntityDecl { -public: - Entity(const StringC &name, DeclType declType, DataType dataType, - const Location &defLocation); - // reference in a literal - virtual void litReference(Text &, ParserState &, - const Ptr &, - Boolean squeezeSpaces) - const; - // reference in a declaration - virtual void declReference(ParserState &, - const Ptr &) - const; - // reference in a declaration subset - virtual void dsReference(ParserState &, - const Ptr &) - const; - // reference in content - virtual void contentReference(ParserState &, - const Ptr &) - const; - // reference in rcdata - virtual void rcdataReference(ParserState &, - const Ptr &) - const; - // for entity name attribute checking - virtual Boolean isDataOrSubdoc() const; - // for determining whether we need to validate as character data - virtual Boolean isCharacterData() const; - virtual const ExternalDataEntity *asExternalDataEntity() const; - virtual const SubdocEntity *asSubdocEntity() const; - virtual const InternalEntity *asInternalEntity() const; - virtual const ExternalEntity *asExternalEntity() const; - // needed for default entity - virtual Entity *copy() const = 0; - virtual void generateSystemId(ParserState &); - void setUsed(); - Boolean used() const; - void setDefaulted(); - Boolean defaulted() const; -protected: - static void checkEntlvl(ParserState &); - Boolean checkNotOpen(ParserState &) const; -private: - virtual void normalReference(ParserState &, - const Ptr &, - Boolean generateEvent) const = 0; - PackedBoolean used_; - PackedBoolean defaulted_; -}; - -class InternalEntity : public Entity { -public: - InternalEntity(const StringC &, DeclType declType, DataType dataType, - const Location &, Text &); - const StringC &string() const; - const Text &text() const; - const InternalEntity *asInternalEntity() const; -protected: - Text text_; -}; - -class PiEntity : public InternalEntity { -public: - PiEntity(const StringC &, DeclType, const Location &, Text &); - void litReference(Text &, ParserState &, - const Ptr &, - Boolean) const; - void normalReference(ParserState &, - const Ptr &, - Boolean) const; - void declReference(ParserState &, - const Ptr &) const; - void rcdataReference(ParserState &, - const Ptr &) const; - Entity *copy() const; -}; - -class InternalDataEntity : public InternalEntity { -public: - InternalDataEntity(const StringC &, DataType, const Location &, Text &); - void declReference(ParserState &, - const Ptr &) const; - Boolean isDataOrSubdoc() const; -}; - -class InternalCdataEntity : public InternalDataEntity { -public: - InternalCdataEntity(const StringC &, const Location &, Text &); - void normalReference(ParserState &, - const Ptr &, - Boolean) const; - void litReference(Text &, ParserState &, - const Ptr &, - Boolean) const; - Entity *copy() const; - Boolean isCharacterData() const; -}; - -class InternalSdataEntity : public InternalDataEntity { -public: - InternalSdataEntity(const StringC &, const Location &, Text &); - void normalReference(ParserState &, - const Ptr &, - Boolean) const; - void litReference(Text &, ParserState &, - const Ptr &, - Boolean) const; - Entity *copy() const; - Boolean isCharacterData() const; -}; - -class InternalTextEntity : public InternalEntity { -public: - enum Bracketed { - none, - starttag, - endtag, - ms, - md - }; - InternalTextEntity(const StringC &, DeclType, const Location &, Text &, - Bracketed); - Entity *copy() const; -private: - void normalReference(ParserState &, - const Ptr &, - Boolean) const; - void litReference(Text &, ParserState &, - const Ptr &, - Boolean) const; - Bracketed bracketed_; -}; - -class ExternalEntity : public Entity { -public: - ExternalEntity(const StringC &, DeclType, DataType, const Location &, - const ExternalId &); - const ExternalId &externalId() const; - const ExternalEntity *asExternalEntity() const; - void generateSystemId(ParserState &); - const StringC *systemIdPointer() const; - const StringC *effectiveSystemIdPointer() const; - const StringC *publicIdPointer() const; -private: - ExternalId externalId_; -}; - -class ExternalTextEntity : public ExternalEntity { -public: - ExternalTextEntity(const StringC &, DeclType, const Location &, - const ExternalId &); - Entity *copy() const; -private: - void normalReference(ParserState &, - const Ptr &, - Boolean) const; - void litReference(Text &, ParserState &, - const Ptr &, - Boolean) const; -}; - -class ExternalNonTextEntity : public ExternalEntity { -public: - ExternalNonTextEntity(const StringC &, DataType, - const Location &, const ExternalId &); - Boolean isDataOrSubdoc() const; - void litReference(Text &, ParserState &, - const Ptr &, - Boolean) const; - void rcdataReference(ParserState &, - const Ptr &) const; - void normalReference(ParserState &, - const Ptr &, - Boolean) const; - Boolean isCharacterData() const; -}; - -class ExternalDataEntity : public ExternalNonTextEntity { -public: - ExternalDataEntity(const StringC &, DataType, const Location &, - const ExternalId &, const ConstPtr &, - AttributeList &); - const AttributeList &attributes() const; - const Notation *notation() const; - const ExternalDataEntity *asExternalDataEntity() const; - Entity *copy() const; - void contentReference(ParserState &, - const Ptr &) const; - void setNotation(const ConstPtr &, AttributeList &); -private: - ConstPtr notation_; - AttributeList attributes_; -}; - -class SubdocEntity : public ExternalNonTextEntity { -public: - SubdocEntity(const StringC &, const Location &, const ExternalId &); - const SubdocEntity *asSubdocEntity() const; - Entity *copy() const; - void contentReference(ParserState &, - const Ptr &) const; -private: -}; - -class IgnoredEntity : public Entity { -public: - IgnoredEntity(const StringC &, DeclType declType); - Entity *copy() const; - void litReference(Text &, ParserState &, - const Ptr &, - Boolean squeezeSpaces) const; - void declReference(ParserState &, - const Ptr &) const; -private: - void normalReference(ParserState &, - const Ptr &, - Boolean generateEvent) const; -}; - -class SP_API EntityOrigin : public InputSourceOrigin { -public: - void *operator new(size_t sz, Allocator &alloc) { - return alloc.alloc(sz); - } - void *operator new(size_t sz) { - return Allocator::allocSimple(sz); - } - void operator delete(void *p) { - Allocator::free(p); - } - EntityOrigin(); - EntityOrigin(const Location &refLocation); - EntityOrigin(const ConstPtr &); - EntityOrigin(const ConstPtr &, - const Location &refLocation); - EntityOrigin(const ConstPtr &, - const Location &refLocation, Index refLength, - Owner &markup); - ~EntityOrigin(); - InputSourceOrigin *copy() const; - const ConstPtr &entity() const { return entity_; } - const StringC *entityName() const; - const EntityDecl *entityDecl() const; - const EntityOrigin *asEntityOrigin() const; - Boolean defLocation(Offset off, Location &loc) const; - Index refLength() const; - const Markup *markup() const; -private: - EntityOrigin(const EntityOrigin &); // undefined - void operator=(const EntityOrigin &); // undefined - ConstPtr entity_; // 0 for document entity - // total length of reference - // (characters that were replaced by the entity) - Index refLength_; - Owner markup_; -}; - -inline -Boolean Entity::used() const -{ - return used_; -} - -inline -void Entity::setUsed() -{ - used_ = 1; -} - -inline -Boolean Entity::defaulted() const -{ - return defaulted_; -} - -inline -void Entity::setDefaulted() -{ - defaulted_ = 1; -} - -inline -const StringC &InternalEntity::string() const -{ - return text_.string(); -} - -inline -const Text &InternalEntity::text() const -{ - return text_; -} - -inline -const ExternalId &ExternalEntity::externalId() const -{ - return externalId_; -} - -inline -const AttributeList &ExternalDataEntity::attributes() const -{ - return attributes_; -} - -inline -const Notation *ExternalDataEntity::notation() const -{ - return notation_.pointer(); -} - -inline -const Markup *EntityOrigin::markup() const -{ - return markup_.pointer(); -} - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* not Entity_INCLUDED */ diff --git a/cde/programs/nsgmls/EntityApp.C b/cde/programs/nsgmls/EntityApp.C deleted file mode 100644 index 62101b3af..000000000 --- a/cde/programs/nsgmls/EntityApp.C +++ /dev/null @@ -1,242 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: EntityApp.C /main/1 1996/07/29 16:49:57 cde-hp $ */ -// Copyright (c) 1996 James Clark -// See the file COPYING for copying permission. - -#ifdef __GNUG__ -#pragma implementation -#endif - -#include "splib.h" -#include "EntityApp.h" -#include "sptchar.h" - -#include - -#ifdef SP_MULTI_BYTE -#include "ISO8859InputCodingSystem.h" -#endif - -#include "PosixStorage.h" -#include "URLStorage.h" -#include "LiteralStorage.h" -#include "ExtendEntityManager.h" -#include "SOEntityCatalog.h" -#include "CodingSystem.h" -#include "macros.h" - -#ifndef SGML_SEARCH_PATH_DEFAULT -#define SGML_SEARCH_PATH_DEFAULT SP_T("") -#endif - -#ifndef SGML_CATALOG_FILES_DEFAULT -#define SGML_CATALOG_FILES_DEFAULT SP_T("") -#endif /* not SGML_CATALOG_FILES_DEFAULT */ - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -#ifdef MSDOS_FILENAMES -const Char FILE_SEP = ';'; -#else -const Char FILE_SEP = ':'; -#endif - -#ifdef SP_MULTI_BYTE -static ISO8859InputCodingSystem iso8859_2InputCodingSystem(2); -static ISO8859InputCodingSystem iso8859_3InputCodingSystem(3); -static ISO8859InputCodingSystem iso8859_4InputCodingSystem(4); -static ISO8859InputCodingSystem iso8859_5InputCodingSystem(5); -static ISO8859InputCodingSystem iso8859_6InputCodingSystem(6); -static ISO8859InputCodingSystem iso8859_7InputCodingSystem(7); -static ISO8859InputCodingSystem iso8859_8InputCodingSystem(8); -static ISO8859InputCodingSystem iso8859_9InputCodingSystem(9); - -static struct { - const char *name; - const InputCodingSystem *cs; -} inputCodingSystems[] = { - { "IS8859-2", &iso8859_2InputCodingSystem }, - { "IS8859-3", &iso8859_3InputCodingSystem }, - { "IS8859-4", &iso8859_4InputCodingSystem }, - { "IS8859-5", &iso8859_5InputCodingSystem }, - { "IS8859-6", &iso8859_6InputCodingSystem }, - { "IS8859-7", &iso8859_7InputCodingSystem }, - { "IS8859-8", &iso8859_8InputCodingSystem }, - { "IS8859-9", &iso8859_9InputCodingSystem }, -}; - -#endif /* SP_MULTI_BYTE */ - -#ifdef SP_MULTI_BYTE -static UnivCharsetDesc::Range range = { 0, 65536, 0 }; -#else -static UnivCharsetDesc::Range range = { 0, 256, 0 }; -#endif - -EntityApp::EntityApp() -: mapCatalogDocument_(0), - systemCharset_(UnivCharsetDesc(&range, 1)) -{ - registerOption('c', SP_T("catalog_sysid")); - registerOption('C'); - registerOption('D', SP_T("dir")); -} - -void EntityApp::processOption(AppChar opt, const AppChar *arg) -{ - switch (opt) { - case 'c': - catalogSysids_.push_back(arg); - break; - case 'C': - mapCatalogDocument_ = 1; - break; - case 'D': - searchDirs_.push_back(arg); - break; - default: - CmdLineApp::processOption(opt, arg); - break; - } -} - -int EntityApp::processArguments(int argc, AppChar **argv) -{ - StringC sysid; - if (!makeSystemId(argc, argv, sysid)) - return 1; - return processSysid(sysid); -} - -Boolean EntityApp::makeSystemId(int nFiles, AppChar *const *files, - StringC &result) -{ - Vector filenames(nFiles == 0 ? 1 : nFiles); - int i; - for (i = 0; i < nFiles; i++) - filenames[i] = convertInput(tcscmp(files[i], SP_T("-")) == 0 - ? SP_T("0") - : files[i]); - if (nFiles == 0) - filenames[0] = convertInput(SP_T("0")); - return entityManager()->mergeSystemIds(filenames, - mapCatalogDocument_, - systemCharset_, - *this, - result); -} - - -Ptr &EntityApp::entityManager() -{ - if (!entityManager_.isNull()) - return entityManager_; - PosixStorageManager *sm - = new PosixStorageManager("OSFILE", - systemCharset_.desc(), -#ifndef SP_WIDE_SYSTEM - codingSystem(), -#endif - 5); - size_t i; - for (i = 0; i < searchDirs_.size(); i++) - sm->addSearchDir(convertInput(searchDirs_[i])); - { - const AppChar *e = tgetenv(SP_T("SGML_SEARCH_PATH")); - if (!e) - e = SGML_SEARCH_PATH_DEFAULT; - if (*e) { - StringC str(convertInput(e)); - size_t i = 0; - size_t start = 0; - for (;;) { - if (i == str.size() || str[i] == FILE_SEP) { - sm->addSearchDir(StringC(str.data() + start, - i - start)); - if (i == str.size()) - break; - start = ++i; - } - else - i++; - } - } - } - - entityManager_ = ExtendEntityManager::make(sm, codingSystem()); - entityManager_ - ->registerStorageManager(new PosixFdStorageManager("OSFD", - systemCharset_.desc())); - entityManager_->registerStorageManager(new URLStorageManager("URL")); - entityManager_->registerStorageManager(new LiteralStorageManager("LITERAL")); - for (i = 0;; i++) { - const char *s; - const CodingSystem *p = codingSystem(i, s); - if (!p) - break; - entityManager_->registerCodingSystem(s, p); - } -#ifdef SP_MULTI_BYTE - for (i = 0; i < SIZEOF(inputCodingSystems); i++) - entityManager_->registerCodingSystem(inputCodingSystems[i].name, - inputCodingSystems[i].cs); -#endif - Vector v; - for (i = 0; i < catalogSysids_.size(); i++) - // filenames specified on command-line must exist - v.push_back(convertInput(catalogSysids_[i])); - { - const AppChar *e = tgetenv(SP_T("SGML_CATALOG_FILES")); - if (!e) - e = SGML_CATALOG_FILES_DEFAULT; - if (*e) { - StringC str(convertInput(e)); - size_t i = 0; - size_t start = 0; - for (;;) { - if (i == str.size() || str[i] == FILE_SEP) { - v.push_back(StringC(str.data() + start, - i - start)); - if (i == str.size()) - break; - start = ++i; - } - else - i++; - } - } - } - entityManager_->setCatalogManager(SOCatalogManager::make(v, - catalogSysids_.size(), - systemCharset_, - systemCharset_)); - return entityManager_; -} - - -#ifdef SP_NAMESPACE -} -#endif diff --git a/cde/programs/nsgmls/EntityApp.h b/cde/programs/nsgmls/EntityApp.h deleted file mode 100644 index 98934e9f3..000000000 --- a/cde/programs/nsgmls/EntityApp.h +++ /dev/null @@ -1,71 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: EntityApp.h /main/1 1996/07/29 16:50:06 cde-hp $ */ -// Copyright (c) 1996 James Clark -// See the file COPYING for copying permission. - -#ifndef EntityApp_INCLUDED -#define EntityApp_INCLUDED 1 - -#ifdef __GNUG__ -#pragma interface -#endif - -#include "CmdLineApp.h" -#include "CharsetInfo.h" -#include "Boolean.h" -#include "ExtendEntityManager.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -class SP_API EntityApp : public CmdLineApp { -public: - EntityApp(); - void processOption(AppChar opt, const AppChar *arg); - virtual int processSysid(const StringC &) = 0; - int processArguments(int argc, AppChar **files); - Boolean makeSystemId(int nFiles, AppChar *const *files, StringC &result); - Ptr &entityManager(); -protected: - void clearEntityManager(); - CharsetInfo systemCharset_; -private: - Vector searchDirs_; - Vector catalogSysids_; - Boolean mapCatalogDocument_; - Ptr entityManager_; -}; - -inline -void EntityApp::clearEntityManager() -{ - entityManager_.clear(); -} - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* not EntityApp_INCLUDED */ diff --git a/cde/programs/nsgmls/EntityCatalog.C b/cde/programs/nsgmls/EntityCatalog.C deleted file mode 100644 index 1e047dee0..000000000 --- a/cde/programs/nsgmls/EntityCatalog.C +++ /dev/null @@ -1,82 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: EntityCatalog.C /main/1 1996/07/29 16:50:12 cde-hp $ */ -// Copyright (c) 1995 James Clark -// See the file COPYING for copying permission. - -#ifdef __GNUG__ -#pragma implementation -#endif -#include "splib.h" -#include "EntityCatalog.h" -#include "EntityDecl.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -EntityCatalog::~EntityCatalog() -{ -} - - -Boolean EntityCatalog::sgmlDecl(const CharsetInfo &, - Messenger &, - StringC &) const -{ - return 0; -} - -Boolean EntityCatalog::lookup(const EntityDecl &decl, - const Syntax &, - const CharsetInfo &, - Messenger &, - StringC &str) const -{ - const StringC *p = decl.systemIdPointer(); - if (!p) - return 0; - str = *p; - return 1; -} - -Boolean EntityCatalog::lookupPublic(const StringC &, - const CharsetInfo &, - Messenger &, - StringC &) const -{ - return 0; -} - -Boolean EntityCatalog::defaultDoctype(const CharsetInfo &, - Messenger &, - StringC &, - StringC &) const -{ - return 0; -} - - -#ifdef SP_NAMESPACE -} -#endif diff --git a/cde/programs/nsgmls/EntityCatalog.h b/cde/programs/nsgmls/EntityCatalog.h deleted file mode 100644 index 04a85c1fd..000000000 --- a/cde/programs/nsgmls/EntityCatalog.h +++ /dev/null @@ -1,76 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: EntityCatalog.h /main/1 1996/07/29 16:50:18 cde-hp $ */ -#ifndef EntityCatalog_INCLUDED -#define EntityCatalog_INCLUDED 1 - -#ifdef __GNUG__ -#pragma interface -#endif - -#include "types.h" -#include "StringC.h" -#include "Resource.h" -#include "SubstTable.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -class Messenger; -class CharsetInfo; -class EntityDecl; - -class SP_API EntityCatalog : public Resource { -public: - class SP_API Syntax { - public: - virtual Boolean namecaseGeneral() const = 0; - virtual Boolean namecaseEntity() const = 0; - virtual const SubstTable &upperSubstTable() const = 0; - virtual const StringC &peroDelim() const = 0; - }; - virtual ~EntityCatalog(); - virtual Boolean sgmlDecl(const CharsetInfo &, - Messenger &, - StringC &) const; - virtual Boolean lookup(const EntityDecl &, - const Syntax &, - const CharsetInfo &, - Messenger &, - StringC &) const; - virtual Boolean lookupPublic(const StringC &, - const CharsetInfo &, - Messenger &, - StringC &) const; - virtual Boolean defaultDoctype(const CharsetInfo &, - Messenger &, - StringC &, - StringC &) const; -}; - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* not EntityCatalog_INCLUDED */ diff --git a/cde/programs/nsgmls/EntityDecl.C b/cde/programs/nsgmls/EntityDecl.C deleted file mode 100644 index bd26dcb82..000000000 --- a/cde/programs/nsgmls/EntityDecl.C +++ /dev/null @@ -1,81 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: EntityDecl.C /main/1 1996/07/29 16:50:24 cde-hp $ */ -// Copyright (c) 1995 James Clark -// See the file COPYING for copying permission. - -#ifdef __GNUG__ -#pragma implementation -#endif -#include "splib.h" -#include "EntityDecl.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -EntityDecl::EntityDecl(const StringC &str, DeclType declType, DataType dataType, - const Location &defLocation) -: NamedResource(str), declType_(declType), dataType_(dataType), - defLocation_(defLocation), dtdIsBase_(0), lpdIsActive_(0) -{ -} - -void EntityDecl::setDeclIn(const ConstPtr > &dtdName, - Boolean dtdIsBase, - const ConstPtr > &lpdName, - Boolean lpdIsActive) -{ - dtdName_ = dtdName; - lpdName_ = lpdName; - dtdIsBase_ = dtdIsBase; - lpdIsActive_ = lpdIsActive; -} - -void EntityDecl::setDeclIn(const ConstPtr > &dtdName, - Boolean dtdIsBase) -{ - dtdName_ = dtdName; - lpdName_.clear(); - dtdIsBase_ = dtdIsBase; -} - -const StringC *EntityDecl::systemIdPointer() const -{ - return 0; -} - -const StringC *EntityDecl::publicIdPointer() const -{ - return 0; -} - -const StringC *EntityDecl::effectiveSystemIdPointer() const -{ - return 0; -} - - -#ifdef SP_NAMESPACE -} -#endif diff --git a/cde/programs/nsgmls/EntityDecl.h b/cde/programs/nsgmls/EntityDecl.h deleted file mode 100644 index 0ca3d9d12..000000000 --- a/cde/programs/nsgmls/EntityDecl.h +++ /dev/null @@ -1,130 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: EntityDecl.h /main/1 1996/07/29 16:50:29 cde-hp $ */ -// Copyright (c) 1995 James Clark -// See the file COPYING for copying permission. - -#ifndef EntityDecl_INCLUDED -#define EntityDecl_INCLUDED 1 - -#ifdef __GNUG__ -#pragma interface -#endif - -#include "NamedResource.h" -#include "Ptr.h" -#include "StringResource.h" -#include "Location.h" -#include "types.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -class SP_API EntityDecl : public NamedResource { -public: - enum DeclType { generalEntity, parameterEntity, doctype, linktype, - notation }; - enum DataType { sgmlText, pi, cdata, sdata, ndata, subdoc }; - EntityDecl(const StringC &, DeclType declType, DataType dataType, - const Location &defLocation); - DataType dataType() const; - DeclType declType() const; - const Location &defLocation() const; - Boolean declInDtdIsBase() const; - Boolean declInActiveLpd() const; - const StringC *declInDtdNamePointer() const; - const StringC *declInLpdNamePointer() const; - void setDeclIn(const ConstPtr > &dtdName, - Boolean dtdIsBase, - const ConstPtr > &lpdName, - Boolean lpdIsActive); - void setDeclIn(const ConstPtr > &dtdName, - Boolean dtdIsBase); - void setDefLocation(const Location &); - virtual const StringC *systemIdPointer() const; - virtual const StringC *publicIdPointer() const; - virtual const StringC *effectiveSystemIdPointer() const; -private: - DeclType declType_; - DataType dataType_; - PackedBoolean dtdIsBase_; - PackedBoolean lpdIsActive_; - Location defLocation_; - ConstPtr > dtdName_; - ConstPtr > lpdName_; -}; - -inline -const Location &EntityDecl::defLocation() const -{ - return defLocation_; -} - -inline -EntityDecl::DeclType EntityDecl::declType() const -{ - return declType_; -} - -inline -EntityDecl::DataType EntityDecl::dataType() const -{ - return dataType_; -} - -inline -const StringC *EntityDecl::declInDtdNamePointer() const -{ - return dtdName_.pointer(); -} - -inline -const StringC *EntityDecl::declInLpdNamePointer() const -{ - return lpdName_.pointer(); -} - -inline -Boolean EntityDecl::declInDtdIsBase() const -{ - return dtdIsBase_; -} - -inline -Boolean EntityDecl::declInActiveLpd() const -{ - return lpdIsActive_; -} - -inline -void EntityDecl::setDefLocation(const Location &loc) -{ - defLocation_ = loc; -} - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* not EntityDecl_INCLUDED */ diff --git a/cde/programs/nsgmls/EntityManager.C b/cde/programs/nsgmls/EntityManager.C deleted file mode 100644 index 3567bafd9..000000000 --- a/cde/programs/nsgmls/EntityManager.C +++ /dev/null @@ -1,44 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: EntityManager.C /main/1 1996/07/29 16:50:33 cde-hp $ */ -// Copyright (c) 1995 James Clark -// See the file COPYING for copying permission. - -#ifdef __GNUG__ -#pragma implementation -#endif -#include "splib.h" -#include "EntityManager.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -EntityManager::~EntityManager() -{ -} - - -#ifdef SP_NAMESPACE -} -#endif diff --git a/cde/programs/nsgmls/EntityManager.h b/cde/programs/nsgmls/EntityManager.h deleted file mode 100644 index 4cf0c9b8d..000000000 --- a/cde/programs/nsgmls/EntityManager.h +++ /dev/null @@ -1,68 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: EntityManager.h /main/1 1996/07/29 16:50:39 cde-hp $ */ -// Copyright (c) 1995 James Clark -// See the file COPYING for copying permission. - -#ifndef EntityManager_INCLUDED -#define EntityManager_INCLUDED 1 - -#ifdef __GNUG__ -#pragma interface -#endif - -#include "types.h" -#include "StringC.h" -#include "Resource.h" -#include "EntityCatalog.h" -#include "Ptr.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -class Messenger; -class InputSourceOrigin; -class CharsetInfo; -class InputSource; - -class SP_API EntityManager : public Resource { -public: - virtual ~EntityManager(); - virtual InputSource *open(const StringC &sysid, - const CharsetInfo &, - InputSourceOrigin *, - Boolean mayRewind, - Messenger &) = 0; - // Make a catalog for a document or subdocument with specified - // system identifier. - // The catalog can cause the system identifier to be replaced. - virtual ConstPtr - makeCatalog(StringC &systemId, const CharsetInfo &, Messenger &) = 0; -}; - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* not EntityManager_INCLUDED */ diff --git a/cde/programs/nsgmls/EntityManagerMessages.h b/cde/programs/nsgmls/EntityManagerMessages.h deleted file mode 100644 index 2bdf94e12..000000000 --- a/cde/programs/nsgmls/EntityManagerMessages.h +++ /dev/null @@ -1,301 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: EntityManagerMessages.h /main/1 1996/07/29 16:50:47 cde-hp $ */ -// This file was automatically generated from EntityManagerMessages.msg by msggen.pl. -#include "Message.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -struct EntityManagerMessages { - // 2000 - static const MessageType1 fsiSyntax; - // 2001 - static const MessageType1 fsiMissingValue; - // 2002 - static const MessageType1 fsiValueAsName; - // 2003 - static const MessageType1 fsiBadSmcrd; - // 2004 - static const MessageType1 fsiUnknownBctf; - // 2005 - static const MessageType1 fsiUnsupportedRecords; - // 2006 - static const MessageType1 fsiUnsupportedAttribute; - // 2007 - static const MessageType1 fsiUnsupportedAttributeToken; - // 2008 - static const MessageType1 fsiBadTracking; - // 2009 - static const MessageType1 fsiDuplicateAttribute; - // 2010 - static const MessageType1 fsiBadZapeof; - // 2011 - static const MessageType1 fsiBadSearch; - // 2012 - static const MessageType1 fsiBadFold; - // 2013 - static const MessageType0 fsiFoldNotNeutral; - // 2014 - static const MessageType0 fsiBctfNotApplicable; - // 2015 - static const MessageType0 fsiZapeofNotApplicable; - // 2016 - static const MessageType0 fsiRecordsNotApplicable; - // 2017 - static const MessageType1 fsiBadIndirect; - // 2018 - static const MessageType1 fsiLookupChar; -}; -const MessageType1 EntityManagerMessages::fsiSyntax( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -2000 -#ifndef SP_NO_MESSAGE_TEXT -,"bad formal system identifier syntax in %1" -#endif -); -const MessageType1 EntityManagerMessages::fsiMissingValue( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -2001 -#ifndef SP_NO_MESSAGE_TEXT -,"value for attribute %1 missing in formal system identifier" -#endif -); -const MessageType1 EntityManagerMessages::fsiValueAsName( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -2002 -#ifndef SP_NO_MESSAGE_TEXT -,"%1 is a formal system identifier attribute value not an attribute name" -#endif -); -const MessageType1 EntityManagerMessages::fsiBadSmcrd( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -2003 -#ifndef SP_NO_MESSAGE_TEXT -,"value of SMCRD attribute must be a single character not %1" -#endif -); -const MessageType1 EntityManagerMessages::fsiUnknownBctf( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -2004 -#ifndef SP_NO_MESSAGE_TEXT -,"unknown BCTF %1" -#endif -); -const MessageType1 EntityManagerMessages::fsiUnsupportedRecords( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -2005 -#ifndef SP_NO_MESSAGE_TEXT -,"unsupported record boundary indicator %1" -#endif -); -const MessageType1 EntityManagerMessages::fsiUnsupportedAttribute( -MessageType::warning, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -2006 -#ifndef SP_NO_MESSAGE_TEXT -,"unsupported formal system identifier attribute %1" -#endif -); -const MessageType1 EntityManagerMessages::fsiUnsupportedAttributeToken( -MessageType::warning, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -2007 -#ifndef SP_NO_MESSAGE_TEXT -,"unsupported formal system identifier attribute value %1" -#endif -); -const MessageType1 EntityManagerMessages::fsiBadTracking( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -2008 -#ifndef SP_NO_MESSAGE_TEXT -,"bad value %1 for formal system identifier tracking attribute" -#endif -); -const MessageType1 EntityManagerMessages::fsiDuplicateAttribute( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -2009 -#ifndef SP_NO_MESSAGE_TEXT -,"duplicate specification for formal system identifier attribute %1" -#endif -); -const MessageType1 EntityManagerMessages::fsiBadZapeof( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -2010 -#ifndef SP_NO_MESSAGE_TEXT -,"bad value %1 for formal system identifier zapeof attribute" -#endif -); -const MessageType1 EntityManagerMessages::fsiBadSearch( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -2011 -#ifndef SP_NO_MESSAGE_TEXT -,"bad value %1 for formal system identifier search attribute" -#endif -); -const MessageType1 EntityManagerMessages::fsiBadFold( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -2012 -#ifndef SP_NO_MESSAGE_TEXT -,"bad value %1 for formal system identifier fold attribute" -#endif -); -const MessageType0 EntityManagerMessages::fsiFoldNotNeutral( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -2013 -#ifndef SP_NO_MESSAGE_TEXT -,"fold attribute allowed only for neutral storage manager" -#endif -); -const MessageType0 EntityManagerMessages::fsiBctfNotApplicable( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -2014 -#ifndef SP_NO_MESSAGE_TEXT -,"BCTF attribute not applicable to this storage manager" -#endif -); -const MessageType0 EntityManagerMessages::fsiZapeofNotApplicable( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -2015 -#ifndef SP_NO_MESSAGE_TEXT -,"ZAPEOF attribute not applicable to this storage manager" -#endif -); -const MessageType0 EntityManagerMessages::fsiRecordsNotApplicable( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -2016 -#ifndef SP_NO_MESSAGE_TEXT -,"RECORDS attribute not applicable to this storage manager" -#endif -); -const MessageType1 EntityManagerMessages::fsiBadIndirect( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -2017 -#ifndef SP_NO_MESSAGE_TEXT -,"bad value %1 for formal system identifier indirect attribute" -#endif -); -const MessageType1 EntityManagerMessages::fsiLookupChar( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -2018 -#ifndef SP_NO_MESSAGE_TEXT -,"non-minimum data character (number %1) in value of formal system identifier lookup attribute" -#endif -); -#ifdef SP_NAMESPACE -} -#endif diff --git a/cde/programs/nsgmls/EquivClass.h b/cde/programs/nsgmls/EquivClass.h deleted file mode 100644 index 1bd48bf3c..000000000 --- a/cde/programs/nsgmls/EquivClass.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: EquivClass.h /main/1 1996/07/29 16:50:53 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#ifndef EquivClass_INCLUDED -#define EquivClass_INCLUDED 1 - -#include "Link.h" -#include "types.h" -#include "ISet.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -struct EquivClass : public Link { - EquivClass(unsigned in = 0) : inSets(in) { } - ISet set; - unsigned inSets; -}; - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* not EquivClass_INCLUDED */ diff --git a/cde/programs/nsgmls/ErrnoMessageArg.C b/cde/programs/nsgmls/ErrnoMessageArg.C deleted file mode 100644 index ee3eb436c..000000000 --- a/cde/programs/nsgmls/ErrnoMessageArg.C +++ /dev/null @@ -1,47 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: ErrnoMessageArg.C /main/1 1996/07/29 16:50:58 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#include "splib.h" -#include "ErrnoMessageArg.h" -#include "StringOf.h" -#include "MessageBuilder.h" - -#include - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -RTTI_DEF1(ErrnoMessageArg, OtherMessageArg) - -MessageArg *ErrnoMessageArg::copy() const -{ - return new ErrnoMessageArg(*this); -} - -#ifdef SP_NAMESPACE -} -#endif diff --git a/cde/programs/nsgmls/ErrnoMessageArg.h b/cde/programs/nsgmls/ErrnoMessageArg.h deleted file mode 100644 index 3251a94d8..000000000 --- a/cde/programs/nsgmls/ErrnoMessageArg.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: ErrnoMessageArg.h /main/1 1996/07/29 16:51:02 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#ifndef ErrnoMessageArg_INCLUDED -#define ErrnoMessageArg_INCLUDED 1 - -#include "MessageArg.h" -#include "rtti.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -class SP_API ErrnoMessageArg : public OtherMessageArg { - RTTI_CLASS -public: - ErrnoMessageArg(int errnum) : errno_(errnum) { } - MessageArg *copy() const; - // errno might be a macro so we must use a different name - int errnum() const; -private: - int errno_; -}; - -inline -int ErrnoMessageArg::errnum() const -{ - return errno_; -} - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* not ErrnoMessageArg_INCLUDED */ diff --git a/cde/programs/nsgmls/ErrorCountEventHandler.C b/cde/programs/nsgmls/ErrorCountEventHandler.C deleted file mode 100644 index 18aa4d889..000000000 --- a/cde/programs/nsgmls/ErrorCountEventHandler.C +++ /dev/null @@ -1,56 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: ErrorCountEventHandler.C /main/1 1996/07/29 16:51:07 cde-hp $ */ -// Copyright (c) 1996 James Clark -// See the file COPYING for copying permission. - -#ifdef __GNUG__ -#pragma implementation -#endif -#include "splib.h" -#include "ErrorCountEventHandler.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -ErrorCountEventHandler::ErrorCountEventHandler(unsigned errorLimit) -: errorCount_(0), maxErrors_(errorLimit), cancel_(0) -{ -} - -void ErrorCountEventHandler::message(MessageEvent *event) -{ - noteMessage(event->message()); - delete event; -} - -void ErrorCountEventHandler::noteMessage(const Message &message) -{ - if (message.isError() && ++errorCount_ == maxErrors_) - cancel_ = 1; -} - -#ifdef SP_NAMESPACE -} -#endif diff --git a/cde/programs/nsgmls/ErrorCountEventHandler.h b/cde/programs/nsgmls/ErrorCountEventHandler.h deleted file mode 100644 index d55eb4d8c..000000000 --- a/cde/programs/nsgmls/ErrorCountEventHandler.h +++ /dev/null @@ -1,91 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: ErrorCountEventHandler.h /main/1 1996/07/29 16:51:11 cde-hp $ */ -// Copyright (c) 1996 James Clark -// See the file COPYING for copying permission. - -#ifndef ErrorCountEventHandler_INCLUDED -#define ErrorCountEventHandler_INCLUDED 1 - -#ifdef __GNUG__ -#pragma interface -#endif - -#include -#include "Event.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -class SP_API ErrorCountEventHandler : public EventHandler { -public: - ErrorCountEventHandler(unsigned errorLimit = 0); - void setErrorLimit(unsigned maxErrors); - const sig_atomic_t *cancelPtr() const; - void cancel(); - Boolean cancelled() const; - unsigned errorCount() const; - void message(MessageEvent *); - void noteMessage(const Message &); -private: - unsigned maxErrors_; - unsigned errorCount_; - sig_atomic_t cancel_; -}; - -inline -unsigned ErrorCountEventHandler::errorCount() const -{ - return errorCount_; -} - -inline -const sig_atomic_t *ErrorCountEventHandler::cancelPtr() const -{ - return &cancel_; -} - -inline -void ErrorCountEventHandler::cancel() -{ - cancel_ = 1; -} - -inline -void ErrorCountEventHandler::setErrorLimit(unsigned maxErrors) -{ - maxErrors_ = maxErrors; -} - -inline -Boolean ErrorCountEventHandler::cancelled() const -{ - return cancel_ != 0; -} - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* not ErrorCountEventHandler_INCLUDED */ diff --git a/cde/programs/nsgmls/Event.C b/cde/programs/nsgmls/Event.C deleted file mode 100644 index 3bd485b55..000000000 --- a/cde/programs/nsgmls/Event.C +++ /dev/null @@ -1,591 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: Event.C /main/1 1996/07/29 16:51:15 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#ifdef __GNUG__ -#pragma implementation -#endif -#include "splib.h" -#include "Event.h" -#include "Entity.h" -#include "Attribute.h" -#include "EventQueue.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -void Event::copyData() -{ -} - -LocatedEvent::LocatedEvent(Type type, const Location &location) -: location_(location), Event(type) -{ -} - -MarkupEvent::MarkupEvent(Type type) -: LocatedEvent(type, Location()) -{ -} - -MarkupEvent::MarkupEvent(Type type, const Location &loc, Markup *markup) -: LocatedEvent(type, loc) -{ - if (markup) - markup->swap(markup_); -} - -StartElementEvent::StartElementEvent(const ElementType *elementType, - const ConstPtr &dtd, - AttributeList *attributes, - const Location &startLocation, - Markup *markup) -: LocatedEvent(startElement, startLocation), - elementType_(elementType), - dtd_(dtd), - included_(0), - copied_(0), - markup_(markup), - attributes_(attributes) -{ -} - -StartElementEvent::~StartElementEvent() -{ - if (copied_) { - delete attributes_; - delete markup_; - } -} - -void StartElementEvent::copyData() -{ - if (!copied_) { - { - AttributeList *p = new AttributeList; - attributes_->swap(*p); - attributes_ = p; - } - if (markup_) { - Markup *p = new Markup; - markup_->swap(*p); - markup_ = p; - } - copied_ = 1; - } -} - -EndElementEvent::EndElementEvent(const ElementType *elementType, - const ConstPtr &dtd, - const Location &startLocation, - Markup *markup) -: LocatedEvent(endElement, startLocation), - elementType_(elementType), - dtd_(dtd), - included_(0), - copied_(0), - markup_(markup) -{ -} - -EndElementEvent::~EndElementEvent() -{ - if (copied_) - delete markup_; -} - -void EndElementEvent::copyData() -{ - if (!copied_) { - if (markup_) { - Markup *p = new Markup; - markup_->swap(*p); - markup_ = p; - } - copied_ = 1; - } -} - -DataEvent::DataEvent(Type type, const Char *p, size_t length, - const Location &location) -: p_(p),length_(length), LocatedEvent(type, location) -{ -} - -const Entity *DataEvent::entity() const -{ - return 0; -} - -Boolean DataEvent::isRe(unsigned long &) const -{ - return 0; -} - -ImmediateDataEvent::ImmediateDataEvent(Type type, const Char *p, size_t length, - const Location &location, - Boolean copy) -: DataEvent(type, p, length, location), alloc_(0) -{ - if (copy) - ImmediateDataEvent::copyData(); -} - -ImmediateDataEvent::~ImmediateDataEvent() -{ - if (alloc_) - delete [] alloc_; -} - -void ImmediateDataEvent::copyData() -{ - if (!alloc_) { - alloc_ = new Char[length_]; - memcpy(alloc_, p_, length_*sizeof(Char)); - p_ = alloc_; - } -} - -ReEvent::ReEvent(const Char *p, const Location &location, unsigned long serial) -: ImmediateDataEvent(characterData, p, 1, location, 0), - serial_(serial) -{ -} - -Boolean ReEvent::isRe(unsigned long &serial) const -{ - serial = serial_; - return 1; -} - -DataEntityEvent::DataEntityEvent(Type type, const InternalEntity *entity, - const ConstPtr &origin) -: DataEvent(type, - entity->string().data(), - entity->string().size(), - Location(origin, 0)) -{ -} - -const Entity *DataEntityEvent::entity() const -{ - return location().origin()->asEntityOrigin()->entity().pointer(); -} - -CdataEntityEvent::CdataEntityEvent(const InternalEntity *entity, - const ConstPtr &origin) -: DataEntityEvent(characterData, entity, origin) -{ -} - -SdataEntityEvent::SdataEntityEvent(const InternalEntity *entity, - const ConstPtr &origin) -: DataEntityEvent(sdataEntity, entity, origin) -{ -} - -MessageEvent::MessageEvent(const Message &m) -: Event(Event::message), message_(m) -{ -} - -MessageEvent::MessageEvent(Message &m) -: Event(Event::message) -{ - m.swap(message_); -} - -PiEvent::PiEvent(const Char *data, size_t dataLength, const Location &location) -: data_(data), dataLength_(dataLength), LocatedEvent(pi, location) -{ -} - -const Entity *PiEvent::entity() const -{ - return 0; -} - -PiEntityEvent::PiEntityEvent(const PiEntity *entity, - const ConstPtr &origin) -: PiEvent(entity->string().data(), entity->string().size(), - Location(origin, 0)) -{ -} - -const Entity *PiEntityEvent::entity() const -{ - return location().origin()->asEntityOrigin()->entity().pointer(); -} - -ImmediatePiEvent::ImmediatePiEvent(StringC &str, const Location &loc) -: PiEvent(str.data(), str.size(), loc) -{ - str.swap(string_); -} - -ExternalEntityEvent::ExternalEntityEvent(Type type, - const ConstPtr &origin) -: origin_(origin), Event(type) -{ -} - -ExternalDataEntityEvent::ExternalDataEntityEvent(const ExternalDataEntity *entity, - const ConstPtr &origin) -: dataEntity_(entity), ExternalEntityEvent(externalDataEntity, origin) -{ -} - -SubdocEntityEvent::SubdocEntityEvent(const SubdocEntity *entity, - const ConstPtr &origin) -: subdocEntity_(entity), ExternalEntityEvent(subdocEntity, origin) -{ -} - -AppinfoEvent::AppinfoEvent(const Location &location) -: LocatedEvent(appinfo, location), appinfoNone_(1) -{ -} - -AppinfoEvent::AppinfoEvent(const Text &text, const Location &location) -: LocatedEvent(appinfo, location), appinfoNone_(0), appinfo_(text) -{ -} - -UselinkEvent::UselinkEvent(const ConstPtr &lpd, - const LinkSet *linkSet, - Boolean restore, - const Location &loc, - Markup *markup) -: MarkupEvent(uselink, loc, markup), - lpd_(lpd), - linkSet_(linkSet), - restore_(restore) -{ -} - -UsemapEvent::UsemapEvent(const ShortReferenceMap *map, - Vector &elements, - const ConstPtr &dtd, - const Location &loc, - Markup *markup) -: MarkupEvent(usemap, loc, markup), - map_(map), - dtd_(dtd) -{ - elements.swap(elements_); -} - -StartSubsetEvent::StartSubsetEvent(Type type, - const StringC &name, - const ConstPtr &entity, - Boolean hasInternalSubset, - const Location &loc, - Markup *markup) -: name_(name), entity_(entity), hasInternalSubset_(hasInternalSubset), - MarkupEvent(type, loc, markup) -{ -} - -StartDtdEvent::StartDtdEvent(const StringC &name, - const ConstPtr &entity, - Boolean hasInternalSubset, - const Location &loc, - Markup *markup) -: StartSubsetEvent(startDtd, name, entity, hasInternalSubset, loc, markup) -{ -} - -StartLpdEvent::StartLpdEvent(Boolean active, - const StringC &name, - const ConstPtr &entity, - Boolean hasInternalSubset, - const Location &loc, - Markup *markup) -: StartSubsetEvent(startLpd, name, entity, hasInternalSubset, loc, markup), - active_(active) -{ -} - -EndDtdEvent::EndDtdEvent(const ConstPtr &dtd, - const Location &loc, - Markup *markup) -: MarkupEvent(endDtd, loc, markup), dtd_(dtd) -{ -} - -EndLpdEvent::EndLpdEvent(const ConstPtr &lpd, - const Location &loc, - Markup *markup) -: MarkupEvent(endLpd, loc, markup), lpd_(lpd) -{ -} - -EndPrologEvent::EndPrologEvent(const ConstPtr &dtd, - const ConstPtr &lpd, - Vector &simpleLinkNames, - Vector &simpleLinkAttributes, - const Location &location) -: LocatedEvent(endProlog, location), dtd_(dtd), lpd_(lpd) -{ - simpleLinkAttributes.swap(simpleLinkAttributes_); - simpleLinkNames.swap(simpleLinkNames_); -} - -EndPrologEvent::EndPrologEvent(const ConstPtr &dtd, - const Location &location) -: LocatedEvent(endProlog, location), dtd_(dtd) -{ -} - -SgmlDeclEvent::SgmlDeclEvent(const ConstPtr &sd, - const ConstPtr &syntax) - -: sd_(sd), prologSyntax_(syntax), instanceSyntax_(syntax), - nextIndex_(0), MarkupEvent(sgmlDecl) -{ -} - -SgmlDeclEvent::SgmlDeclEvent(const ConstPtr &sd, - const ConstPtr &prologSyntax, - const ConstPtr &instanceSyntax, - const ConstPtr &refSd, - const ConstPtr &refSyntax, - Index nextIndex, - const StringC &implySystemId, - const Location &loc, - Markup *markup) -: sd_(sd), prologSyntax_(prologSyntax), instanceSyntax_(instanceSyntax), - refSd_(refSd), refSyntax_(refSyntax), - nextIndex_(nextIndex), implySystemId_(implySystemId), - MarkupEvent(sgmlDecl, loc, markup) -{ -} - -CommentDeclEvent::CommentDeclEvent(const Location &loc, - Markup *markup) -: MarkupEvent(commentDecl, loc, markup) -{ -} - -SSepEvent::SSepEvent(const Char *p, size_t length, - const Location &location, Boolean copy) -: ImmediateDataEvent(sSep, p, length, location, copy) -{ -} - -IgnoredRsEvent::IgnoredRsEvent(Char c, const Location &location) -: LocatedEvent(ignoredRs, location), c_(c) -{ -} - -IgnoredReEvent::IgnoredReEvent(Char c, const Location &location, - unsigned long serial) -: LocatedEvent(ignoredRe, location), - c_(c), - serial_(serial) -{ -} - -ReOriginEvent::ReOriginEvent(Char c, const Location &location, - unsigned long serial) -: LocatedEvent(reOrigin, location), c_(c), serial_(serial) -{ -} - - -IgnoredCharsEvent::IgnoredCharsEvent(const Char *p, size_t length, - const Location &location, Boolean copy) -: ImmediateDataEvent(ignoredChars, p, length, location, copy) -{ -} - -MarkedSectionEvent::MarkedSectionEvent(Type type, Status status, - const Location &loc, - Markup *markup) -: MarkupEvent(type, loc, markup), - status_(status) -{ -} - -MarkedSectionStartEvent::MarkedSectionStartEvent(Status status, - const Location &loc, - Markup *markup) -: MarkedSectionEvent(markedSectionStart, status, loc, markup) -{ -} - -MarkedSectionEndEvent::MarkedSectionEndEvent(Status status, - const Location &loc, - Markup *markup) -: MarkedSectionEvent(markedSectionEnd, status, loc, markup) -{ -} - -EntityStartEvent::EntityStartEvent(const ConstPtr &origin) -: Event(entityStart), origin_(origin) -{ -} - -EntityEndEvent::EntityEndEvent(const Location &location) -: LocatedEvent(entityEnd, location) -{ -} - -EntityDeclEvent:: EntityDeclEvent(const ConstPtr &entity, - Boolean ignored, const Location &loc, - Markup *markup) -: MarkupEvent(entityDecl, loc, markup), - entity_(entity), - ignored_(ignored) -{ -} - -NotationDeclEvent:: NotationDeclEvent(const ConstPtr ¬ation, - const Location &loc, - Markup *markup) -: MarkupEvent(notationDecl, loc, markup), notation_(notation) -{ -} - -ElementDeclEvent::ElementDeclEvent(Vector &elements, - const ConstPtr &dtd, - const Location &loc, - Markup *markup) -: MarkupEvent(elementDecl, loc, markup), dtd_(dtd) -{ - elements.swap(elements_); -} - -AttlistDeclEvent::AttlistDeclEvent(Vector &elements, - const ConstPtr &dtd, - const Location &loc, - Markup *markup) -: MarkupEvent(attlistDecl, loc, markup), dtd_(dtd) -{ - elements.swap(elements_); -} - -AttlistNotationDeclEvent::AttlistNotationDeclEvent( - Vector > ¬ations, const Location &loc, - Markup *markup) -: MarkupEvent(attlistNotationDecl, loc, markup) -{ - notations.swap(notations_); -} - -LinkAttlistDeclEvent -::LinkAttlistDeclEvent(Vector &elements, - const ConstPtr &lpd, - const Location &loc, - Markup *markup) -: MarkupEvent(linkAttlistDecl, loc, markup), lpd_(lpd) -{ - elements.swap(elements_); -} - -LinkDeclEvent::LinkDeclEvent(const LinkSet *linkSet, - const ConstPtr &lpd, - const Location &loc, - Markup *markup) -: MarkupEvent(linkDecl, loc, markup), lpd_(lpd), linkSet_(linkSet) -{ -} - -IdLinkDeclEvent::IdLinkDeclEvent(const ConstPtr &lpd, - const Location &loc, - Markup *markup) -: MarkupEvent(linkDecl, loc, markup), lpd_(lpd) -{ -} - -ShortrefDeclEvent::ShortrefDeclEvent(const ShortReferenceMap *map, - const ConstPtr &dtd, - const Location &loc, - Markup *markup) -: MarkupEvent(shortrefDecl, loc, markup), map_(map), dtd_(dtd) -{ -} - -IgnoredMarkupEvent::IgnoredMarkupEvent(const Location &loc, - Markup *markup) -: MarkupEvent(ignoredMarkup, loc, markup) -{ -} - -EntityDefaultedEvent::EntityDefaultedEvent(const ConstPtr &entity, - const Location &loc) -: LocatedEvent(entityDefaulted, loc), entity_(entity) -{ -} - -SgmlDeclEntityEvent:: SgmlDeclEntityEvent(const PublicId &publicId, - PublicId::TextClass entityType, - const StringC &effectiveSystemId, - const Location &loc) -: LocatedEvent(sgmlDeclEntity, loc), publicId_(publicId), - entityType_(entityType), effectiveSystemId_(effectiveSystemId) -{ -} - -EventHandler::~EventHandler() -{ -} - -EventQueue::EventQueue() -{ -} - -#define EVENT(c, f) \ - void EventHandler::f(c *event) { delete event; } \ - void EventQueue::f(c *event) { append(event); } \ - void c::handle(EventHandler &handler) { handler.f(this); } -#include "events.h" -#undef EVENT - -Pass1EventHandler::Pass1EventHandler() -: hadError_(0), origHandler_(0) -{ -} - -void Pass1EventHandler::init(EventHandler *origHandler) -{ - hadError_ = 0; - origHandler_ = origHandler; -} - -void Pass1EventHandler::message(MessageEvent *event) -{ - if (event->message().isError()) { - hadError_ = 1; - origHandler_->message(event); - } - else - IQueue::append(event); -} - -#ifdef SP_NAMESPACE -} -#endif diff --git a/cde/programs/nsgmls/Event.h b/cde/programs/nsgmls/Event.h deleted file mode 100644 index e411bedfe..000000000 --- a/cde/programs/nsgmls/Event.h +++ /dev/null @@ -1,1365 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: Event.h /main/1 1996/07/29 16:51:20 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#ifndef Event_INCLUDED -#define Event_INCLUDED 1 -#ifdef __GNUG__ -#pragma interface -#endif - -#include "Link.h" -#include "Allocator.h" -#include "Location.h" -#include "Vector.h" -#include "Owner.h" -#include "Boolean.h" -#include "types.h" -#include "Ptr.h" -#include "StringC.h" -#include "Notation.h" -#include "Sd.h" -#include "Syntax.h" -#include "Dtd.h" -#include "ElementType.h" -#include "Text.h" -#include "Lpd.h" -#include "Message.h" -#include "Markup.h" -#include "ShortReferenceMap.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -class EventHandler; - -class SP_API Event : public Link { -public: - enum Type { - message, - characterData, - startElement, - endElement, - pi, - sdataEntity, - externalDataEntity, - subdocEntity, - appinfo, - startDtd, - endDtd, - startLpd, - endLpd, - endProlog, - sgmlDecl, - uselink, - usemap, - commentDecl, - sSep, - ignoredRs, - ignoredRe, - reOrigin, - ignoredChars, - markedSectionStart, - markedSectionEnd, - entityStart, - entityEnd, - notationDecl, - entityDecl, - elementDecl, - attlistDecl, // not #NOTATION and not in LPD - attlistNotationDecl, - linkAttlistDecl, - linkDecl, - idLinkDecl, - shortrefDecl, - ignoredMarkup, - entityDefaulted, - sgmlDeclEntity - }; - Event(Type); - virtual void handle(EventHandler &) = 0; - virtual void copyData(); - void *operator new(size_t sz, Allocator &alloc) { return alloc.alloc(sz); } - void *operator new(size_t sz) { return Allocator::allocSimple(sz); } - void operator delete(void *p) { Allocator::free(p); } - Type type() const; -private: - Event(const Event &); // undefined - void operator=(const Event &); // undefined - Type type_; -}; - -class LocatedEvent : public Event { -public: - LocatedEvent(Type type, const Location &); - const Location &location() const; -private: - LocatedEvent(const LocatedEvent &); // undefined - void operator=(const LocatedEvent &); // undefined - Location location_; -}; - -class MarkupEvent : public LocatedEvent { -public: - MarkupEvent(Type type); - MarkupEvent(Type type, const Location &, Markup *); - const Markup &markup() const; -private: - MarkupEvent(const MarkupEvent &); // undefined - void operator=(const MarkupEvent &); // undefined - Markup markup_; -}; - -class SP_API MessageEvent : public Event { -public: - MessageEvent(Message &); - MessageEvent(const Message &); - const Message &message() const; - void handle(EventHandler &); -private: - MessageEvent(const MessageEvent &); // undefined - void operator=(const MessageEvent &); // undefined - Message message_; -}; - -class AttributeList; - -class StartElementEvent : public LocatedEvent { -public: - StartElementEvent(const ElementType *, - const ConstPtr &, - AttributeList *, - const Location &, - Markup *); - ~StartElementEvent(); - void handle(EventHandler &); - Boolean mustOmitEnd() const; - void setIncluded(); - Boolean included() const; - const StringC &name() const; - const ElementType *elementType() const; - const Markup *markupPtr() const; - const AttributeList &attributes() const; - void copyData(); -private: - StartElementEvent(const StartElementEvent &); // undefined - void operator=(const StartElementEvent &); // undefined - const ElementType *elementType_; - ConstPtr dtd_; - PackedBoolean included_; - PackedBoolean copied_; // has copyData() been called - Markup *markup_; - AttributeList *attributes_; -}; - -class EndElementEvent : public LocatedEvent { -public: - EndElementEvent(const ElementType *, - const ConstPtr &, - const Location &, - Markup *); - ~EndElementEvent(); - void handle(EventHandler &); - void setIncluded(); - Boolean included() const; - const StringC &name() const; - const ElementType *elementType() const; - const Markup *markupPtr() const; - void copyData(); -private: - EndElementEvent(const EndElementEvent &); // undefined - void operator=(const EndElementEvent &); // undefined - const ElementType *elementType_; - ConstPtr dtd_; - PackedBoolean included_; - PackedBoolean copied_; // has copyData() been called - Markup *markup_; -}; - -class DataEvent : public LocatedEvent { -public: - DataEvent(Type, const Char *, size_t, const Location &); - void handle(EventHandler &); - const Char *data() const; - size_t dataLength() const; - virtual Boolean isRe(unsigned long &serial) const; - virtual const Entity *entity() const; -protected: - const Char *p_; - size_t length_; -private: - DataEvent(const DataEvent &); // undefined - void operator=(const DataEvent &); // undefined -}; - -class ImmediateDataEvent : public DataEvent { -public: - ImmediateDataEvent(Type type, const Char *, size_t, const Location &, - Boolean copy); - ~ImmediateDataEvent(); - void copyData(); -private: - ImmediateDataEvent(const ImmediateDataEvent &); // undefined - void operator=(const ImmediateDataEvent &); // undefined - Char *alloc_; -}; - -class InternalDataEntity; - -class DataEntityEvent : public DataEvent { -public: - DataEntityEvent(Type type, const InternalEntity *, - const ConstPtr &); - const Entity *entity() const; -private: - DataEntityEvent(const DataEntityEvent &); // undefined - void operator=(const DataEntityEvent &); // undefined -}; - -class InternalCdataEntity; - -class CdataEntityEvent : public DataEntityEvent { -public: - CdataEntityEvent(const InternalEntity *, - const ConstPtr &); -private: - CdataEntityEvent(const CdataEntityEvent &); // undefined - void operator=(const CdataEntityEvent &); // undefined -}; - -class InternalSdataEntity; - -class SdataEntityEvent : public DataEntityEvent { -public: - SdataEntityEvent(const InternalEntity *, - const ConstPtr &); - void handle(EventHandler &); -private: - SdataEntityEvent(const SdataEntityEvent &); // undefined - void operator=(const SdataEntityEvent &); // undefined -}; - -class PiEntity; - -class PiEvent : public LocatedEvent { -public: - PiEvent(const Char *, size_t, const Location &); - const Char *data() const; - size_t dataLength() const; - virtual const Entity *entity() const; - void handle(EventHandler &); -private: - PiEvent(const PiEvent &); // undefined - void operator=(const PiEvent &); // undefined - const Char *data_; - size_t dataLength_; -}; - -class ImmediatePiEvent : public PiEvent { -public: - ImmediatePiEvent(StringC &, const Location &); -private: - ImmediatePiEvent(const ImmediatePiEvent &); // undefined - void operator=(const ImmediatePiEvent &); // undefined - StringC string_; -}; - -class PiEntityEvent : public PiEvent { -public: - PiEntityEvent(const PiEntity *entity, - const ConstPtr &origin); - const Entity *entity() const; -private: - PiEntityEvent(const PiEntityEvent &); // undefined - void operator=(const PiEntityEvent &); // undefined -}; - -class ExternalNonTextEntity; -class ExternalDataEntity; -class SubdocEntity; - -class ExternalEntityEvent : public Event { -public: - ExternalEntityEvent(Type type, - const ConstPtr &); - const ConstPtr &entityOrigin() const; - const Location &location() const; -private: - ExternalEntityEvent(const ExternalEntityEvent &); // undefined - void operator=(const ExternalEntityEvent &); // undefined - ConstPtr origin_; -}; - -class ExternalDataEntityEvent : public ExternalEntityEvent { -public: - ExternalDataEntityEvent(const ExternalDataEntity *, - const ConstPtr &); - void handle(EventHandler &); - const ExternalDataEntity *entity() const; -private: - ExternalDataEntityEvent(const ExternalDataEntityEvent &); // undefined - void operator=(const ExternalDataEntityEvent &); // undefined - const ExternalDataEntity *dataEntity_; -}; - -class SubdocEntityEvent : public ExternalEntityEvent { -public: - SubdocEntityEvent(const SubdocEntity *, - const ConstPtr &); - void handle(EventHandler &); - const SubdocEntity *entity() const; -private: - SubdocEntityEvent(const SubdocEntityEvent &); // undefined - void operator=(const SubdocEntityEvent &); // undefined - const SubdocEntity *subdocEntity_; -}; - -class AppinfoEvent : public LocatedEvent { -public: - AppinfoEvent(const Location &); - AppinfoEvent(const Text &, const Location &); - void handle(EventHandler &); - Boolean literal(const StringC *&) const; -private: - AppinfoEvent(const AppinfoEvent &); // undefined - void operator=(const AppinfoEvent &); // undefined - Boolean appinfoNone_; - Text appinfo_; -}; - -class UselinkEvent : public MarkupEvent { -public: - UselinkEvent(const ConstPtr &, - const LinkSet *, - Boolean restore, - const Location &, - Markup *); - void handle(EventHandler &); - const ConstPtr &lpd() const; - const LinkSet *linkSet() const; - Boolean restore() const; -private: - UselinkEvent(const UselinkEvent &); // undefined - void operator=(const UselinkEvent &); // undefined - ConstPtr lpd_; - const LinkSet *linkSet_; - Boolean restore_; -}; - -class UsemapEvent : public MarkupEvent { -public: - UsemapEvent(const ShortReferenceMap *, - Vector &, - const ConstPtr &, - const Location &, - Markup *); - void handle(EventHandler &); - const ShortReferenceMap *map() const; - const Vector &elements() const; -private: - UsemapEvent(const UsemapEvent &); // undefined - void operator=(const UsemapEvent &); // undefined - ConstPtr dtd_; - Vector elements_; - const ShortReferenceMap *map_; -}; - -class StartSubsetEvent : public MarkupEvent { -public: - StartSubsetEvent(Type, - const StringC &, - const ConstPtr &entity, - Boolean hasInternalSubset, - const Location &, - Markup *); - const StringC &name() const; - const ConstPtr &entity() const; - Boolean hasInternalSubset() const; -private: - StartSubsetEvent(const StartSubsetEvent &); // undefined - void operator=(const StartSubsetEvent &); // undefined - StringC name_; - ConstPtr entity_; - Boolean hasInternalSubset_; -}; - -class StartDtdEvent : public StartSubsetEvent { -public: - StartDtdEvent(const StringC &, - const ConstPtr &entity, - Boolean hasInternalSubset, - const Location &, - Markup *); - void handle(EventHandler &); -private: - StartDtdEvent(const StartDtdEvent &); // undefined - void operator=(const StartDtdEvent &); // undefined -}; - -class StartLpdEvent : public StartSubsetEvent { -public: - StartLpdEvent(Boolean active, - const StringC &, - const ConstPtr &entity, - Boolean hasInternalSubset, - const Location &, - Markup *); - void handle(EventHandler &); - Boolean active() const; -private: - StartLpdEvent(const StartLpdEvent &); // undefined - void operator=(const StartLpdEvent &); // undefined - Boolean active_; -}; - -class EndDtdEvent : public MarkupEvent { -public: - EndDtdEvent(const ConstPtr &, const Location &, - Markup *); - void handle(EventHandler &); - const Dtd &dtd() const; - const ConstPtr &dtdPointer() const; -private: - EndDtdEvent(const EndDtdEvent &); // undefined - void operator=(const EndDtdEvent &); // undefined - ConstPtr dtd_; -}; - -class EndLpdEvent : public MarkupEvent { -public: - EndLpdEvent(const ConstPtr &, const Location &, - Markup *); - void handle(EventHandler &); - const Lpd &lpd() const; - const ConstPtr &lpdPointer() const; -private: - EndLpdEvent(const EndLpdEvent &); // undefined - void operator=(const EndLpdEvent &); // undefined - ConstPtr lpd_; -}; - -class EndPrologEvent : public LocatedEvent { -public: - EndPrologEvent(const ConstPtr &dtd, - const ConstPtr &lpd, - Vector &simpleLinkNames, - Vector &simpleLinkAttributes, - const Location &); - EndPrologEvent(const ConstPtr &dtd, - const Location &); - void handle(EventHandler &); - const Dtd &dtd() const; - const ConstPtr &dtdPointer() const; - const ConstPtr &lpdPointer() const; - const Vector &simpleLinkNames() const; - const Vector &simpleLinkAttributes() const; -private: - EndPrologEvent(const EndPrologEvent &); // undefined - void operator=(const EndPrologEvent &); // undefined - ConstPtr dtd_; - ConstPtr lpd_; - Vector simpleLinkNames_; - Vector simpleLinkAttributes_; -}; - -class SgmlDeclEvent : public MarkupEvent { -public: - // for an implied SGML declaration - SgmlDeclEvent(const ConstPtr &, - const ConstPtr &syntax); - // for an explicit SGML declaration - SgmlDeclEvent(const ConstPtr &, - const ConstPtr &syntax, - const ConstPtr &instanceSyntax, - const ConstPtr &refSd, - const ConstPtr &refSyntax, - Index nextIndex, - const StringC &implySystemId, - const Location &, - Markup *); - void handle(EventHandler &); - const Sd &sd() const; - const ConstPtr &sdPointer() const; - const Syntax &prologSyntax() const; - const ConstPtr &prologSyntaxPointer() const; - const Syntax &instanceSyntax() const; - const ConstPtr &instanceSyntaxPointer() const; - const ConstPtr &refSdPointer() const; - const ConstPtr &refSyntaxPointer() const; - const StringC &implySystemId() const; -private: - SgmlDeclEvent(const SgmlDeclEvent &); // undefined - void operator=(const SgmlDeclEvent &); // undefined - ConstPtr sd_; - ConstPtr prologSyntax_; - ConstPtr instanceSyntax_; - ConstPtr refSd_; - ConstPtr refSyntax_; - Index nextIndex_; - StringC implySystemId_; -}; - -class CommentDeclEvent : public MarkupEvent { -public: - CommentDeclEvent(const Location &, Markup *); - void handle(EventHandler &); -private: - CommentDeclEvent(const CommentDeclEvent &); // undefined - void operator=(const CommentDeclEvent &); // undefined -}; - -class SSepEvent : public ImmediateDataEvent { -public: - SSepEvent(const Char *, size_t, const Location &, Boolean copy); - void handle(EventHandler &); -private: - SSepEvent(const SSepEvent &); // undefined - void operator=(const SSepEvent &); // undefined -}; - -class IgnoredRsEvent : public LocatedEvent { -public: - IgnoredRsEvent(Char c, const Location &); - void handle(EventHandler &); - Char rs() const; -private: - IgnoredRsEvent(const IgnoredRsEvent &); // undefined - void operator=(const IgnoredRsEvent &); // undefined - Char c_; -}; - -class IgnoredReEvent : public LocatedEvent { -public: - IgnoredReEvent(Char c, const Location &, unsigned long serial); - void handle(EventHandler &); - Char re() const; - unsigned long serial() const; -private: - IgnoredReEvent(const IgnoredReEvent &); // undefined - void operator=(const IgnoredReEvent &); // undefined - unsigned long serial_; - Char c_; -}; - -class ReEvent : public ImmediateDataEvent { -public: - ReEvent(const Char *, const Location &, unsigned long serial); - Boolean isRe(unsigned long &serial) const; -private: - ReEvent(const ReEvent &); // undefined - void operator=(const ReEvent &); // undefined - unsigned long serial_; -}; - -class ReOriginEvent : public LocatedEvent { -public: - ReOriginEvent(Char c, const Location &, unsigned long serial); - void handle(EventHandler &); - Char re() const; - unsigned long serial() const; -private: - ReOriginEvent(const ReOriginEvent &); // undefined - void operator=(const ReOriginEvent &); // undefined - unsigned long serial_; - Char c_; -}; - -class IgnoredCharsEvent : public ImmediateDataEvent { -public: - IgnoredCharsEvent(const Char *, size_t, const Location &, Boolean copy); - void handle(EventHandler &); -private: - IgnoredCharsEvent(const IgnoredCharsEvent &); // undefined - void operator=(const IgnoredCharsEvent &); // undefined -}; - -class MarkedSectionEvent : public MarkupEvent { -public: - enum Status { include, rcdata, cdata, ignore }; // in priority order - MarkedSectionEvent(Type, Status, const Location &, Markup *); - Status status() const; -private: - MarkedSectionEvent(const MarkedSectionEvent &); // undefined - void operator=(const MarkedSectionEvent &); // undefined - Status status_; -}; - -class MarkedSectionStartEvent : public MarkedSectionEvent { -public: - MarkedSectionStartEvent(Status, const Location &, Markup *); - void handle(EventHandler &); -private: - MarkedSectionStartEvent(const MarkedSectionStartEvent &); // undefined - void operator=(const MarkedSectionStartEvent &); // undefined -}; - -class MarkedSectionEndEvent : public MarkedSectionEvent { -public: - MarkedSectionEndEvent(Status, const Location &, Markup *); - void handle(EventHandler &); -private: - MarkedSectionEndEvent(const MarkedSectionEndEvent &); // undefined - void operator=(const MarkedSectionEndEvent &); // undefined -}; - -class EntityStartEvent : public Event { -public: - EntityStartEvent(const ConstPtr &origin); - void handle(EventHandler &); - const Entity *entity() const; - const ConstPtr &entityOrigin() const; -private: - EntityStartEvent(const EntityStartEvent &); // undefined - void operator=(const EntityStartEvent &); // undefined - - ConstPtr origin_; -}; - -class EntityEndEvent : public LocatedEvent { -public: - EntityEndEvent(const Location &); - void handle(EventHandler &); -private: - EntityEndEvent(const EntityEndEvent &); // undefined - void operator=(const EntityEndEvent &); // undefined -}; - -class EntityDeclEvent : public MarkupEvent { -public: - EntityDeclEvent(const ConstPtr &, - Boolean ignored, - const Location &, - Markup *); - void handle(EventHandler &); - const Entity &entity() const; - const ConstPtr &entityPointer() const; - Boolean ignored() const; - // The name of the entity will be empty if this is the default entity. -private: - Boolean ignored_; - // This will actually point to an external entity. - ConstPtr entity_; -}; - -class NotationDeclEvent : public MarkupEvent { -public: - NotationDeclEvent(const ConstPtr &, - const Location &, - Markup *); - void handle(EventHandler &); - const Notation ¬ation() const; - const ConstPtr ¬ationPointer() const; -private: - NotationDeclEvent(const NotationDeclEvent &); // undefined - void operator=(const NotationDeclEvent &); // undefined - ConstPtr notation_; -}; - -class ElementDeclEvent : public MarkupEvent { -public: - ElementDeclEvent(Vector &elements, - const ConstPtr &, - const Location &, - Markup *); - void handle(EventHandler &); - const Vector &elements() const; -private: - ElementDeclEvent(const ElementDeclEvent &); // undefined - void operator=(const ElementDeclEvent &); // undefined - Vector elements_; - ConstPtr dtd_; -}; - -class AttlistDeclEvent : public MarkupEvent { -public: - AttlistDeclEvent(Vector &elements, - const ConstPtr &, - const Location &, - Markup *); - void handle(EventHandler &); - const Vector &elements() const; -private: - AttlistDeclEvent(const AttlistDeclEvent &); // undefined - void operator=(const AttlistDeclEvent &); // undefined - Vector elements_; - ConstPtr dtd_; -}; - -class AttlistNotationDeclEvent : public MarkupEvent { -public: - AttlistNotationDeclEvent(Vector > ¬ations, - const Location &, - Markup *); - void handle(EventHandler &); - const Vector > ¬ations() const; -private: - AttlistNotationDeclEvent(const AttlistNotationDeclEvent &); // undefined - void operator=(const AttlistDeclEvent &); // undefined - Vector > notations_; -}; - -class LinkAttlistDeclEvent : public MarkupEvent { -public: - LinkAttlistDeclEvent(Vector &elements, - const ConstPtr &, - const Location &, - Markup *); - void handle(EventHandler &); - const Vector &elements() const; - const Lpd &lpd() const; -private: - LinkAttlistDeclEvent(const LinkAttlistDeclEvent &); // undefined - void operator=(const LinkAttlistDeclEvent &); // undefined - Vector elements_; - ConstPtr lpd_; -}; - -class LinkDeclEvent : public MarkupEvent { -public: - LinkDeclEvent(const LinkSet *linkSet, - const ConstPtr &, - const Location &, - Markup *); - void handle(EventHandler &); - const LinkSet *linkSet() const; - const ComplexLpd &lpd() const; -private: - LinkDeclEvent(const LinkDeclEvent &); // undefined - void operator=(const LinkDeclEvent &); // undefined - const LinkSet *linkSet_; - ConstPtr lpd_; -}; - -class IdLinkDeclEvent : public MarkupEvent { -public: - IdLinkDeclEvent(const ConstPtr &, - const Location &, - Markup *); - void handle(EventHandler &); - const ComplexLpd &lpd() const; -private: - IdLinkDeclEvent(const IdLinkDeclEvent &); // undefined - void operator=(const IdLinkDeclEvent &); // undefined - ConstPtr lpd_; -}; - -class ShortrefDeclEvent : public MarkupEvent { -public: - ShortrefDeclEvent(const ShortReferenceMap *, - const ConstPtr &, - const Location &, - Markup *); - void handle(EventHandler &); - const ShortReferenceMap *map() const; -private: - ShortrefDeclEvent(const ShortrefDeclEvent &); // undefined - void operator=(const ShortrefDeclEvent &); // undefined - const ShortReferenceMap *map_; - ConstPtr dtd_; -}; - -class IgnoredMarkupEvent : public MarkupEvent { -public: - IgnoredMarkupEvent(const Location &, Markup *); - void handle(EventHandler &); -private: - IgnoredMarkupEvent(const IgnoredMarkupEvent &); // undefined - void operator=(const IgnoredMarkupEvent &); // undefined -}; - -// This is for an undeclared entity whose first occurrence -// is in the instance, when there is a default entity: -// ie it extends the namespace of general entities after -// the end of the prolog. - -class EntityDefaultedEvent : public LocatedEvent { -public: - EntityDefaultedEvent(const ConstPtr &, - const Location &); - void handle(EventHandler &); - const Entity &entity() const; - const ConstPtr &entityPointer() const; -private: - EntityDefaultedEvent(const EntityDefaultedEvent &); // undefined - void operator=(const EntityDefaultedEvent &); // undefined - ConstPtr entity_; -}; - -class SgmlDeclEntityEvent : public LocatedEvent { -public: - SgmlDeclEntityEvent(const PublicId &publicId, - PublicId::TextClass entityType, - const StringC &effectiveSystemId, - const Location &); - void handle(EventHandler &); - const PublicId &publicId() const; - PublicId::TextClass entityType() const; - const StringC &effectiveSystemId() const; -private: - SgmlDeclEntityEvent(const SgmlDeclEntityEvent &); // undefined - void operator=(const SgmlDeclEntityEvent &); // undefined - PublicId publicId_; - PublicId::TextClass entityType_; - StringC effectiveSystemId_; -}; - -class SP_API EventHandler { -public: - virtual ~EventHandler(); - virtual void message(MessageEvent *) = 0; - virtual void data(DataEvent *); - virtual void startElement(StartElementEvent *); - virtual void endElement(EndElementEvent *); - virtual void pi(PiEvent *); - virtual void sdataEntity(SdataEntityEvent *); - virtual void externalDataEntity(ExternalDataEntityEvent *); - virtual void subdocEntity(SubdocEntityEvent *); - virtual void appinfo(AppinfoEvent *); - virtual void uselink(UselinkEvent *); - virtual void usemap(UsemapEvent *); - virtual void startDtd(StartDtdEvent *); - virtual void endDtd(EndDtdEvent *); - virtual void startLpd(StartLpdEvent *); - virtual void endLpd(EndLpdEvent *); - virtual void endProlog(EndPrologEvent *); - virtual void sgmlDecl(SgmlDeclEvent *); - virtual void commentDecl(CommentDeclEvent *); - virtual void sSep(SSepEvent *); - virtual void ignoredRs(IgnoredRsEvent *); - virtual void ignoredRe(IgnoredReEvent *); - virtual void reOrigin(ReOriginEvent *); - virtual void ignoredChars(IgnoredCharsEvent *); - virtual void markedSectionStart(MarkedSectionStartEvent *); - virtual void markedSectionEnd(MarkedSectionEndEvent *); - virtual void entityStart(EntityStartEvent *); - virtual void entityEnd(EntityEndEvent *); - virtual void notationDecl(NotationDeclEvent *); - virtual void entityDecl(EntityDeclEvent *); - virtual void elementDecl(ElementDeclEvent *); - virtual void attlistDecl(AttlistDeclEvent *); - virtual void linkAttlistDecl(LinkAttlistDeclEvent *); - virtual void attlistNotationDecl(AttlistNotationDeclEvent *); - virtual void linkDecl(LinkDeclEvent *); - virtual void idLinkDecl(IdLinkDeclEvent *); - virtual void shortrefDecl(ShortrefDeclEvent *); - virtual void ignoredMarkup(IgnoredMarkupEvent *); - virtual void entityDefaulted(EntityDefaultedEvent *); - virtual void sgmlDeclEntity(SgmlDeclEntityEvent *); -}; - -inline -Event::Event(Type type) -: type_(type) -{ -} - -inline -Event::Type Event::type() const -{ - return type_; -} - -inline -const Location &LocatedEvent::location() const -{ - return location_; -} - -inline -const Markup &MarkupEvent::markup() const -{ - return markup_; -} - -inline -const Message &MessageEvent::message() const -{ - return message_; -} - -inline -const ElementType *StartElementEvent::elementType() const -{ - return elementType_; -} - -inline -const StringC &StartElementEvent::name() const -{ - return elementType_->name(); -} - -inline -void StartElementEvent::setIncluded() -{ - included_ = 1; -} - -inline -Boolean StartElementEvent::included() const -{ - return included_; -} - -inline -const Markup *StartElementEvent::markupPtr() const -{ - return markup_; -} - -inline -const AttributeList &StartElementEvent::attributes() const -{ - return *attributes_; -} - -inline -Boolean StartElementEvent::mustOmitEnd() const -{ - return ((elementType()->definition()->declaredContent() - == ElementDefinition::empty) - || attributes_->conref()); -} - -inline -const ElementType *EndElementEvent::elementType() const -{ - return elementType_; -} - -inline -const StringC &EndElementEvent::name() const -{ - return elementType_->name(); -} - -inline -void EndElementEvent::setIncluded() -{ - included_ = 1; -} - -inline -Boolean EndElementEvent::included() const -{ - return included_; -} - -inline -const Markup *EndElementEvent::markupPtr() const -{ - return markup_; -} - -inline -const Char *DataEvent::data() const -{ - return p_; -} - -inline -size_t DataEvent::dataLength() const -{ - return length_; -} - -inline -const Char *PiEvent::data() const -{ - return data_; -} - -inline -size_t PiEvent::dataLength() const -{ - return dataLength_; -} - -inline -const ConstPtr & -ExternalEntityEvent::entityOrigin() const -{ - return origin_; -} - -inline -const Location &ExternalEntityEvent::location() const -{ - return origin_->parent(); -} - -inline -const ExternalDataEntity *ExternalDataEntityEvent::entity() const -{ - return dataEntity_; -} - -inline -const SubdocEntity *SubdocEntityEvent::entity() const -{ - return subdocEntity_; -} - -inline -Boolean AppinfoEvent::literal(const StringC *&p) const -{ - int retVal; - - if (appinfoNone_) - retVal = 0; - else { - p = &appinfo_.string(); - retVal = 1; - } - return retVal; -} - -inline -const ConstPtr &UselinkEvent::lpd() const -{ - return lpd_; -} - -inline -const LinkSet *UselinkEvent::linkSet() const -{ - return linkSet_; -} - -inline -Boolean UselinkEvent::restore() const -{ - return restore_; -} - -inline -const ShortReferenceMap *UsemapEvent::map() const -{ - return map_; -} - -inline -const StringC &StartSubsetEvent::name() const -{ - return name_; -} - -inline -const ConstPtr &StartSubsetEvent::entity() const -{ - return entity_; -} - -inline -Boolean StartSubsetEvent::hasInternalSubset() const -{ - return hasInternalSubset_; -} - -inline -Boolean StartLpdEvent::active() const -{ - return active_; -} - -inline -const Dtd &EndDtdEvent::dtd() const -{ - return *dtd_; -} - -inline -const ConstPtr &EndDtdEvent::dtdPointer() const -{ - return dtd_; -} - -inline -const Lpd &EndLpdEvent::lpd() const -{ - return *lpd_; -} - -inline -const ConstPtr &EndLpdEvent::lpdPointer() const -{ - return lpd_; -} - -inline -const Dtd &EndPrologEvent::dtd() const -{ - return *dtd_; -} - -inline -const ConstPtr &EndPrologEvent::dtdPointer() const -{ - return dtd_; -} - -inline -const ConstPtr &EndPrologEvent::lpdPointer() const -{ - return lpd_; -} - -inline -const Vector &EndPrologEvent::simpleLinkNames() const -{ - return simpleLinkNames_; -} - -inline -const Vector &EndPrologEvent::simpleLinkAttributes() const -{ - return simpleLinkAttributes_; -} - -inline -const Sd &SgmlDeclEvent::sd() const -{ - return *sd_; -} - -inline -const ConstPtr &SgmlDeclEvent::sdPointer() const -{ - return sd_; -} - -inline -const ConstPtr &SgmlDeclEvent::refSdPointer() const -{ - return refSd_; -} - -inline -const Syntax &SgmlDeclEvent::prologSyntax() const -{ - return *prologSyntax_; -} - -inline -const ConstPtr &SgmlDeclEvent::prologSyntaxPointer() const -{ - return prologSyntax_; -} - -inline -const Syntax &SgmlDeclEvent::instanceSyntax() const -{ - return *instanceSyntax_; -} - -inline -const ConstPtr &SgmlDeclEvent::instanceSyntaxPointer() const -{ - return instanceSyntax_; -} - -inline -const ConstPtr &SgmlDeclEvent::refSyntaxPointer() const -{ - return refSyntax_; -} - -inline -const StringC &SgmlDeclEvent::implySystemId() const -{ - return implySystemId_; -} - -inline -Char IgnoredRsEvent::rs() const -{ - return c_; -} - -inline -Char IgnoredReEvent::re() const -{ - return c_; -} - -inline -unsigned long IgnoredReEvent::serial() const -{ - return serial_; -} - -inline -Char ReOriginEvent::re() const -{ - return c_; -} - -inline -unsigned long ReOriginEvent::serial() const -{ - return serial_; -} - -inline -MarkedSectionEvent::Status MarkedSectionEvent::status() const -{ - return status_; -} - -inline -const Entity *EntityStartEvent::entity() const -{ - return origin_->entity().pointer(); -} - -inline -const ConstPtr & -EntityStartEvent::entityOrigin() const -{ - return origin_; -} - -inline -const ConstPtr &EntityDeclEvent::entityPointer() const -{ - return entity_; -} - -inline -const Entity &EntityDeclEvent::entity() const -{ - return *entity_; -} - -inline -Boolean EntityDeclEvent::ignored() const -{ - return ignored_; -} - -inline -const Notation &NotationDeclEvent::notation() const -{ - return *notation_; -} - -inline -const ConstPtr &NotationDeclEvent::notationPointer() const -{ - return notation_; -} - -inline -const Vector &ElementDeclEvent::elements() const -{ - return elements_; -} - -inline -const Vector &AttlistDeclEvent::elements() const -{ - return elements_; -} - -inline -const Vector &LinkAttlistDeclEvent::elements() const -{ - return elements_; -} - -inline -const Lpd &LinkAttlistDeclEvent::lpd() const -{ - return *lpd_; -} - -inline -const LinkSet *LinkDeclEvent::linkSet() const -{ - return linkSet_; -} - -inline -const ComplexLpd &LinkDeclEvent::lpd() const -{ - return *lpd_; -} - -inline -const ComplexLpd &IdLinkDeclEvent::lpd() const -{ - return *lpd_; -} - -inline -const Vector > & -AttlistNotationDeclEvent::notations() const -{ - return notations_; -} - -inline -const ShortReferenceMap *ShortrefDeclEvent::map() const -{ - return map_; -} - -inline -const Entity &EntityDefaultedEvent::entity() const -{ - return *entity_; -} - -inline -const ConstPtr &EntityDefaultedEvent::entityPointer() - const -{ - return entity_; -} - -inline -const PublicId &SgmlDeclEntityEvent::publicId() const -{ - return publicId_; -} - -inline -PublicId::TextClass SgmlDeclEntityEvent::entityType() const -{ - return entityType_; -} - -inline -const StringC &SgmlDeclEntityEvent::effectiveSystemId() const -{ - return effectiveSystemId_; -} - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* not Event_INCLUDED */ diff --git a/cde/programs/nsgmls/EventGenerator.C b/cde/programs/nsgmls/EventGenerator.C deleted file mode 100644 index cacc5b376..000000000 --- a/cde/programs/nsgmls/EventGenerator.C +++ /dev/null @@ -1,48 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: EventGenerator.C /main/1 1996/07/29 16:51:25 cde-hp $ */ -// Copyright (c) 1995 James Clark -// See the file COPYING for copying permission. - -#ifdef __GNUG__ -#pragma implementation -#endif - -#include "splib.h" -#include "Boolean.h" -#include "EventGenerator.h" - -EventGenerator::~EventGenerator() -{ -} - -void EventGenerator::inhibitMessages(bool) -{ -} - -EventGenerator * -EventGenerator::makeSubdocEventGenerator(const SGMLApplication::Char *, - size_t) -{ - return 0; -} diff --git a/cde/programs/nsgmls/EventGenerator.h b/cde/programs/nsgmls/EventGenerator.h deleted file mode 100644 index 9e67b6efa..000000000 --- a/cde/programs/nsgmls/EventGenerator.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: EventGenerator.h /main/1 1996/07/29 16:51:29 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#ifndef EventGenerator_INCLUDED -#define EventGenerator_INCLUDED 1 - -#ifdef __GNUG__ -#pragma interface -#endif - -#include "SGMLApplication.h" - -class SP_API EventGenerator { -public: - virtual ~EventGenerator(); - // Can be called at most once for any object. - // Returns number of errors. - virtual unsigned run(SGMLApplication &) = 0; - // may be called at any time - virtual void inhibitMessages(bool); - // may be called at any time, even from another thread - virtual void halt() = 0; - // called after run - virtual EventGenerator * - makeSubdocEventGenerator(const SGMLApplication::Char *systemId, - size_t systemIdLength); -}; - -#endif /* not EventGenerator_INCLUDED */ diff --git a/cde/programs/nsgmls/EventQueue.h b/cde/programs/nsgmls/EventQueue.h deleted file mode 100644 index 453d5bbca..000000000 --- a/cde/programs/nsgmls/EventQueue.h +++ /dev/null @@ -1,81 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: EventQueue.h /main/1 1996/07/29 16:51:33 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#ifndef EventQueue_INCLUDED -#define EventQueue_INCLUDED 1 - -#include "IQueue.h" -#include "Event.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -class EventQueue : public EventHandler, public IQueue { -public: - EventQueue(); -private: -#define EVENT(c, f) void f(c *); -#include "events.h" -#undef EVENT - void append(Event *); -}; - -class Pass1EventHandler : public EventQueue { -public: - Pass1EventHandler(); - void init(EventHandler *origHandler); - void message(MessageEvent *); - Boolean hadError() const; - EventHandler *origHandler() const; -private: - Boolean hadError_; - EventHandler *origHandler_; -}; - -inline -void EventQueue::append(Event *event) -{ - IQueue::append(event); -} - -inline -Boolean Pass1EventHandler::hadError() const -{ - return hadError_; -} - -inline -EventHandler *Pass1EventHandler::origHandler() const -{ - return origHandler_; -} - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* not EventQueue_INCLUDED */ diff --git a/cde/programs/nsgmls/EventsWanted.h b/cde/programs/nsgmls/EventsWanted.h deleted file mode 100644 index 77f2d7359..000000000 --- a/cde/programs/nsgmls/EventsWanted.h +++ /dev/null @@ -1,114 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: EventsWanted.h /main/1 1996/07/29 16:51:38 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#ifndef EventsWanted_INCLUDED -#define EventsWanted_INCLUDED 1 - -#include "Boolean.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -class SP_API EventsWanted { -public: - EventsWanted(); - Boolean wantInstanceMarkup() const; - Boolean wantCommentDecls() const; // in instance - Boolean wantMarkedSections() const; // in instance - Boolean wantPrologMarkup() const; - void addInstanceMarkup(); - void addCommentDecls(); - void addMarkedSections(); - void addPrologMarkup(); -private: - PackedBoolean instanceMarkup_; - PackedBoolean commentDecls_; - PackedBoolean markedSections_; - PackedBoolean prologMarkup_; -}; - -inline -EventsWanted::EventsWanted() -: instanceMarkup_(0), commentDecls_(0), markedSections_(0), prologMarkup_(0) -{ -} - -inline -Boolean EventsWanted::wantInstanceMarkup() const -{ - return instanceMarkup_; -} - -inline -void EventsWanted::addInstanceMarkup() -{ - instanceMarkup_ = 1; - commentDecls_ = 1; - markedSections_ = 1; -} - -inline -Boolean EventsWanted::wantCommentDecls() const -{ - return commentDecls_; -} - -inline -void EventsWanted::addCommentDecls() -{ - commentDecls_ = 1; -} - -inline -Boolean EventsWanted::wantMarkedSections() const -{ - return markedSections_; -} - -inline -void EventsWanted::addMarkedSections() -{ - markedSections_ = 1; -} - -inline -Boolean EventsWanted::wantPrologMarkup() const -{ - return prologMarkup_; -} - -inline -void EventsWanted::addPrologMarkup() -{ - prologMarkup_ = 1; -} - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* not EventsWanted_INCLUDED */ diff --git a/cde/programs/nsgmls/ExtendEntityManager.C b/cde/programs/nsgmls/ExtendEntityManager.C deleted file mode 100644 index 5d8458995..000000000 --- a/cde/programs/nsgmls/ExtendEntityManager.C +++ /dev/null @@ -1,1915 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: ExtendEntityManager.C /main/1 1996/07/29 16:51:42 cde-hp $ */ -// Copyright (c) 1994, 1995, 1996 James Clark -// See the file COPYING for copying permission. - -#ifdef __GNUG__ -#pragma implementation -#endif - -#include "splib.h" -#include "ExtendEntityManager.h" -#include "Message.h" -#include "MessageArg.h" -#include "OffsetOrderedList.h" -#include "rtti.h" -#include "StorageManager.h" -#include "Vector.h" -#include "NCVector.h" -#include "Owner.h" -#include "RegisteredCodingSystem.h" -#include "constant.h" -#include "EntityManagerMessages.h" -#include "StorageObjectPosition.h" -#include "Owner.h" -#include "CodingSystem.h" -#include "InputSource.h" -#include "macros.h" -#include "EntityCatalog.h" - -#include -#include -#include -#include -#include - -#ifdef DECLARE_MEMMOVE -extern "C" { - void *memmove(void *, const void *, size_t); -} -#endif - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -const char EOFCHAR = '\032'; // Control-Z - -class ExternalInputSource; - -class EntityManagerImpl : public ExtendEntityManager { -public: - EntityManagerImpl(StorageManager *defaultStorageManager, - const InputCodingSystem *defaultCodingSystem); - void setCatalogManager(CatalogManager *catalogManager); - void registerStorageManager(StorageManager *); - void registerCodingSystem(const char *, const InputCodingSystem *); - InputSource *open(const StringC &sysid, - const CharsetInfo &, - InputSourceOrigin *, - Boolean mayRewind, - Messenger &); - InputSource *openIfExists(const StringC &sysid, - const CharsetInfo &, - InputSourceOrigin *, - Boolean mayRewind, - Messenger &); - ConstPtr makeCatalog(StringC &systemId, - const CharsetInfo &charset, - Messenger &mgr); - Boolean expandSystemId(const StringC &, - const Location &, - Boolean isNdata, - const CharsetInfo &, - const StringC *, - Messenger &, - StringC &); - Boolean mergeSystemIds(const Vector &, - Boolean mapCatalogDocument, - const CharsetInfo &, - Messenger &mgr, - StringC &) const; - StorageManager *lookupStorageType(const StringC &, const CharsetInfo &) const; - StorageManager *lookupStorageType(const char *) const; - StorageManager *guessStorageType(const StringC &, const CharsetInfo &) const; - const InputCodingSystem *lookupCodingSystem(const StringC &, - const CharsetInfo &, - const char *&) const; - Boolean resolveSystemId(const StringC &str, - const CharsetInfo &idCharset, - Messenger &mgr, - const Location &defLocation, - Boolean isNdata, - ParsedSystemId &parsedSysid) const; - Boolean parseSystemId(const StringC &str, - const CharsetInfo &idCharset, - Boolean isNdata, - const StorageObjectSpec *defSpec, - Messenger &mgr, - ParsedSystemId &parsedSysid) const; -private: - EntityManagerImpl(const EntityManagerImpl &); // undefined - void operator=(const EntityManagerImpl &); // undefined - static const StorageObjectSpec *defStorageObject(const Location &); - static Boolean matchKey(const StringC &type, const char *s, - const CharsetInfo &docCharset); - NCVector > storageManagers_; - Vector codingSystems_; - Owner defaultStorageManager_; - const InputCodingSystem *defaultCodingSystem_; - Owner catalogManager_; - friend class FSIParser; -}; - -class ExternalInfoImpl : public ExternalInfo { - RTTI_CLASS -public: - ExternalInfoImpl(ParsedSystemId &parsedSysid); - const StorageObjectSpec &spec(size_t i) const; - size_t nSpecs() const; - const ParsedSystemId &parsedSystemId() const; - void noteRS(Offset); - void noteStorageObjectEnd(Offset); - void noteInsertedRSs(); - void setDecoder(size_t i, Decoder *); - StringC &id(size_t i); - Boolean convertOffset(Offset, StorageObjectLocation &) const; -private: - ParsedSystemId parsedSysid_; - NCVector position_; - size_t currentIndex_; - // list of inserted RSs - OffsetOrderedList rsList_; - Boolean notrack_; -}; - -class ExternalInputSource : public InputSource { -public: - ExternalInputSource(ParsedSystemId &parsedSysid, - InputSourceOrigin *origin, - Boolean mayRewind, - Boolean mayNotExist = 0); - void pushCharRef(Char, const NamedCharRef &); - ~ExternalInputSource(); -private: - Xchar fill(Messenger &); - Boolean rewind(Messenger &); - void willNotRewind(); - - void init(); - void noteRS(); - void noteRSAt(const Char *); - void reallocateBuffer(size_t size); - void insertChar(Char); - static const Char *findNextCr(const Char *start, const Char *end); - static const Char *findNextLf(const Char *start, const Char *end); - static const Char *findNextCrOrLf(const Char *start, const Char *end); - - ExternalInfoImpl *info_; - Char *buf_; - const Char *bufLim_; - Offset bufLimOffset_; - size_t bufSize_; - size_t readSize_; - NCVector > sov_; - StorageObject *so_; - size_t soIndex_; - Boolean insertRS_; - Decoder *decoder_; - const char *leftOver_; - size_t nLeftOver_; - Boolean mayRewind_; - Boolean mayNotExist_; - enum RecordType { - unknown, - crUnknown, - crlf, - lf, - cr, - asis - }; - RecordType recordType_; - Boolean zapEof_; -}; - -class FSIParser { -public: - FSIParser(const StringC &, const CharsetInfo &idCharset, - Boolean isNdata, - const StorageObjectSpec *defSpec, - const EntityManagerImpl *em, - Messenger &mgr); - Boolean parse(ParsedSystemId &parsedSysid); - static const char *recordsName(StorageObjectSpec::Records records); - struct RecordType { - const char *name; - StorageObjectSpec::Records value; - }; -private: - Boolean handleInformal(size_t startIndex, ParsedSystemId &parsedSysid); - Boolean convertId(StringC &, Xchar smcrd, const StorageManager *); - Xchar get(); - void unget(); - StorageManager *lookupStorageType(const StringC &key, Boolean &neutral); - Boolean matchKey(const StringC &, const char *); - Boolean matchChar(Xchar, char); - Boolean isS(Xchar); - Boolean convertDigit(Xchar c, int &weight); - void uncharref(StringC &); - Boolean setAttributes(StorageObjectSpec &sos, Boolean neutral, - Xchar &smcrd, Boolean &fold); - Boolean setCatalogAttributes(ParsedSystemId &parsedSysid); - void setDefaults(StorageObjectSpec &sos); - Boolean parseAttribute(StringC &token, Boolean &gotValue, StringC &value); - Boolean lookupRecords(const StringC &token, StorageObjectSpec::Records &); - void convertMinimumLiteral(const StringC &from, StringC &to); - - const StringC &str_; - size_t strIndex_; - Messenger &mgr_; - const EntityManagerImpl *em_; - const StorageObjectSpec *defSpec_; - const CharsetInfo &idCharset_; - Boolean isNdata_; - static RecordType recordTypeTable[]; -}; - -const Char RS = '\n'; -const Char RE = '\r'; -const char lineEnd = '\n'; - -ExtendEntityManager::CatalogManager::~CatalogManager() -{ -} - -ExtendEntityManager *ExtendEntityManager::make(StorageManager *sm, - const InputCodingSystem *cs) -{ - return new EntityManagerImpl(sm, cs); -} - -Boolean ExtendEntityManager::externalize(const ExternalInfo *info, - Offset off, - StorageObjectLocation &loc) -{ - if (!info) - return false; - const ExternalInfoImpl *p = DYNAMIC_CAST_CONST_PTR(ExternalInfoImpl, info); - if (!p) - return false; - return p->convertOffset(off, loc); -} - -const ParsedSystemId * -ExtendEntityManager::externalInfoParsedSystemId(const ExternalInfo *info) -{ - if (!info) - return 0; - const ExternalInfoImpl *p = DYNAMIC_CAST_CONST_PTR(ExternalInfoImpl, info); - if (!p) - return 0; - return &p->parsedSystemId(); -} - - -EntityManagerImpl::EntityManagerImpl(StorageManager *defaultStorageManager, - const InputCodingSystem *defaultCodingSystem) -: defaultStorageManager_(defaultStorageManager), - defaultCodingSystem_(defaultCodingSystem) -{ -} - -InputSource *EntityManagerImpl::open(const StringC &sysid, - const CharsetInfo &docCharset, - InputSourceOrigin *origin, - Boolean mayRewind, - Messenger &mgr) -{ - ParsedSystemId parsedSysid; - if (!parseSystemId(sysid, docCharset, 0, 0, mgr, parsedSysid) - || !catalogManager_->mapCatalog(parsedSysid, this, mgr)) - return 0; - return new ExternalInputSource(parsedSysid, origin, mayRewind, 0); -} - -InputSource *EntityManagerImpl::openIfExists(const StringC &sysid, - const CharsetInfo &docCharset, - InputSourceOrigin *origin, - Boolean mayRewind, - Messenger &mgr) -{ - ParsedSystemId parsedSysid; - if (!parseSystemId(sysid, docCharset, 0, 0, mgr, parsedSysid) - || !catalogManager_->mapCatalog(parsedSysid, this, mgr)) - return 0; - return new ExternalInputSource(parsedSysid, origin, mayRewind, 1); -} - -ConstPtr -EntityManagerImpl::makeCatalog(StringC &systemId, - const CharsetInfo &charset, - Messenger &mgr) -{ - return catalogManager_->makeCatalog(systemId, charset, this, mgr); -} - -Boolean -EntityManagerImpl::mergeSystemIds(const Vector &sysids, - Boolean mapCatalogDocument, - const CharsetInfo &charset, - Messenger &mgr, - StringC &result) const -{ - ParsedSystemId parsedSysid; - if (mapCatalogDocument) { - parsedSysid.maps.resize(parsedSysid.maps.size() + 1); - parsedSysid.maps.back().type = ParsedSystemIdMap::catalogDocument; - } - for (size_t i = 0; i < sysids.size(); i++) - if (!parseSystemId(sysids[i], - charset, - 0, - 0, - mgr, - parsedSysid)) - return 0; - parsedSysid.unparse(charset, result); - return 1; -} - -Boolean -EntityManagerImpl::expandSystemId(const StringC &str, - const Location &defLocation, - Boolean isNdata, - const CharsetInfo &charset, - const StringC *mapCatalogPublic, - Messenger &mgr, - StringC &result) -{ - ParsedSystemId parsedSysid; - const StorageObjectSpec *defSpec = defStorageObject(defLocation); - if (!parseSystemId(str, charset, isNdata, defSpec, mgr, parsedSysid)) - return 0; - if (mapCatalogPublic) { - ParsedSystemIdMap map; - map.type = ParsedSystemIdMap::catalogPublic; - map.publicId = *mapCatalogPublic; - parsedSysid.maps.insert(parsedSysid.maps.begin(), 1, map); - } - parsedSysid.unparse(charset, result); - return 1; -} - -Boolean EntityManagerImpl::parseSystemId(const StringC &str, - const CharsetInfo &idCharset, - Boolean isNdata, - const StorageObjectSpec *defSpec, - Messenger &mgr, - ParsedSystemId &parsedSysid) const -{ - FSIParser fsiParser(str, idCharset, isNdata, defSpec, this, mgr); - return fsiParser.parse(parsedSysid); -} - -StorageManager * -EntityManagerImpl::guessStorageType(const StringC &type, - const CharsetInfo &docCharset) const -{ - for (size_t i = 0; i < storageManagers_.size(); i++) - if (storageManagers_[i]->guessIsId(type, docCharset)) - return storageManagers_[i].pointer(); - if (defaultStorageManager_->guessIsId(type, docCharset)) - return defaultStorageManager_.pointer(); - return 0; -} - -StorageManager * -EntityManagerImpl::lookupStorageType(const StringC &type, - const CharsetInfo &docCharset) const -{ - if (type.size() == 0) - return 0; - if (matchKey(type, defaultStorageManager_->type(), docCharset)) - return defaultStorageManager_.pointer(); - for (size_t i = 0; i < storageManagers_.size(); i++) - if (matchKey(type, storageManagers_[i]->type(), docCharset)) - return storageManagers_[i].pointer(); - return 0; -} - -StorageManager * -EntityManagerImpl::lookupStorageType(const char *type) const -{ - if (type == defaultStorageManager_->type()) - return defaultStorageManager_.pointer(); - for (size_t i = 0; i < storageManagers_.size(); i++) - if (type == storageManagers_[i]->type()) - return storageManagers_[i].pointer(); - return 0; -} - -const InputCodingSystem * -EntityManagerImpl::lookupCodingSystem(const StringC &type, - const CharsetInfo &docCharset, - const char *&name) const -{ - for (size_t i = 0; i < codingSystems_.size(); i++) - if (matchKey(type, codingSystems_[i].name, docCharset)) { - name = codingSystems_[i].name; - return codingSystems_[i].ics; - } - return 0; -} - -Boolean -EntityManagerImpl::matchKey(const StringC &type, - const char *s, - const CharsetInfo &docCharset) -{ - if (strlen(s) != type.size()) - return false; - for (size_t i = 0; i < type.size(); i++) - if (docCharset.execToDesc(toupper(s[i])) != type[i] - && docCharset.execToDesc(tolower(s[i])) != type[i]) - return false; - return true; -} - -void EntityManagerImpl::registerStorageManager(StorageManager *sm) -{ - storageManagers_.resize(storageManagers_.size() + 1); - storageManagers_.back() = sm; -} - -void EntityManagerImpl::registerCodingSystem(const char *name, - const InputCodingSystem *ics) -{ - codingSystems_.resize(codingSystems_.size() + 1); - RegisteredCodingSystem &rcs = codingSystems_.back(); - rcs.name = name; - rcs.ics = ics; -} - -void EntityManagerImpl::setCatalogManager(CatalogManager *catalogManager) -{ - catalogManager_ = catalogManager; -} - -const StorageObjectSpec * -EntityManagerImpl::defStorageObject(const Location &defLocation) -{ - Offset off; - const ExternalInfo *info; - Location loc(defLocation); - for (;;) { - if (loc.origin().isNull()) - return 0; - const InputSourceOrigin *inputSourceOrigin = loc.origin()->asInputSourceOrigin(); - if (inputSourceOrigin) { - off = inputSourceOrigin->startOffset(loc.index()); - info = inputSourceOrigin->externalInfo(); - if (info) - break; - if (!inputSourceOrigin->defLocation(off, loc)) - return 0; - } - else - loc = loc.origin()->parent(); - } - StorageObjectLocation soLoc; - if (!ExtendEntityManager::externalize(info, off, soLoc)) - return 0; - return soLoc.storageObjectSpec; -} - -ExternalInputSource::ExternalInputSource(ParsedSystemId &parsedSysid, - InputSourceOrigin *origin, - Boolean mayRewind, - Boolean mayNotExist) -: InputSource(origin, 0, 0), - mayRewind_(mayRewind), - mayNotExist_(mayNotExist), - sov_(parsedSysid.size()), - readSize_(0), - decoder_(NULL), - recordType_(unknown), - zapEof_(false) -{ - init(); - info_ = new ExternalInfoImpl(parsedSysid); - origin->setExternalInfo(info_); -} - -void ExternalInputSource::init() -{ - so_ = 0; - buf_ = 0; - bufSize_ = 0; - bufLim_ = 0; - bufLimOffset_ = 0; - insertRS_ = true; - soIndex_ = 0; - leftOver_ = 0; - nLeftOver_ = 0; -} - -ExternalInputSource::~ExternalInputSource() -{ - if (buf_) - delete [] buf_; -} - -Boolean ExternalInputSource::rewind(Messenger &mgr) -{ - reset(0, 0); - if (buf_) - delete [] buf_; - // reset makes a new EntityOrigin - ParsedSystemId parsedSysid(info_->parsedSystemId()); - info_ = new ExternalInfoImpl(parsedSysid); - inputSourceOrigin()->setExternalInfo(info_); - so_ = 0; - for (size_t i = 0; i < soIndex_; i++) { - if (sov_[i] && !sov_[i]->rewind(mgr)) - return 0; - } - init(); - return 1; -} - -void ExternalInputSource::willNotRewind() -{ - for (size_t i = 0; i < soIndex_; i++) - if (sov_[i]) - sov_[i]->willNotRewind(); - mayRewind_ = 0; -} - -// Round up N so that it is a power of TO. -// TO must be a power of 2. - -inline -size_t roundUp(size_t n, size_t to) -{ - return (n + (to - 1)) & ~(to - 1); -} - -inline -void ExternalInputSource::noteRSAt(const Char *p) -{ - info_->noteRS(bufLimOffset_ - (bufLim_ - p)); -} - -inline -void ExternalInputSource::noteRS() -{ - noteRSAt(cur()); -} - -Xchar ExternalInputSource::fill(Messenger &mgr) -{ - ASSERT(cur() == end()); - while (end() >= bufLim_) { - // need more data - while (so_ == 0) { - if (soIndex_ >= sov_.size()) - return eE; - if (soIndex_ > 0) - info_->noteStorageObjectEnd(bufLimOffset_ - (bufLim_ - end())); - const StorageObjectSpec &spec = info_->spec(soIndex_); - if (mayNotExist_) { - NullMessenger nullMgr; - sov_[soIndex_] - = spec.storageManager->makeStorageObject(spec.specId, spec.baseId, - spec.search, - mayRewind_, nullMgr, - info_->id(soIndex_)); - } - else - sov_[soIndex_] - = spec.storageManager->makeStorageObject(spec.specId, spec.baseId, - spec.search, - mayRewind_, mgr, - info_->id(soIndex_)); - so_ = sov_[soIndex_].pointer(); - if (so_) { - decoder_ = spec.codingSystem->makeDecoder(); - info_->setDecoder(soIndex_, decoder_); - zapEof_ = spec.zapEof; - switch (spec.records) { - case StorageObjectSpec::asis: - recordType_ = asis; - insertRS_ = false; - break; - case StorageObjectSpec::cr: - recordType_ = cr; - break; - case StorageObjectSpec::lf: - recordType_ = lf; - break; - case StorageObjectSpec::crlf: - recordType_ = crlf; - break; - case StorageObjectSpec::find: - recordType_ = unknown; - break; - default: - CANNOT_HAPPEN(); - } - soIndex_++; - readSize_ = so_->getBlockSize(); - nLeftOver_ = 0; - break; - } - else - setAccessError(); - soIndex_++; - } - - size_t keepSize = end() - start(); - const size_t align = sizeof(int)/sizeof(Char); - size_t readSizeChars = (readSize_ + (sizeof(Char) - 1))/sizeof(Char); - readSizeChars = roundUp(readSizeChars, align); - size_t neededSize; // in Chars - size_t startOffset; - // compute neededSize and readSize - unsigned minBytesPerChar = decoder_->minBytesPerChar(); - if (nLeftOver_ == 0 && minBytesPerChar >= sizeof(Char)) { - // In this case we want to do decoding in place. - // FIXME It might be a win on some systems (Irix?) to arrange that the - // read buffer is on a page boundary. - - if (keepSize >= size_t(-1)/sizeof(Char) - (align - 1) - insertRS_) - abort(); // FIXME throw an exception - - // Now size_t(-1)/sizeof(Char) - (align - 1) - insertRS_ - keepSize > 0 - if (readSizeChars - > size_t(-1)/sizeof(Char) - (align - 1) - insertRS_ - keepSize) - abort(); - neededSize = roundUp(readSizeChars + keepSize + insertRS_, align); - startOffset = ((neededSize > bufSize_ ? neededSize : bufSize_) - - readSizeChars - insertRS_ - keepSize); - } - else { - // Needs to be room for everything before decoding. - neededSize = (keepSize + insertRS_ + readSizeChars - + (nLeftOver_ + sizeof(Char) - 1)/sizeof(Char)); - // Also must be room for everything after decoding. - size_t neededSize2 - = (keepSize + insertRS_ - // all the converted characters - + (nLeftOver_ + readSize_)/minBytesPerChar - // enough Chars to contain left over bytes - + ((readSize_ % minBytesPerChar + sizeof(Char) - 1) - / sizeof(Char))); - if (neededSize2 > neededSize) - neededSize = neededSize2; - neededSize = roundUp(neededSize, align); - if (neededSize > size_t(-1)/sizeof(Char)) - abort(); - startOffset = 0; - } - if (bufSize_ < neededSize) - reallocateBuffer(neededSize); - Char *newStart = buf_ + startOffset; - if (newStart != start() && keepSize > 0) - memmove(newStart, start(), keepSize*sizeof(Char)); - char *bytesStart = (char *)(buf_ + bufSize_ - readSizeChars) - nLeftOver_; - if (nLeftOver_ > 0 && leftOver_ != bytesStart) - memmove(bytesStart, leftOver_, nLeftOver_); - moveStart(newStart); - bufLim_ = end(); - - size_t nread; - if (so_->read((char *)(buf_ + bufSize_ - readSizeChars), readSize_, - mgr, nread)) { - if (nread > 0) { - const char *bytesEnd = bytesStart + nLeftOver_ + nread; - size_t nChars = decoder_->decode((Char *)end() + insertRS_, - bytesStart, - nLeftOver_ + nread - - (zapEof_ && bytesEnd[-1] == EOFCHAR), - &leftOver_); - nLeftOver_ = bytesEnd - leftOver_; - if (nChars > 0) { - if (insertRS_) { - noteRS(); - *(Char *)end() = RS; - advanceEnd(end() + 1); - insertRS_ = false; - bufLim_ += 1; - bufLimOffset_ += 1; - } - bufLim_ += nChars; - bufLimOffset_ += nChars; - break; - } - } - } - else - so_ = 0; - } - ASSERT(end() < bufLim_); - if (insertRS_) { - noteRS(); - insertChar(RS); - insertRS_ = false; - bufLimOffset_ += 1; - } - switch (recordType_) { - case unknown: - { - const Char *e = findNextCrOrLf(end(), bufLim_); - if (e) { - if (*e == '\n') { - recordType_ = lf; - info_->noteInsertedRSs(); - *(Char *)e = RE; - advanceEnd(e + 1); - insertRS_ = true; - } - else { - if (e + 1 < bufLim_) { - if (e[1] == '\n') { - recordType_ = crlf; - advanceEnd(e + 1); - if (e + 2 == bufLim_) { - bufLim_--; - bufLimOffset_--; - insertRS_ = true; - } - } - else { - advanceEnd(e + 1); - recordType_ = cr; - info_->noteInsertedRSs(); - insertRS_ = true; - } - } - else { - recordType_ = crUnknown; - advanceEnd(e + 1); - } - } - } - else - advanceEnd(bufLim_); - } - break; - case crUnknown: - { - if (*cur() == '\n') { - noteRS(); - advanceEnd(cur() + 1); - recordType_ = crlf; - } - else { - advanceEnd(cur() + 1); - insertRS_ = true; - recordType_ = cr; - info_->noteInsertedRSs(); - } - } - break; - case lf: - { - Char *e = (Char *)findNextLf(end(), bufLim_); - if (e) { - advanceEnd(e + 1); - *e = RE; - insertRS_ = true; - } - else - advanceEnd(bufLim_); - } - break; - case cr: - { - const Char *e = findNextCr(end(), bufLim_); - if (e) { - advanceEnd(e + 1); - insertRS_ = true; - } - else - advanceEnd(bufLim_); - } - break; - case crlf: - { - const Char *e = end(); - for (;;) { - e = findNextLf(e, bufLim_); - if (!e) { - advanceEnd(bufLim_); - break; - } - // Need to delete final RS if not followed by anything. - if (e + 1 == bufLim_) { - bufLim_--; - bufLimOffset_--; - advanceEnd(e); - insertRS_ = true; - break; - } - noteRSAt(e); - e++; - } - } - break; - case asis: - advanceEnd(bufLim_); - break; - default: - CANNOT_HAPPEN(); - } - - return nextChar(); -} - -const Char *ExternalInputSource::findNextCr(const Char *start, - const Char *end) -{ - for (; start < end; start++) - if (*start == '\r') - return start; - return 0; -} - -const Char *ExternalInputSource::findNextLf(const Char *start, - const Char *end) -{ - for (; start < end; start++) - if (*start == '\n') - return start; - return 0; -} - -const Char *ExternalInputSource::findNextCrOrLf(const Char *start, - const Char *end) -{ - for (; start < end; start++) - if (*start == '\n' || *start == '\r') - return start; - return 0; -} - -void ExternalInputSource::pushCharRef(Char ch, const NamedCharRef &ref) -{ - ASSERT(cur() == start()); - noteCharRef(startIndex() + (cur() - start()), ref); - insertChar(ch); -} - -void ExternalInputSource::insertChar(Char ch) -{ - if (start() > buf_) { - if (cur() > start()) - memmove((Char *)start() - 1, start(), (cur() - start())*sizeof(Char)); - moveLeft(); - *(Char *)cur() = ch; - } - else { - // must have start == buf - if (buf_ + (bufSize_ - (nLeftOver_ + sizeof(Char) - 1)/sizeof(Char)) - == bufLim_) { - if (bufSize_ == size_t(-1)) - abort(); // FIXME throw an exception - reallocateBuffer(bufSize_ + 1); - } - else if (nLeftOver_ > 0 && ((char *)(bufLim_ + 1) > leftOver_)) { - char *s = (char *)(buf_ + bufSize_) - nLeftOver_; - memmove(s, leftOver_, nLeftOver_); - leftOver_ = s; - } - if (cur() < bufLim_) - memmove((Char *)cur() + 1, cur(), (bufLim_ - cur())*sizeof(Char)); - *(Char *)cur() = ch; - advanceEnd(end() + 1); - bufLim_ += 1; - } -} - -void ExternalInputSource::reallocateBuffer(size_t newSize) -{ - Char *newBuf = new Char[newSize]; - - memcpy(newBuf, buf_, bufSize_*sizeof(Char)); - bufSize_ = newSize; - changeBuffer(newBuf, buf_); - bufLim_ = newBuf + (bufLim_ - buf_); - if (nLeftOver_ > 0) { - char *s = (char *)(newBuf + bufSize_) - nLeftOver_; - memmove(s, - newBuf + (leftOver_ - (char *)buf_), - nLeftOver_); - leftOver_ = s; - } - delete [] buf_; - buf_ = newBuf; -} - -RTTI_DEF1(ExternalInfoImpl, ExternalInfo) - -ExternalInfoImpl::ExternalInfoImpl(ParsedSystemId &parsedSysid) -: currentIndex_(0), position_(parsedSysid.size()) -{ - parsedSysid.swap(parsedSysid_); - if (parsedSysid_.size() > 0) { - notrack_ = parsedSysid_[0].notrack; - } else { - notrack_ = false; - } -} - -StringC &ExternalInfoImpl::id(size_t i) -{ - return parsedSysid_[i].id; -} - -void ExternalInfoImpl::setDecoder(size_t i, Decoder *decoder) -{ - position_[i].decoder = decoder; -} - -void ExternalInfoImpl::noteInsertedRSs() -{ - position_[currentIndex_].insertedRSs = 1; -} - -void ExternalInfoImpl::noteRS(Offset offset) -{ - if (!notrack_) - rsList_.append(offset); - if (offset - == (currentIndex_ == 0 ? 0 : position_[currentIndex_- 1].endOffset)) - position_[currentIndex_].startsWithRS = 1; -} - -void ExternalInfoImpl::noteStorageObjectEnd(Offset offset) -{ - ASSERT(currentIndex_ < position_.size()); - // The last endOffset_ must be -1. - if (currentIndex_ < position_.size() - 1) { - position_[currentIndex_++].endOffset = offset; - position_[currentIndex_].line1RS = rsList_.size(); - notrack_ = parsedSysid_[currentIndex_].notrack; - } -} - -Boolean ExternalInfoImpl::convertOffset(Offset off, - StorageObjectLocation &ret) const -{ - ret.storageObjectSpec = 0; - if (off == Offset(-1) || position_.size() == 0) - return false; - // the last endOffset_ is Offset(-1), so this will - // terminate - int i; - for (i = 0; off >= position_[i].endOffset; i++) - ; - for (; parsedSysid_[i].id.size() == 0; i--) - if (i == 0) - return false; - ret.storageObjectSpec = &parsedSysid_[i]; - Offset startOffset = i == 0 ? 0 : position_[i - 1].endOffset; - ret.storageObjectOffset = off - startOffset; - ret.byteIndex = ret.storageObjectOffset; - if (parsedSysid_[i].notrack - || parsedSysid_[i].records == StorageObjectSpec::asis) { - ret.lineNumber = (unsigned long)-1; - if (parsedSysid_[i].records != StorageObjectSpec::asis) { - if (position_[i].insertedRSs) - ret.byteIndex = (unsigned long)-1; - else if (ret.byteIndex > 0 && position_[i].startsWithRS) - ret.byteIndex--; // first RS is inserted - } - ret.columnNumber = (unsigned long)-1; - return true; - } - else { - size_t line1RS = position_[i].line1RS; - // line1RS is now the number of RSs that are before or on the current line. - size_t j; - Offset colStart; - if (rsList_.findPreceding(off, j, colStart)) { - if (position_[i].insertedRSs) - ret.byteIndex -= j + 1 - line1RS; - else if (ret.byteIndex > 0 && position_[i].startsWithRS) - ret.byteIndex--; // first RS is inserted - j++; - colStart++; - } - else { - j = 0; - colStart = 0; - } - // j is now the number of RSs that are before or on the current line - // colStart is the offset of the first column - ret.lineNumber = j - line1RS + 1 - position_[i].startsWithRS; - // the offset of the first column - if (colStart < startOffset) - colStart = startOffset; - // the RS that starts a line will be in column 0; - // the first real character of a line will be column 1 - ret.columnNumber = 1 + off - colStart; - } - if (!position_[i].decoder - || !position_[i].decoder->convertOffset(ret.byteIndex)) - ret.byteIndex = (unsigned long)-1; - return true; -} - -const StorageObjectSpec &ExternalInfoImpl::spec(size_t i) const -{ - return parsedSysid_[i]; -} - -size_t ExternalInfoImpl::nSpecs() const -{ - return parsedSysid_.size(); -} - -const ParsedSystemId &ExternalInfoImpl::parsedSystemId() const -{ - return parsedSysid_; -} - -StorageObjectSpec::StorageObjectSpec() -: storageManager(0), codingSystem(0), codingSystemName(0), notrack(0), - records(find), zapEof(1), search(1) -{ -} - -StorageObjectPosition::StorageObjectPosition() -: endOffset(Offset(-1)), line1RS(0), startsWithRS(0), insertedRSs(0) -{ -} - -FSIParser::FSIParser(const StringC &str, - const CharsetInfo &idCharset, - Boolean isNdata, - const StorageObjectSpec *defSpec, - const EntityManagerImpl *em, - Messenger &mgr) -: str_(str), - strIndex_(0), - idCharset_(idCharset), - isNdata_(isNdata), - defSpec_(defSpec), - em_(em), - mgr_(mgr) -{ -} - -Xchar FSIParser::get() -{ - if (strIndex_ < str_.size()) - return str_[strIndex_++]; - else - return -1; -} - -void FSIParser::unget() -{ - if (strIndex_ > 0) - strIndex_ -= 1; -} - -Boolean FSIParser::matchKey(const StringC &str, const char *s) -{ - if (strlen(s) != str.size()) - return false; - for (size_t i = 0; i < str.size(); i++) - if (idCharset_.execToDesc(toupper(s[i])) != str[i] - && idCharset_.execToDesc(tolower(s[i])) != str[i]) - return false; - return true; -} - -Boolean FSIParser::matchChar(Xchar ch, char execC) -{ - return ch == idCharset_.execToDesc(execC); -} - -Boolean FSIParser::isS(Xchar c) -{ - return (matchChar(c, ' ') - || matchChar(c, '\r') - || matchChar(c, '\n') - || matchChar(c, ' ')); -} - -Boolean FSIParser::convertDigit(Xchar c, int &weight) -{ - static const char digits[] = "0123456789"; - for (int i = 0; digits[i] != '\0'; i++) - if (matchChar(c, digits[i])) { - weight = i; - return 1; - } - return 0; -} - -Boolean FSIParser::parse(ParsedSystemId &parsedSysid) -{ - size_t startIndex = strIndex_; - if (!matchChar(get(), '<')) - return handleInformal(startIndex, parsedSysid); - StringC key; - for (;;) { - Xchar c = get(); - if (c == -1) - return handleInformal(startIndex, parsedSysid); - if (isS(c) || matchChar(c, '>')) - break; - key += Char(c); - } - unget(); - if (matchKey(key, "CATALOG")) { - if (!setCatalogAttributes(parsedSysid)) - return 0; - return parse(parsedSysid); - } - Boolean neutral; - StorageManager *sm = lookupStorageType(key, neutral); - if (!sm) - return handleInformal(startIndex, parsedSysid); - for (;;) { - parsedSysid.resize(parsedSysid.size() + 1); - StorageObjectSpec &sos = parsedSysid.back(); - sos.storageManager = sm; - Xchar smcrd; - Boolean fold; - if (!setAttributes(sos, neutral, smcrd, fold)) - return 0; - sm = 0; - StringC id; - Boolean hadData = 0; - for (;;) { - Xchar c = get(); - if (c == -1) - break; - if (matchChar(c, '<')) { - hadData = 1; - Char stago = c; - key.resize(0); - for (;;) { - c = get(); - if (c == -1) { - id += stago; - id += key; - break; - } - if (isS(c) || matchChar(c, '>')) { - unget(); - sm = lookupStorageType(key, neutral); - if (!sm) { - id += stago; - id += key; - } - break; - } - key += c; - } - if (sm) - break; - } - else if (!((!hadData && matchChar(c, '\r')) // ignored RE - || matchChar(c, '\n') )) { // ignored RS - hadData = 1; - id += c; - } - } - if (id.size() > 0 && matchChar(id[id.size() - 1], '\r')) - id.resize(id.size() - 1); - uncharref(id); - id.swap(sos.specId); - if (!convertId(sos.specId, smcrd, sos.storageManager)) - return 0; - if (neutral) { - if (!sos.storageManager->transformNeutral(sos.specId, fold, mgr_)) - return 0; - } - if (sos.storageManager->resolveRelative(sos.baseId, sos.specId, - sos.search)) - sos.baseId.resize(0); - if (!sm) - break; - } - return 1; -} - -Boolean FSIParser::handleInformal(size_t index, ParsedSystemId &parsedSysid) -{ - parsedSysid.resize(parsedSysid.size() + 1); - StorageObjectSpec &sos = parsedSysid.back(); - sos.specId.assign(str_.data() + index, - str_.size() - index); - sos.storageManager = em_->guessStorageType(sos.specId, idCharset_); - if (!sos.storageManager) { - if (defSpec_ && defSpec_->storageManager->inheritable()) - sos.storageManager = defSpec_->storageManager; - else - sos.storageManager = em_->defaultStorageManager_.pointer(); - } - setDefaults(sos); - if (!convertId(sos.specId, -1, sos.storageManager)) - return 0; - if (sos.storageManager->resolveRelative(sos.baseId, sos.specId, sos.search)) - sos.baseId.resize(0); - return 1; -} - -StorageManager *FSIParser::lookupStorageType(const StringC &key, - Boolean &neutral) -{ - if (matchKey(key, "NEUTRAL")) { - neutral = 1; - if (defSpec_ && defSpec_->storageManager->inheritable()) - return defSpec_->storageManager; - else - return em_->defaultStorageManager_.pointer(); - } - else { - StorageManager *sm = em_->lookupStorageType(key, idCharset_); - if (sm) - neutral = 0; - return sm; - } -} - -Boolean FSIParser::setCatalogAttributes(ParsedSystemId &parsedSysid) -{ - Boolean hadPublic = 0; - parsedSysid.maps.resize(parsedSysid.maps.size() + 1); - parsedSysid.maps.back().type = ParsedSystemIdMap::catalogDocument; - for (;;) { - StringC token, value; - Boolean gotValue; - if (!parseAttribute(token, gotValue, value)) { - mgr_.message(EntityManagerMessages::fsiSyntax, StringMessageArg(str_)); - return 0; - } - if (token.size() == 0) - break; - if (matchKey(token, "PUBLIC")) { - if (hadPublic) - mgr_.message(EntityManagerMessages::fsiDuplicateAttribute, - StringMessageArg(idCharset_.execToDesc("PUBLIC"))); - else if (gotValue) { - convertMinimumLiteral(value, parsedSysid.maps.back().publicId); - parsedSysid.maps.back().type = ParsedSystemIdMap::catalogPublic; - } - else - mgr_.message(EntityManagerMessages::fsiMissingValue, - StringMessageArg(token)); - hadPublic = 1; - } - else - mgr_.message(gotValue - ? EntityManagerMessages::fsiUnsupportedAttribute - : EntityManagerMessages::fsiUnsupportedAttributeToken, - StringMessageArg(token)); - } - return 1; -} - -void FSIParser::convertMinimumLiteral(const StringC &from, StringC &to) -{ - // Do just enough to ensure it can be reparsed. - to.resize(0); - for (size_t i = 0; i < from.size(); i++) { - Char c = from[i]; - if (matchChar(c, '"') || matchChar(c, '#')) - mgr_.message(EntityManagerMessages::fsiLookupChar, NumberMessageArg(c)); - else if (matchChar(c, ' ')) { - if (to.size() && to[to.size() - 1] != c) - to += c; - } - else - to += c; - } - if (to.size() && matchChar(to[to.size() - 1], ' ')) - to.resize(to.size() - 1); -} - -// FIXME This should be table driven. - -Boolean FSIParser::setAttributes(StorageObjectSpec &sos, - Boolean neutral, - Xchar &smcrd, - Boolean &fold) -{ - Boolean hadBctf = 0; - Boolean hadTracking = 0; - Boolean hadSmcrd = 0; - smcrd = -1; - fold = 1; - Boolean hadRecords = 0; - Boolean hadBase = 0; - Boolean hadZapeof = 0; - Boolean hadSearch = 0; - Boolean hadFold = 0; - StorageObjectSpec::Records records; - setDefaults(sos); - for (;;) { - StringC token, value; - Boolean gotValue; - if (!parseAttribute(token, gotValue, value)) { - mgr_.message(EntityManagerMessages::fsiSyntax, StringMessageArg(str_)); - return 0; - } - if (token.size() == 0) - break; - if (matchKey(token, "BCTF")) { - if (sos.storageManager->requiredCodingSystem()) - mgr_.message(EntityManagerMessages::fsiBctfNotApplicable); - else if (hadBctf) - mgr_.message(EntityManagerMessages::fsiDuplicateAttribute, - StringMessageArg(token)); - else if (gotValue) { - const char *codingSystemName; - const InputCodingSystem *codingSystem - = em_->lookupCodingSystem(value, idCharset_, codingSystemName); - if (codingSystem) { - sos.codingSystem = codingSystem; - sos.codingSystemName = codingSystemName; - } - else if (matchKey(value, "SAME")) { - if (isNdata_) { - if (defSpec_) { - sos.codingSystem = defSpec_->codingSystem; - sos.codingSystemName = defSpec_->codingSystemName; - } - else { - sos.codingSystem = em_->defaultCodingSystem_; - sos.codingSystemName = 0; - } - } - } - else - mgr_.message(EntityManagerMessages::fsiUnknownBctf, - StringMessageArg(value)); - } - else - mgr_.message(EntityManagerMessages::fsiMissingValue, - StringMessageArg(token)); - hadBctf = 1; - } - else if (matchKey(token, "TRACKING")) { - if (hadTracking) - mgr_.message(EntityManagerMessages::fsiDuplicateAttribute, - StringMessageArg(token)); - else if (gotValue) { - if (matchKey(value, "NOTRACK")) - sos.notrack = 1; - else if (!matchKey(value, "TRACK")) - mgr_.message(EntityManagerMessages::fsiBadTracking, - StringMessageArg(value)); - } - else - mgr_.message(EntityManagerMessages::fsiMissingValue, - StringMessageArg(token)); - hadTracking = 1; - } - else if (matchKey(token, "ZAPEOF")) { - if (sos.storageManager->requiredCodingSystem()) - mgr_.message(EntityManagerMessages::fsiZapeofNotApplicable); - else if (hadZapeof) - mgr_.message(EntityManagerMessages::fsiDuplicateAttribute, - StringMessageArg(token)); - else if (gotValue) { - if (matchKey(value, "ZAPEOF")) - sos.zapEof = 1; - else if (matchKey(value, "NOZAPEOF")) - sos.zapEof = 0; - else - mgr_.message(EntityManagerMessages::fsiBadZapeof, - StringMessageArg(value)); - } - else - sos.zapEof = 1; - hadZapeof = 1; - } - else if (matchKey(token, "NOZAPEOF")) { - if (sos.storageManager->requiredCodingSystem()) - mgr_.message(EntityManagerMessages::fsiZapeofNotApplicable); - else if (hadZapeof) - mgr_.message(EntityManagerMessages::fsiDuplicateAttribute, - StringMessageArg(idCharset_.execToDesc("ZAPEOF"))); - else if (gotValue) - mgr_.message(EntityManagerMessages::fsiValueAsName, - StringMessageArg(token)); - else - sos.zapEof = 0; - hadZapeof = 1; - } - else if (matchKey(token, "SEARCH")) { - if (hadSearch) - mgr_.message(EntityManagerMessages::fsiDuplicateAttribute, - StringMessageArg(token)); - else if (gotValue) { - if (matchKey(value, "SEARCH")) - sos.search = 1; - else if (matchKey(value, "NOSEARCH")) - sos.search = 0; - else - mgr_.message(EntityManagerMessages::fsiBadSearch, - StringMessageArg(value)); - } - else - sos.search = 1; - hadSearch = 1; - } - else if (matchKey(token, "NOSEARCH")) { - if (hadSearch) - mgr_.message(EntityManagerMessages::fsiDuplicateAttribute, - StringMessageArg(idCharset_.execToDesc("SEARCH"))); - else if (gotValue) - mgr_.message(EntityManagerMessages::fsiValueAsName, - StringMessageArg(token)); - else - sos.search = 0; - hadSearch = 1; - } - else if (matchKey(token, "FOLD")) { - if (!neutral) - mgr_.message(EntityManagerMessages::fsiFoldNotNeutral); - else if (hadFold) - mgr_.message(EntityManagerMessages::fsiDuplicateAttribute, - StringMessageArg(token)); - else if (gotValue) { - if (matchKey(value, "FOLD")) - fold = 1; - else if (matchKey(value, "NOFOLD")) - fold = 0; - else - mgr_.message(EntityManagerMessages::fsiBadFold, - StringMessageArg(value)); - } - else - fold = 1; - hadFold = 1; - } - else if (matchKey(token, "NOFOLD")) { - if (!neutral) - mgr_.message(EntityManagerMessages::fsiFoldNotNeutral); - else if (hadFold) - mgr_.message(EntityManagerMessages::fsiDuplicateAttribute, - StringMessageArg(idCharset_.execToDesc("FOLD"))); - else if (gotValue) - mgr_.message(EntityManagerMessages::fsiValueAsName, - StringMessageArg(token)); - else - fold = 0; - hadFold = 1; - } - else if (matchKey(token, "SMCRD")) { - if (hadSmcrd) - mgr_.message(EntityManagerMessages::fsiDuplicateAttribute, - StringMessageArg(token)); - else if (gotValue) { - if (value.size() == 0) - smcrd = -1; - else if (value.size() == 1) - smcrd = value[0]; - else - mgr_.message(EntityManagerMessages::fsiBadSmcrd, - StringMessageArg(value)); - } - else - mgr_.message(EntityManagerMessages::fsiMissingValue, - StringMessageArg(token)); - hadSmcrd = 1; - } - else if (matchKey(token, "RECORDS")) { - if (sos.storageManager->requiresCr()) - mgr_.message(EntityManagerMessages::fsiRecordsNotApplicable); - else if (hadRecords) - mgr_.message(EntityManagerMessages::fsiDuplicateAttribute, - StringMessageArg(token)); - else if (gotValue) { - if (!lookupRecords(value, sos.records)) - mgr_.message(EntityManagerMessages::fsiUnsupportedRecords, - StringMessageArg(value)); - } - else - mgr_.message(EntityManagerMessages::fsiMissingValue, - StringMessageArg(token)); - hadRecords = 1; - } - else if (matchKey(token, "SOIBASE")) { - if (hadBase) - mgr_.message(EntityManagerMessages::fsiDuplicateAttribute, - StringMessageArg(token)); - else if (gotValue) - value.swap(sos.baseId); - else { - mgr_.message(EntityManagerMessages::fsiMissingValue, - StringMessageArg(token)); - sos.baseId.resize(0); - } - hadBase = 1; - } - else if (lookupRecords(token, records)) { - if (sos.storageManager->requiresCr()) - mgr_.message(EntityManagerMessages::fsiRecordsNotApplicable); - else if (hadRecords) - mgr_.message(EntityManagerMessages::fsiDuplicateAttribute, - StringMessageArg(idCharset_.execToDesc("RECORDS"))); - else if (!gotValue) - sos.records = records; - else - mgr_.message(EntityManagerMessages::fsiValueAsName, - StringMessageArg(token)); - hadRecords = 1; - } - else if (matchKey(token, "NOTRACK")) { - if (hadTracking) - mgr_.message(EntityManagerMessages::fsiDuplicateAttribute, - StringMessageArg(idCharset_.execToDesc("TRACKING"))); - else if (!gotValue) - sos.notrack = 1; - else - mgr_.message(EntityManagerMessages::fsiValueAsName, - StringMessageArg(token)); - hadTracking = 1; - } - else if (matchKey(token, "TRACK")) { - if (hadTracking) - mgr_.message(EntityManagerMessages::fsiDuplicateAttribute, - StringMessageArg(idCharset_.execToDesc("TRACKING"))); - else if (gotValue) - mgr_.message(EntityManagerMessages::fsiValueAsName, - StringMessageArg(token)); - hadTracking = 1; - } - else - mgr_.message(gotValue - ? EntityManagerMessages::fsiUnsupportedAttribute - : EntityManagerMessages::fsiUnsupportedAttributeToken, - StringMessageArg(token)); - } - if (hadBase && sos.baseId.size() > 0) { - convertId(sos.baseId, smcrd, sos.storageManager); - if (neutral) { - if (!sos.storageManager->transformNeutral(sos.baseId, fold, mgr_)) - sos.baseId.resize(0); - } - } - if (!hadZapeof && hadRecords && sos.records == StorageObjectSpec::asis) - sos.zapEof = 0; - return 1; -} - -FSIParser::RecordType FSIParser::recordTypeTable[] = { - { "FIND", StorageObjectSpec::find }, - { "ASIS", StorageObjectSpec::asis }, - { "CR", StorageObjectSpec::cr }, - { "LF", StorageObjectSpec::lf }, - { "CRLF", StorageObjectSpec::crlf } -}; - -const char *FSIParser::recordsName(StorageObjectSpec::Records records) -{ - for (size_t i = 0; i < SIZEOF(recordTypeTable); i++) - if (records == recordTypeTable[i].value) - return recordTypeTable[i].name; - return 0; -} - -Boolean FSIParser::lookupRecords(const StringC &token, - StorageObjectSpec::Records &result) -{ - for (size_t i = 0; i < SIZEOF(recordTypeTable); i++) - if (matchKey(token, recordTypeTable[i].name)) { - result = recordTypeTable[i].value; - return 1; - } - return 0; -} - -void FSIParser::setDefaults(StorageObjectSpec &sos) -{ - if (sos.storageManager->requiresCr()) - sos.records = StorageObjectSpec::cr; - else if (isNdata_ - || (defSpec_ && defSpec_->records == StorageObjectSpec::asis)) - sos.records = StorageObjectSpec::asis; - if (isNdata_ || (defSpec_ && !defSpec_->zapEof)) - sos.zapEof = 0; - if (defSpec_ && defSpec_->storageManager == sos.storageManager) { - if (defSpec_->id.size()) - sos.baseId = defSpec_->id; - else { - sos.baseId = defSpec_->specId; - sos.storageManager->resolveRelative(defSpec_->baseId, - sos.baseId, - 0); - } - } - sos.codingSystem = sos.storageManager->requiredCodingSystem(); - if (sos.codingSystem) - sos.zapEof = 0; // hack - else { - sos.codingSystem = em_->defaultCodingSystem_; - if (isNdata_) { - const InputCodingSystem *id = 0; - size_t j; - for (j = 0; j < em_->codingSystems_.size(); j++) - if (em_->codingSystems_[j].ics->isIdentity()) { - id = em_->codingSystems_[j].ics; - break; - } - if (id && id != em_->defaultCodingSystem_) { - sos.codingSystem = id; - sos.codingSystemName = em_->codingSystems_[j].name; - } - } - else if (defSpec_) { - sos.codingSystem = defSpec_->codingSystem; - sos.codingSystemName = defSpec_->codingSystemName; - } - } -} - -Boolean FSIParser::parseAttribute(StringC &token, Boolean &gotValue, - StringC &value) -{ - Xchar c = get(); - while (isS(c)) - c = get(); - if (c == -1) { - return 0; - } - token.resize(0); - if (matchChar(c, '>')) - return 1; - if (matchChar(c, '"') || matchChar(c, '\'') || matchChar(c, '=')) - return 0; - for (;;) { - token += c; - c = get(); - if (c == -1) - return 0; - if (isS(c)) - break; - if (matchChar(c, '>') || matchChar(c, '=')) - break; - } - while (isS(c)) - c = get(); - if (c == -1) - return 0; - if (!matchChar(c, '=')) { - unget(); - gotValue = 0; - return 1; - } - gotValue = 1; - value.resize(0); - - c = get(); - while (isS(c)) - c = get(); - if (matchChar(c, '>') || matchChar(c, '=')) - return 0; - if (matchChar(c, '"') || matchChar(c, '\'')) { - Char lit = c; - for (;;) { - Xchar c = get(); - if (c == lit) - break; - if (c == -1) - return 0; - if (matchChar(c, '\n')) - ; - else if (matchChar(c, '\r') || matchChar(c, '\t')) - value += idCharset_.execToDesc(' '); - else - value += c; - } - uncharref(value); - } - else { - for (;;) { - value += c; - c = get(); - if (c == -1) - return 0; - if (isS(c)) - break; - if (matchChar(c, '>') || matchChar(c, '=')) { - unget(); - break; - } - } - } - return 1; -} - -void FSIParser::uncharref(StringC &str) -{ - size_t j = 0; - size_t i = 0; - while (i < str.size()) { - int digit; - if (matchChar(str[i], '&') - && i + 2 < str.size() - && matchChar(str[i + 1], '#') - && convertDigit(str[i + 2], digit)) { - unsigned long val = digit; - i += 3; - while (i < str.size() && convertDigit(str[i], digit)) { - val = val*10 + digit; - i++; - } - str[j++] = val; - if (i < str.size() && matchChar(str[i], ';')) - i++; - } - else - str[j++] = str[i++]; - } - str.resize(j); -} - -Boolean FSIParser::convertId(StringC &id, Xchar smcrd, - const StorageManager *sm) -{ - const CharsetInfo *smCharset = sm->idCharset(); - StringC newId; - size_t i = 0; - while (i < id.size()) { - UnivChar univ; - WideChar wide; - ISet wideSet; - int digit; - if (Xchar(id[i]) == smcrd - && i + 1 < id.size() - && convertDigit(id[i + 1], digit)) { - i += 2; - Char val = digit; - while (i < id.size() && convertDigit(id[i], digit)) { - val = val*10 + digit; - i++; - } - newId += val; - if (i < id.size() && matchChar(id[i], ';')) - i++; - } - else if (smCharset) { - if (!idCharset_.descToUniv(id[i++], univ)) - return 0; - if (univ == UnivCharsetDesc::rs) - ; - else if (univ == UnivCharsetDesc::re && sm->reString()) - newId += *sm->reString(); - else if (smCharset->univToDesc(univ, wide, wideSet) != 1 - || wide > charMax) - return 0; // FIXME give error - else - newId += Char(wide); - } - else - newId += id[i++]; - } - newId.swap(id); - return 1; -} - -ParsedSystemId:: ParsedSystemId() -{ -} - -static -void unparseSoi(const StringC &soi, - const CharsetInfo *idCharset, - const CharsetInfo &resultCharset, - StringC &result, - Boolean &needSmcrd); - -void ParsedSystemId::unparse(const CharsetInfo &resultCharset, - StringC &result) const -{ - size_t len = size(); - result.resize(0); - size_t i; - for (i = 0; i < maps.size(); i++) { - if (maps[i].type == ParsedSystemIdMap::catalogDocument) - result += resultCharset.execToDesc(""); - else if (maps[i].type == ParsedSystemIdMap::catalogPublic) { - result += resultCharset.execToDesc(""); - } - } - for (i = 0; i < len; i++) { - const StorageObjectSpec &sos = (*this)[i]; - result += resultCharset.execToDesc('<'); - result += resultCharset.execToDesc(sos.storageManager->type()); - if (sos.notrack) - result += resultCharset.execToDesc(" NOTRACK"); - if (!sos.search) - result += resultCharset.execToDesc(" NOSEARCH"); - if (!sos.storageManager->requiresCr() - && sos.records != StorageObjectSpec::find) { - result += resultCharset.execToDesc(' '); - result += resultCharset.execToDesc(FSIParser::recordsName(sos.records)); - } - if (sos.codingSystemName) { - if (!sos.zapEof) - result += resultCharset.execToDesc(" NOZAPEOF"); - result += resultCharset.execToDesc(" BCTF="); - result += resultCharset.execToDesc(sos.codingSystemName); - } - Boolean needSmcrd = 0; - if (sos.baseId.size() != 0) { - result += resultCharset.execToDesc(" SOIBASE='"); - unparseSoi(sos.baseId, - sos.storageManager->idCharset(), - resultCharset, - result, - needSmcrd); - result += resultCharset.execToDesc('\''); - } - StringC tem; - unparseSoi(sos.specId, - sos.storageManager->idCharset(), - resultCharset, - tem, - needSmcrd); - if (needSmcrd) - result += resultCharset.execToDesc(" SMCRD='^'"); - result += resultCharset.execToDesc('>'); - result += tem; - } -} - -void unparseSoi(const StringC &soi, - const CharsetInfo *idCharset, - const CharsetInfo &resultCharset, - StringC &result, - Boolean &needSmcrd) -{ - if (!idCharset) { - for (size_t i = 0; i < soi.size(); i++) { - char buf[32]; - sprintf(buf, "&#%lu;", (unsigned long)soi[i]); - result += resultCharset.execToDesc(buf); - } - return; - } - for (size_t i = 0; i < soi.size(); i++) { - UnivChar univ; - WideChar to; - ISet toSet; - if (!idCharset->descToUniv(soi[i], univ) - || univ >= 127 - || univ < 32 - || univ == 36 // $ - || univ == 96 // ` -#ifndef MSDOS_FILENAMES - || univ == 92 // backslash -#endif - || univ == 94 // ^ - || resultCharset.univToDesc(univ, to, toSet) != 1) { - needSmcrd = 1; - char buf[32]; - sprintf(buf, "^%lu;", (unsigned long)soi[i]); - result += resultCharset.execToDesc(buf); - } - else { - switch (univ) { - case 34: // double quote - case 35: // # - case 39: // apostrophe - case 60: // < - { - char buf[32]; - sprintf(buf, "&#%lu;", (unsigned long)to); - result += resultCharset.execToDesc(buf); - } - break; - default: - result += Char(to); - break; - } - } - } -} - -#ifdef SP_NAMESPACE -} -#endif diff --git a/cde/programs/nsgmls/ExtendEntityManager.h b/cde/programs/nsgmls/ExtendEntityManager.h deleted file mode 100644 index e13b4cd90..000000000 --- a/cde/programs/nsgmls/ExtendEntityManager.h +++ /dev/null @@ -1,149 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: ExtendEntityManager.h /main/1 1996/07/29 16:51:47 cde-hp $ */ -// Copyright (c) 1994, 1995 James Clark -// See the file COPYING for copying permission. - -#ifndef ExtendEntityManager_INCLUDED -#define ExtendEntityManager_INCLUDED 1 - -#ifdef __GNUG__ -#pragma interface -#endif - -#include "EntityManager.h" -#include "CharsetInfo.h" -#include "types.h" -#include "Boolean.h" -#include "StringC.h" -#include "types.h" -#include "Vector.h" -#include "Location.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -class StorageManager; -class InputCodingSystem; -class Messenger; - -struct SP_API StorageObjectSpec { - StorageObjectSpec(); - StorageManager *storageManager; - const char *codingSystemName; - const InputCodingSystem *codingSystem; - StringC specId; // specified id - StringC baseId; // id that specified id is relative to - StringC id; // actual id used (filled in after opening) - enum Records { - find, - cr, - lf, - crlf, - asis - }; - Records records; - PackedBoolean notrack; - PackedBoolean zapEof; // zap a final Ctrl-Z - PackedBoolean search; -}; - -struct SP_API ParsedSystemIdMap { - enum Type { - catalogDocument, - catalogPublic - }; - Type type; - StringC publicId; -}; - -struct SP_API ParsedSystemId : public Vector { - ParsedSystemId(); - void unparse(const CharsetInfo &charset, StringC &result) const; - Vector maps; -}; - -struct SP_API StorageObjectLocation { - const StorageObjectSpec *storageObjectSpec; - unsigned long lineNumber; - unsigned long columnNumber; - unsigned long byteIndex; - unsigned long storageObjectOffset; -}; - -class SP_API ExtendEntityManager : public EntityManager { -public: - class SP_API CatalogManager { - public: - virtual ~CatalogManager(); - virtual ConstPtr - makeCatalog(StringC &systemId, - const CharsetInfo &charset, - ExtendEntityManager *, - Messenger &) const = 0; - virtual Boolean mapCatalog(ParsedSystemId &systemId, - ExtendEntityManager *em, - Messenger &mgr) const = 0; - }; - virtual void registerStorageManager(StorageManager *) = 0; - virtual void registerCodingSystem(const char *, const InputCodingSystem *) - = 0; - virtual void setCatalogManager(CatalogManager *) = 0; - virtual InputSource *openIfExists(const StringC &sysid, - const CharsetInfo &, - InputSourceOrigin *, - Boolean mayRewind, - Messenger &) = 0; - virtual Boolean expandSystemId(const StringC &, - const Location &, - Boolean isNdata, - const CharsetInfo &, - const StringC *mapCatalogPublic, - Messenger &, - StringC &) = 0; - virtual Boolean mergeSystemIds(const Vector &sysids, - Boolean mapCatalogDocument, - const CharsetInfo &, - Messenger &mgr, - StringC &) const = 0; - virtual Boolean parseSystemId(const StringC &str, - const CharsetInfo &idCharset, - Boolean isNdata, - const StorageObjectSpec *defSpec, - Messenger &mgr, - ParsedSystemId &parsedSysid) const = 0; - static Boolean externalize(const ExternalInfo *, - Offset, - StorageObjectLocation &); - static const ParsedSystemId * - externalInfoParsedSystemId(const ExternalInfo *); - static ExtendEntityManager *make(StorageManager *, - const InputCodingSystem *); -}; - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* not ExtendEntityManager_INCLUDED */ diff --git a/cde/programs/nsgmls/ExternalId.C b/cde/programs/nsgmls/ExternalId.C deleted file mode 100644 index 85ec500c8..000000000 --- a/cde/programs/nsgmls/ExternalId.C +++ /dev/null @@ -1,287 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: ExternalId.C /main/1 1996/07/29 16:51:51 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#ifdef __GNUG__ -#pragma implementation -#endif -#include "splib.h" -#include "ExternalId.h" -#include "CharsetInfo.h" -#include "macros.h" -#include "ParserMessages.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -ExternalId::ExternalId() -: haveSystem_(0), havePublic_(0) -{ -} - -void ExternalId::setSystem(Text &text) -{ - text.swap(system_); - haveSystem_ = 1; -} - -Boolean ExternalId::setPublic(Text &text, const CharsetInfo &charset, - Char space, const MessageType1 *&error) -{ - havePublic_ = 1; - return public_.init(text, charset, space, error); -} - -void ExternalId::setLocation(const Location &loc) -{ - loc_ = loc; -} - -PublicId::PublicId() -: formal_(0), ownerType_(ISO), textClass_(CAPACITY), unavailable_(false), haveDisplayVersion_(false) -{ -} - -Boolean PublicId::init(Text &text, const CharsetInfo &charset, - Char space, const MessageType1 *&error) -{ - text.swap(text_); - const StringC &str = text_.string(); - formal_ = 0; - const Char *next = str.data(); - const Char *lim = str.data() + str.size(); - Char solidus = charset.execToDesc('/'); - Char minus = charset.execToDesc('-'); - Char plus = charset.execToDesc('+'); - const Char *fieldStart; - size_t fieldLength; - if (!nextField(solidus, next, lim, fieldStart, fieldLength)) { - error = &ParserMessages::fpiMissingField; - return 0; - } - if (fieldLength == 1 && (*fieldStart == minus || *fieldStart == plus)) { - ownerType_ = (*fieldStart == plus ? registered : unregistered); - if (!nextField(solidus, next, lim, fieldStart, fieldLength)) { - error = &ParserMessages::fpiMissingField; - return 0; - } - } - else - ownerType_ = ISO; - owner_.assign(fieldStart, fieldLength); - if (!nextField(solidus, next, lim, fieldStart, fieldLength)) { - error = &ParserMessages::fpiMissingField; - return 0; - } - size_t i; - for (i = 0; i < fieldLength; i++) - if (fieldStart[i] == space) - break; - if (i >= fieldLength) { - error = &ParserMessages::fpiMissingTextClassSpace; - return 0; - } - StringC textClassString(fieldStart, i); - if (!lookupTextClass(textClassString, charset, textClass_)) { - error = &ParserMessages::fpiInvalidTextClass; - return 0; - } - i++; // skip the space - fieldStart += i; - fieldLength -= i; - if (fieldLength == 1 && *fieldStart == minus) { - unavailable_ = 1; - if (!nextField(solidus, next, lim, fieldStart, fieldLength)) { - error = &ParserMessages::fpiMissingField; - return 0; - } - } - else - unavailable_ = 0; - description_.assign(fieldStart, fieldLength); - if (!nextField(solidus, next, lim, fieldStart, fieldLength)) { - error = &ParserMessages::fpiMissingField; - return 0; - } - if (textClass_ != CHARSET) { - for (i = 0; i < fieldLength; i++) { - UnivChar c; - if (!charset.descToUniv(fieldStart[i], c) - || c < UnivCharsetDesc::A || c >= UnivCharsetDesc::A + 26) { - error = &ParserMessages::fpiInvalidLanguage; - return 0; - } - } - // The public text language must be a name. - // Names cannot be empty. - if (fieldLength == 0) { - error = &ParserMessages::fpiInvalidLanguage; - return 0; - } - } - languageOrDesignatingSequence_.assign(fieldStart, fieldLength); - if (nextField(solidus, next, lim, fieldStart, fieldLength)) { - switch (textClass_) { - case CAPACITY: - case CHARSET: - case NOTATION: - case SYNTAX: - error = &ParserMessages::fpiIllegalDisplayVersion; - return 0; - default: - break; - } - haveDisplayVersion_ = 1; - displayVersion_.assign(fieldStart, fieldLength); - } - else - haveDisplayVersion_ = 0; - if (next != 0) { - error = &ParserMessages::fpiExtraField; - return 0; - } - formal_ = 1; - return 1; -} - -Boolean PublicId::nextField(Char solidus, - const Char *&next, - const Char *lim, - const Char *&fieldStart, - size_t &fieldLength) - -{ - if (next == 0) - return 0; - fieldStart = next; - for (; next < lim; next++) { - if (next[0] == solidus && next + 1 < lim && next[1] == solidus) { - fieldLength = next - fieldStart; - next += 2; - return 1; - } - } - fieldLength = lim - fieldStart; - next = 0; - return 1; -} - -const char *const PublicId::textClasses[] = { - "CAPACITY", - "CHARSET", - "DOCUMENT", - "DTD", - "ELEMENTS", - "ENTITIES", - "LPD", - "NONSGML", - "NOTATION", - "SHORTREF", - "SUBDOC", - "SYNTAX", - "TEXT", -}; - -Boolean PublicId::lookupTextClass(const StringC &str, - const CharsetInfo &charset, - TextClass &textClass) -{ - for (size_t i = 0; i < SIZEOF(textClasses); i++) - if (str == charset.execToDesc(textClasses[i])) { - textClass = TextClass(i); - return 1; - } - return 0; -} - -Boolean PublicId::getOwnerType(OwnerType &result) const -{ - if (!formal_) - return 0; - result = ownerType_; - return 1; -} - -Boolean PublicId::getOwner(StringC &result) const -{ - if (!formal_) - return 0; - result = owner_; - return 1; -} - -Boolean PublicId::getTextClass(TextClass &result) const -{ - if (!formal_) - return 0; - result = textClass_; - return 1; -} - -Boolean PublicId::getUnavailable(Boolean &result) const -{ - if (!formal_) - return 0; - result = unavailable_; - return 1; -} - -Boolean PublicId::getDescription(StringC &result) const -{ - if (!formal_) - return 0; - result = description_; - return 1; -} - -Boolean PublicId::getLanguage(StringC &result) const -{ - if (!formal_ || textClass_ == CHARSET) - return 0; - result = languageOrDesignatingSequence_; - return 1; -} - -Boolean PublicId::getDesignatingSequence(StringC &result) const -{ - if (!formal_ || textClass_ != CHARSET) - return 0; - result = languageOrDesignatingSequence_; - return 1; -} - -Boolean PublicId::getDisplayVersion(StringC &result) const -{ - if (!formal_) - return 0; - if (haveDisplayVersion_) - result = displayVersion_; - return 1; -} - -#ifdef SP_NAMESPACE -} -#endif diff --git a/cde/programs/nsgmls/ExternalId.h b/cde/programs/nsgmls/ExternalId.h deleted file mode 100644 index 7da9c9128..000000000 --- a/cde/programs/nsgmls/ExternalId.h +++ /dev/null @@ -1,200 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: ExternalId.h /main/1 1996/07/29 16:51:56 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#ifndef ExternalId_INCLUDED -#define ExternalId_INCLUDED 1 -#ifdef __GNUG__ -#pragma interface -#endif - -#include "Boolean.h" -#include "StringC.h" -#include "Text.h" -#include "types.h" -#include "Message.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -class CharsetInfo; - -class SP_API PublicId { -public: - enum TextClass { - CAPACITY, - CHARSET, - DOCUMENT, - DTD, - ELEMENTS, - ENTITIES, - LPD, - NONSGML, - NOTATION, - SHORTREF, - SUBDOC, - SYNTAX, - TEXT - }; - enum OwnerType { - ISO, - registered, - unregistered - }; - PublicId(); - - Boolean getOwnerType(OwnerType &) const; - Boolean getOwner(StringC &) const; - Boolean getTextClass(TextClass &) const; - Boolean getUnavailable(Boolean &) const; - Boolean getDescription(StringC &) const; - Boolean getLanguage(StringC &) const; - Boolean getDesignatingSequence(StringC &) const; - Boolean getDisplayVersion(StringC &) const; - // If it's not a valid formal public identifier, return 0 - // and set error, otherwise return 1. - // charset describes the character set to use for parsing the - // id. - Boolean init(Text &, const CharsetInfo &, Char space, - const MessageType1 *&error); - const StringC &string() const; - const Text &text() const; -private: - static Boolean nextField(Char solidus, - const Char *&next, - const Char *lim, - const Char *&fieldStart, - size_t &fieldLength); - static Boolean lookupTextClass(const StringC &, const CharsetInfo &, - TextClass &); - static const char *const textClasses[]; - - PackedBoolean formal_; - OwnerType ownerType_; - StringC owner_; - TextClass textClass_; - PackedBoolean unavailable_; - StringC description_; - StringC languageOrDesignatingSequence_; - PackedBoolean haveDisplayVersion_; - StringC displayVersion_; - Text text_; -}; - -class SP_API ExternalId { -public: - ExternalId(); - const StringC *systemIdString() const; - const StringC *publicIdString() const; - const StringC &effectiveSystemId() const; - const Text *systemIdText() const; - const Text *publicIdText() const; - const PublicId *publicId() const; - void setSystem(Text &); - void setEffectiveSystem(StringC &); - // If it's not a valid formal public identifier, return 0 - // and set error, otherwise return 1. - // charset describes the character set to use for parsing the - // id. - Boolean setPublic(Text &, const CharsetInfo &, Char space, - const MessageType1 *&error); - void setLocation(const Location &); - // location of keyword - const Location &location() const; -private: - PackedBoolean haveSystem_; - PackedBoolean havePublic_; - Text system_; - PublicId public_; - Location loc_; - StringC effectiveSystem_; -}; - -inline -const StringC &PublicId::string() const -{ - return text_.string(); -} - -inline -const Text &PublicId::text() const -{ - return text_; -} - -inline -const StringC *ExternalId::systemIdString() const -{ - return haveSystem_ ? &system_.string() : 0; -} - -inline -const StringC *ExternalId::publicIdString() const -{ - return havePublic_ ? &public_.string() : 0; -} - -inline -const Text *ExternalId::systemIdText() const -{ - return haveSystem_ ? &system_ : 0; -} - -inline -const Text *ExternalId::publicIdText() const -{ - return havePublic_ ? &public_.text() : 0; -} - -inline -const PublicId *ExternalId::publicId() const -{ - return havePublic_ ? &public_ : 0; -} - -inline -const Location &ExternalId::location() const -{ - return loc_; -} - -inline -const StringC &ExternalId::effectiveSystemId() const -{ - return effectiveSystem_; -} - -inline -void ExternalId::setEffectiveSystem(StringC &str) -{ - str.swap(effectiveSystem_); -} - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* not ExternalId_INCLUDED */ diff --git a/cde/programs/nsgmls/Fixed2CodingSystem.C b/cde/programs/nsgmls/Fixed2CodingSystem.C deleted file mode 100644 index 77070ef00..000000000 --- a/cde/programs/nsgmls/Fixed2CodingSystem.C +++ /dev/null @@ -1,174 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: Fixed2CodingSystem.C /main/1 1996/07/29 16:52:03 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -// This uses a big endian byte order irrespective of host byte order. -// Nothing special is done with FEFF/FFFE. - -#include "splib.h" - -#ifdef SP_MULTI_BYTE - -#include "Fixed2CodingSystem.h" -#include "macros.h" - -#if defined(__linux__) || defined(CSRG_BASED) || defined(sun) -#include -#else -#include -#endif - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -class Fixed2Decoder : public Decoder { -public: - Fixed2Decoder(); - size_t decode(Char *to, const char *from, size_t fromLen, - const char **rest); - Boolean convertOffset(unsigned long &offset) const; -}; - -class Fixed2Encoder : public Encoder { -public: - Fixed2Encoder(); - ~Fixed2Encoder(); - void output(Char *, size_t, streambuf *); - void output(const Char *, size_t, streambuf *); -private: - void allocBuf(size_t); - char *buf_; - size_t bufSize_; -}; - -Decoder *Fixed2CodingSystem::makeDecoder() const -{ - return new Fixed2Decoder; -} - -Encoder *Fixed2CodingSystem::makeEncoder() const -{ - return new Fixed2Encoder; -} - -unsigned Fixed2CodingSystem::fixedBytesPerChar() const -{ - return 2; -} - -Fixed2Decoder::Fixed2Decoder() -: Decoder(2) -{ -} - -size_t Fixed2Decoder::decode(Char *to, const char *from, size_t fromLen, - const char **rest) -{ -#ifdef BIG_ENDIAN - if (sizeof(Char) == 2 && from == (char *)to) { - *rest = from + (fromLen & ~1); - return fromLen/2; - } -#endif - fromLen &= ~1; - *rest = from + fromLen; - for (size_t n = fromLen; n > 0; n -= 2) { - *to++ = ((unsigned char)from[0] << 8) + (unsigned char)from[1]; - from += 2; - } - return fromLen/2; -} - -Boolean Fixed2Decoder::convertOffset(unsigned long &n) const -{ - n *= 2; - return true; -} - -Fixed2Encoder::Fixed2Encoder() -: buf_(0), bufSize_(0) -{ -} - -Fixed2Encoder::~Fixed2Encoder() -{ - delete [] buf_; -} - -void Fixed2Encoder::allocBuf(size_t n) -{ - if (bufSize_ < n) { - delete [] buf_; - buf_ = new char[bufSize_ = n]; - } -} - -// FIXME handle errors from streambuf::sputn - -void Fixed2Encoder::output(Char *s, size_t n, streambuf *sb) -{ -#ifdef BIG_ENDIAN - if (sizeof(Char) == 2) { - sb->sputn((char *)s, n*2); - return; - } -#endif - ASSERT(sizeof(Char) >= 2); - char *p = (char *)s; - for (size_t i = 0; i < n; i++) { - *p++ = (s[i] >> 8) & 0xff; - *p++ = s[i] & 0xff; - } - sb->sputn((char *)s, n*2); -} - -void Fixed2Encoder::output(const Char *s, size_t n, streambuf *sb) -{ -#ifdef BIG_ENDIAN - if (sizeof(Char) == 2) { - sb->sputn((char *)s, n*2); - return; - } -#endif - allocBuf(n*2); - for (size_t i = 0; i < n; i++) { - buf_[i*2] = (s[i] >> 8) & 0xff; - buf_[i*2 + 1] = s[i] & 0xff; - } - sb->sputn(buf_, n*2); -} - -#ifdef SP_NAMESPACE -} -#endif - -#else /* not SP_MULTI_BYTE */ - -#ifndef __GNUG__ -static char non_empty_translation_unit; // sigh -#endif - -#endif /* not SP_MULTI_BYTE */ diff --git a/cde/programs/nsgmls/Fixed2CodingSystem.h b/cde/programs/nsgmls/Fixed2CodingSystem.h deleted file mode 100644 index 20287455b..000000000 --- a/cde/programs/nsgmls/Fixed2CodingSystem.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: Fixed2CodingSystem.h /main/1 1996/07/29 16:52:10 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#ifndef Fixed2CodingSystem_INCLUDED -#define Fixed2CodingSystem_INCLUDED 1 - -#include "CodingSystem.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -class SP_API Fixed2CodingSystem : public CodingSystem { -public: - Decoder *makeDecoder() const; - Encoder *makeEncoder() const; - unsigned fixedBytesPerChar() const; -}; - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* not Fixed2CodingSystem_INCLUDED */ diff --git a/cde/programs/nsgmls/GenericEventHandler.C b/cde/programs/nsgmls/GenericEventHandler.C deleted file mode 100644 index 0ec3e0369..000000000 --- a/cde/programs/nsgmls/GenericEventHandler.C +++ /dev/null @@ -1,813 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: GenericEventHandler.C /main/1 1996/07/29 16:52:15 cde-hp $ */ -// Copyright (c) 1996 James Clark -// See the file COPYING for copying permission. - -#ifdef __GNUG__ -#pragma implementation -#endif - -#include "splib.h" -#include "GenericEventHandler.h" -#include "macros.h" -#include "ExtendEntityManager.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -class SpOpenEntity : public SGMLApplication::OpenEntity { -public: - SpOpenEntity(const ConstPtr &origin); - SGMLApplication::Location location(SGMLApplication::Position) const; -private: - ConstPtr origin_; -}; - -inline -void *operator new(size_t n, GenericEventHandler *handler) -{ - return handler->allocate(n); -} - -inline -void GenericEventHandler::freeAll() -{ - if (allocBlocks_) - freeAll1(); -} - -inline -void GenericEventHandler::clearNotation(SGMLApplication::Notation &to) -{ - clearString(to.name); -} - -inline -void GenericEventHandler::setLocation(SGMLApplication::Position &pos, - const Location &loc) -{ - if (lastOrigin_ != loc.origin()) - setLocation1(pos, loc); - else - pos = loc.index(); -} - -GenericEventHandler::GenericEventHandler(SGMLApplication &app, - bool generalEntities) -: app_(&app), generalEntities_(generalEntities), - freeBlocks_(0), allocBlocks_(0), firstBlockSpare_(0), firstBlockUsed_(0) -{ -} - -GenericEventHandler::~GenericEventHandler() -{ - freeAll(); - while (freeBlocks_) { - Block *tem = freeBlocks_; - freeBlocks_ = freeBlocks_->next; - delete [] tem->mem; - delete tem; - } -} - -void GenericEventHandler::freeAll1() -{ - Block **p; - for (p = &allocBlocks_; *p; p = &(*p)->next) - ; - *p = freeBlocks_; - freeBlocks_ = allocBlocks_; - allocBlocks_ = 0; - if (freeBlocks_) - firstBlockSpare_ = freeBlocks_->size; - else - firstBlockSpare_ = 0; - firstBlockUsed_ = 0; -} - -void *GenericEventHandler::allocate(size_t n) -{ - if (n == 0) - return 0; - // round up to avoid alignment problems - n = (n + sizeof(char *) - 1) & ~(sizeof(char *) - 1); - enum { BIG = 1024 }; - if (n > firstBlockSpare_) { - if (freeBlocks_ && firstBlockUsed_) { - Block *tem = freeBlocks_; - freeBlocks_ = freeBlocks_->next; - tem->next = allocBlocks_; - allocBlocks_ = tem; - } - if (!freeBlocks_ || freeBlocks_->size < n) { - Block *tem = new Block; - tem->size = n < BIG ? int(BIG) : n; - tem->mem = new char[tem->size]; - tem->next = freeBlocks_; - freeBlocks_ = tem; - } - firstBlockUsed_ = 0; - firstBlockSpare_ = freeBlocks_->size; - } - char *tem = freeBlocks_->mem + firstBlockUsed_; - firstBlockUsed_ += n; - firstBlockSpare_ -= n; - return tem; -} - -void GenericEventHandler::startElement(StartElementEvent *event) -{ - SGMLApplication::StartElementEvent appEvent; - setString(appEvent.gi, event->name()); - const ElementDefinition *def = event->elementType()->definition(); - switch (def->declaredContent()) { - case ElementDefinition::modelGroup: - appEvent.contentType - = (def->compiledModelGroup()->containsPcdata() - ? SGMLApplication::StartElementEvent::mixed - : SGMLApplication::StartElementEvent::element); - break; - case ElementDefinition::any: - appEvent.contentType = SGMLApplication::StartElementEvent::mixed; - break; - case ElementDefinition::cdata: - appEvent.contentType = SGMLApplication::StartElementEvent::cdata; - break; - case ElementDefinition::rcdata: - appEvent.contentType = SGMLApplication::StartElementEvent::rcdata; - break; - case ElementDefinition::empty: - appEvent.contentType = SGMLApplication::StartElementEvent::empty; - break; - } - appEvent.included = event->included(); - appEvent.nAttributes = event->attributes().size(); - if (appEvent.nAttributes != 0) { - if (event->attributes().conref()) - appEvent.contentType = SGMLApplication::StartElementEvent::empty; - setAttributes(appEvent.attributes, event->attributes()); - } - setLocation(appEvent.pos, event->location()); - app_->startElement(appEvent); - freeAll(); - delete event; -} - -void GenericEventHandler::endElement(EndElementEvent *event) -{ - SGMLApplication::EndElementEvent appEvent; - setString(appEvent.gi, event->name()); - setLocation(appEvent.pos, event->location()); - app_->endElement(appEvent); - delete event; -} - -void GenericEventHandler::data(DataEvent *event) -{ - SGMLApplication::DataEvent appEvent; - appEvent.data.ptr = event->data(); - appEvent.data.len = event->dataLength(); - setLocation(appEvent.pos, event->location()); - app_->data(appEvent); - delete event; -} - -void GenericEventHandler::pi(PiEvent *event) -{ - SGMLApplication::PiEvent appEvent; - appEvent.data.ptr = event->data(); - appEvent.data.len = event->dataLength(); - const Entity *entity = event->entity(); - if (entity) - setString(appEvent.entityName, entity->name()); - else - appEvent.entityName.len = 0; - setLocation(appEvent.pos, event->location()); - app_->pi(appEvent); - delete event; -} - -void GenericEventHandler::sdataEntity(SdataEntityEvent *event) -{ - SGMLApplication::SdataEvent appEvent; - appEvent.text.ptr = event->data(); - appEvent.text.len = event->dataLength(); - setString(appEvent.entityName, event->entity()->name()); - // Don't want location of chars in entity. - setLocation(appEvent.pos, event->location().origin()->parent()); - app_->sdata(appEvent); - delete event; -} - -void GenericEventHandler::externalDataEntity(ExternalDataEntityEvent *event) -{ - SGMLApplication::ExternalDataEntityRefEvent appEvent; - setEntity(appEvent.entity, *event->entity()); - setLocation(appEvent.pos, event->location()); - app_->externalDataEntityRef(appEvent); - freeAll(); - delete event; -} - -void GenericEventHandler::subdocEntity(SubdocEntityEvent *event) -{ - SGMLApplication::SubdocEntityRefEvent appEvent; - setEntity(appEvent.entity, *event->entity()); - setLocation(appEvent.pos, event->location()); - app_->subdocEntityRef(appEvent); - freeAll(); - delete event; -} - -void GenericEventHandler::startDtd(StartDtdEvent *event) -{ - SGMLApplication::StartDtdEvent appEvent; - setString(appEvent.name, event->name()); - const Entity *entity = event->entity().pointer(); - if (entity) { - appEvent.haveExternalId = 1; - setExternalId(appEvent.externalId, - entity->asExternalEntity()->externalId()); - } - else - appEvent.haveExternalId = 0; - setLocation(appEvent.pos, event->location()); - app_->startDtd(appEvent); - freeAll(); - delete event; -} - -void GenericEventHandler::endDtd(EndDtdEvent *event) -{ - SGMLApplication::EndDtdEvent appEvent; - setString(appEvent.name, event->dtd().name()); - setLocation(appEvent.pos, event->location()); - app_->endDtd(appEvent); - delete event; -} - -void GenericEventHandler::endProlog(EndPrologEvent *event) -{ - if (generalEntities_) { - SGMLApplication::GeneralEntityEvent entityEvent; - const Dtd &dtd = event->dtd(); - Dtd::ConstEntityIter iter(dtd.generalEntityIter()); - for (;;) { - const Entity *entity = iter.nextTemp(); - if (!entity) - break; - setEntity(entityEvent.entity, *entity); - app_->generalEntity(entityEvent); - } - freeAll(); - } - SGMLApplication::EndPrologEvent appEvent; - setLocation(appEvent.pos, event->location()); - app_->endProlog(appEvent); - delete event; -} - -void GenericEventHandler::entityDefaulted(EntityDefaultedEvent *event) -{ - if (generalEntities_) { - SGMLApplication::GeneralEntityEvent appEvent; - setEntity(appEvent.entity, event->entity()); - app_->generalEntity(appEvent); - } - delete event; -} - -void GenericEventHandler::appinfo(AppinfoEvent *event) -{ - SGMLApplication::AppinfoEvent appEvent; - const StringC *str; - if (event->literal(str)) { - setString(appEvent.string, *str); - appEvent.none = 0; - } - else - appEvent.none = 1; - setLocation(appEvent.pos, event->location()); - app_->appinfo(appEvent); - delete event; -} - -void GenericEventHandler::commentDecl(CommentDeclEvent *event) -{ - SGMLApplication::CommentDeclEvent appEvent; - appEvent.nComments = 0; - { - for (MarkupIter iter(event->markup()); iter.valid(); iter.advance()) - if (iter.type() == Markup::comment) - appEvent.nComments++; - } - SGMLApplication::CharString *comments - = (SGMLApplication::CharString *)allocate(appEvent.nComments * 2 - * sizeof(SGMLApplication::CharString)); - appEvent.comments = comments; - appEvent.seps = appEvent.comments + appEvent.nComments; - size_t i = 0; - for (MarkupIter iter(event->markup()); iter.valid(); iter.advance()) - switch (iter.type()) { - case Markup::comment: - comments[i].ptr = iter.charsPointer(); - comments[i].len = iter.charsLength(); - clearString(comments[appEvent.nComments + i]); - i++; - break; - case Markup::s: - comments[appEvent.nComments + i - 1].ptr = iter.charsPointer(); - comments[appEvent.nComments + i - 1].len = iter.charsLength(); - break; - default: - break; - } - setLocation(appEvent.pos, event->location()); - app_->commentDecl(appEvent); - freeAll(); - delete event; -} - -void GenericEventHandler::markedSectionStart(MarkedSectionStartEvent *event) -{ - SGMLApplication::MarkedSectionStartEvent appEvent; - unsigned depth = 0; - appEvent.nParams = 0; - { - for (MarkupIter iter(event->markup()); iter.valid(); iter.advance()) - switch (iter.type()) { - case Markup::reservedName: - if (!depth) - appEvent.nParams++; - break; - case Markup::entityStart: - if (!depth) - appEvent.nParams++; - depth++; - break; - case Markup::entityEnd: - depth--; - break; - default: - break; - } - } - SGMLApplication::MarkedSectionStartEvent::Param *params - = (SGMLApplication::MarkedSectionStartEvent::Param *) - allocate(appEvent.nParams * sizeof(appEvent.params[0])); - appEvent.params = params; - size_t i = 0; - for (MarkupIter iter(event->markup()); iter.valid(); iter.advance()) - switch (iter.type()) { - case Markup::reservedName: - if (!depth) { - switch (iter.reservedName()) { - case Syntax::rTEMP: - params[i].type - = SGMLApplication::MarkedSectionStartEvent::Param::temp; - break; - case Syntax::rINCLUDE: - params[i].type - = SGMLApplication::MarkedSectionStartEvent::Param::include; - break; - case Syntax::rRCDATA: - params[i].type - = SGMLApplication::MarkedSectionStartEvent::Param::rcdata; - break; - case Syntax::rCDATA: - params[i].type - = SGMLApplication::MarkedSectionStartEvent::Param::cdata; - break; - case Syntax::rIGNORE: - params[i].type - = SGMLApplication::MarkedSectionStartEvent::Param::ignore; - break; - default: - CANNOT_HAPPEN(); - } - clearString(params[i].entityName); - i++; - } - break; - case Markup::entityStart: - if (!depth) { - params[i].type - = SGMLApplication::MarkedSectionStartEvent::Param::entityRef; - setString(params[i].entityName, - iter.entityOrigin()->entity()->name()); - i++; - } - depth++; - break; - case Markup::entityEnd: - depth--; - break; - default: - break; - } - switch (event->status()) { - case MarkedSectionEvent::include: - appEvent.status = SGMLApplication::MarkedSectionStartEvent::include; - break; - case MarkedSectionEvent::rcdata: - appEvent.status = SGMLApplication::MarkedSectionStartEvent::rcdata; - break; - case MarkedSectionEvent::cdata: - appEvent.status = SGMLApplication::MarkedSectionStartEvent::cdata; - break; - case MarkedSectionEvent::ignore: - appEvent.status = SGMLApplication::MarkedSectionStartEvent::ignore; - break; - } - setLocation(appEvent.pos, event->location()); - app_->markedSectionStart(appEvent); - freeAll(); - delete event; -} - -void GenericEventHandler::ignoredChars(IgnoredCharsEvent *event) -{ - SGMLApplication::IgnoredCharsEvent appEvent; - appEvent.data.ptr = event->data(); - appEvent.data.len = event->dataLength(); - setLocation(appEvent.pos, event->location()); - app_->ignoredChars(appEvent); - delete event; -} - -void GenericEventHandler::markedSectionEnd(MarkedSectionEndEvent *event) -{ - SGMLApplication::MarkedSectionEndEvent appEvent; - switch (event->status()) { - case MarkedSectionEvent::include: - appEvent.status = SGMLApplication::MarkedSectionEndEvent::include; - break; - case MarkedSectionEvent::rcdata: - appEvent.status = SGMLApplication::MarkedSectionEndEvent::rcdata; - break; - case MarkedSectionEvent::cdata: - appEvent.status = SGMLApplication::MarkedSectionEndEvent::cdata; - break; - case MarkedSectionEvent::ignore: - appEvent.status = SGMLApplication::MarkedSectionEndEvent::ignore; - break; - } - setLocation(appEvent.pos, event->location()); - app_->markedSectionEnd(appEvent); - delete event; -} - -void GenericEventHandler::message(MessageEvent *event) -{ - SGMLApplication::ErrorEvent appEvent; - switch (event->message().type->severity()) { - case MessageType::quantityError: - appEvent.type = SGMLApplication::ErrorEvent::quantity; - break; - case MessageType::idrefError: - appEvent.type = SGMLApplication::ErrorEvent::idref; - break; - case MessageType::error: - appEvent.type = SGMLApplication::ErrorEvent::otherError; - break; - case MessageType::info: - appEvent.type = SGMLApplication::ErrorEvent::info; - break; - case MessageType::warning: - appEvent.type = SGMLApplication::ErrorEvent::warning; - break; - } - setLocation(appEvent.pos, event->message().loc); - StringC str; - reportMessage(event->message(), str); - setString(appEvent.message, str); - app_->error(appEvent); - ErrorCountEventHandler::message(event); -} - -void GenericEventHandler::setLocation1(SGMLApplication::Position &pos, - const Location &loc) -{ - const Location *locp = &loc; - for (;;) { - if (locp->origin().isNull()) { - lastOrigin_.clear(); - openEntityPtr_ = (SpOpenEntity *)0; - return; - } - const InputSourceOrigin *origin = locp->origin()->asInputSourceOrigin(); - if (origin && origin->externalInfo()) - break; - locp = &locp->origin()->parent(); - } - lastOrigin_ = locp->origin(); - pos = locp->index(); - openEntityPtr_ = new SpOpenEntity(locp->origin()); - app_->openEntityChange(openEntityPtr_); -} - -void -GenericEventHandler::setAttributes(const SGMLApplication::Attribute *&attributes, - const AttributeList &attributeList) -{ - size_t nAttributes = attributeList.size(); - SGMLApplication::Attribute *to - = (SGMLApplication::Attribute *)allocate(nAttributes * sizeof(*to)); - attributes = to; - for (size_t i = 0; i < nAttributes; i++) { - SGMLApplication::Attribute *p = to + i; - setString(p->name, attributeList.name(i)); - const AttributeValue *value = attributeList.value(i); - if (!value) - p->type = SGMLApplication::Attribute::invalid; - else { - const Text *text; - const StringC *string; - switch (value->info(text, string)) { - case AttributeValue::implied: - p->type = SGMLApplication::Attribute::implied; - break; - case AttributeValue::tokenized: - { - if (attributeList.specified(i)) - p->defaulted = SGMLApplication::Attribute::specified; - else if (attributeList.current(i)) - p->defaulted = SGMLApplication::Attribute::current; - else - p->defaulted = SGMLApplication::Attribute::definition; - p->type = SGMLApplication::Attribute::tokenized; - p->nEntities = 0; - p->notation.name.len = 0; - p->isId = attributeList.id(i); - p->isGroup = (attributeList.getAllowedTokens(i) != 0); - setString(p->tokens, *string); - const AttributeSemantics *semantics = attributeList.semantics(i); - if (semantics) { - ConstPtr notation = semantics->notation(); - if (!notation.isNull()) - setNotation(p->notation, *notation); - else { - size_t nEntities = semantics->nEntities(); - if (nEntities) { - SGMLApplication::Entity *v - = (SGMLApplication::Entity *)allocate(nEntities * sizeof(*v)); - p->entities = v; - p->nEntities = nEntities; - for (size_t i = 0; i < nEntities; i++) - setEntity(v[i], *semantics->entity(i)); - } - } - } - } - break; - case AttributeValue::cdata: - { - p->type = SGMLApplication::Attribute::cdata; - if (attributeList.specified(i)) - p->defaulted = SGMLApplication::Attribute::specified; - else if (attributeList.current(i)) - p->defaulted = SGMLApplication::Attribute::current; - else - p->defaulted = SGMLApplication::Attribute::definition; - TextItem::Type type; - const Char *s; - size_t length; - const Location *loc; - size_t nChunks = 0; - { - TextIter iter(*text); - while (iter.next(type, s, length, loc)) - switch (type) { - case TextItem::data: - case TextItem::sdata: - case TextItem::cdata: - nChunks++; - break; - default: - break; - } - } - p->cdataChunks - = (SGMLApplication::Attribute::CdataChunk *)allocate(nChunks * sizeof(SGMLApplication::Attribute::CdataChunk)); - p->nCdataChunks = nChunks; - - { - size_t i = 0; - for (TextIter iter(*text); - iter.next(type, s, length, loc); - i++) { - switch (type) { - case TextItem::data: - case TextItem::sdata: - case TextItem::cdata: - { - SGMLApplication::Attribute::CdataChunk *chunk - = (SGMLApplication::Attribute::CdataChunk *)(p->cdataChunks + i); - if (type != TextItem::sdata) - chunk->isSdata = 0; - else { - chunk->isSdata = 1; - setString(chunk->entityName, - *loc->origin()->asInputSourceOrigin()->entityName()); - } - chunk->data.ptr = s; - chunk->data.len = length; - } - break; - default: - break; - } - } - } - } - break; - } - } - } -} - - -void GenericEventHandler::setEntity(SGMLApplication::Entity &to, - const Entity &from) -{ - setString(to.name, from.name()); - switch (from.declType()) { - case Entity::generalEntity: - to.declType = SGMLApplication::Entity::general; - break; - case Entity::parameterEntity: - to.declType = SGMLApplication::Entity::parameter; - break; - case Entity::doctype: - to.declType = SGMLApplication::Entity::doctype; - break; - case Entity::linktype: - to.declType = SGMLApplication::Entity::linktype; - break; - default: - CANNOT_HAPPEN(); - } - switch (from.dataType()) { - case Entity::sgmlText: - to.dataType = SGMLApplication::Entity::sgml; - break; - case Entity::cdata: - to.dataType = SGMLApplication::Entity::cdata; - break; - case Entity::sdata: - to.dataType = SGMLApplication::Entity::sdata; - break; - case Entity::ndata: - to.dataType = SGMLApplication::Entity::ndata; - break; - case Entity::subdoc: - to.dataType = SGMLApplication::Entity::subdoc; - break; - case Entity::pi: - to.dataType = SGMLApplication::Entity::pi; - break; - } - const InternalEntity *internal = from.asInternalEntity(); - if (internal) { - to.isInternal = 1; - setString(to.text, internal->string()); - } - else { - const ExternalEntity *external = from.asExternalEntity(); - to.isInternal = 0; - setExternalId(to.externalId, external->externalId()); - const ExternalDataEntity *externalData = from.asExternalDataEntity(); - if (externalData) { - setNotation(to.notation, *externalData->notation()); - to.nAttributes = externalData->attributes().size(); - if (to.nAttributes) - setAttributes(to.attributes, externalData->attributes()); - } - else { - to.notation.name.len = 0; - to.nAttributes = 0; - } - } -} - - -void GenericEventHandler::setNotation(SGMLApplication::Notation &to, - const Notation &from) -{ - setString(to.name, from.name()); - setExternalId(to.externalId, from.externalId()); -} - -void GenericEventHandler::setExternalId(SGMLApplication::ExternalId &to, - const ExternalId &from) -{ - const StringC *str; - str = from.systemIdString(); - if (str) { - to.haveSystemId = 1; - setString(to.systemId, *str); - } - else - to.haveSystemId = 0; - str = from.publicIdString(); - if (str) { - to.havePublicId = 1; - setString(to.publicId, *str); - } - else - to.havePublicId = 0; - str = &from.effectiveSystemId(); - if (str->size()) { - to.haveGeneratedSystemId = 1; - setString(to.generatedSystemId, *str); - } - else - to.haveGeneratedSystemId = 0; -} - -MsgGenericEventHandler::MsgGenericEventHandler(SGMLApplication &app, - bool generalEntities, - MessageReporter &reporter, - const bool *messagesInhibitedPtr) -: GenericEventHandler(app, generalEntities), - reporter_(&reporter), - messagesInhibitedPtr_(messagesInhibitedPtr) -{ -} - -void MsgGenericEventHandler::reportMessage(const Message &msg, StringC &str) -{ - WrapReporter wrap(reporter_); - reporter_->dispatchMessage(msg); - wrap.strStream.extractString(str); - if (!*messagesInhibitedPtr_) - *wrap.origStream << str; -} - -SpOpenEntity::SpOpenEntity(const ConstPtr &origin) -: origin_(origin) -{ -} - -SGMLApplication::Location -SpOpenEntity::location(SGMLApplication::Position pos) const -{ - SGMLApplication::Location loc; - const Origin *origin = origin_.pointer(); - const InputSourceOrigin *inputSourceOrigin; - const ExternalInfo *externalInfo; - Index index = Index(pos); - for (;;) { - if (!origin) - return loc; - inputSourceOrigin = origin->asInputSourceOrigin(); - if (inputSourceOrigin) { - externalInfo = inputSourceOrigin->externalInfo(); - if (externalInfo) - break; - } - const Location &loc = origin->parent(); - index = loc.index(); - origin = loc.origin().pointer(); - } - const StringC *entityName = inputSourceOrigin->entityName(); - if (entityName) - GenericEventHandler::setString(loc.entityName, *entityName); - Offset off = inputSourceOrigin->startOffset(index); - loc.entityOffset = off; - StorageObjectLocation soLoc; - if (!ExtendEntityManager::externalize(externalInfo, off, soLoc)) - return loc; - loc.lineNumber = soLoc.lineNumber; - GenericEventHandler::setString(loc.filename, soLoc.storageObjectSpec->id); - loc.columnNumber = soLoc.columnNumber; - loc.byteOffset = soLoc.byteIndex; - loc.other = soLoc.storageObjectSpec; - return loc; -} - -#ifdef SP_NAMESPACE -} -#endif diff --git a/cde/programs/nsgmls/GenericEventHandler.h b/cde/programs/nsgmls/GenericEventHandler.h deleted file mode 100644 index d5e6e2904..000000000 --- a/cde/programs/nsgmls/GenericEventHandler.h +++ /dev/null @@ -1,149 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: GenericEventHandler.h /main/1 1996/07/29 16:52:21 cde-hp $ */ -// Copyright (c) 1995, 1996 James Clark -// See the file COPYING for copying permission. - -#ifndef GenericEventHandler_INCLUDED -#define GenericEventHandler_INCLUDED 1 - -#ifdef __GNUG__ -#pragma interface -#endif - -// Must include Boolean.h before SGMLApplication.h. - -#include "Boolean.h" -#include "SGMLApplication.h" -#include "Event.h" -#include "MessageReporter.h" -#include "ErrorCountEventHandler.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -class SP_API GenericEventHandler : public ErrorCountEventHandler { -public: - GenericEventHandler(SGMLApplication &, bool generalEntities); - ~GenericEventHandler(); - void message(MessageEvent *); - void appinfo(AppinfoEvent *); - void startDtd(StartDtdEvent *); - void endDtd(EndDtdEvent *); - void endProlog(EndPrologEvent *); - void entityDefaulted(EntityDefaultedEvent *); - void startElement(StartElementEvent *); - void endElement(EndElementEvent *); - void data(DataEvent *); - void pi(PiEvent *); - void sdataEntity(SdataEntityEvent *); - void externalDataEntity(ExternalDataEntityEvent *); - void subdocEntity(SubdocEntityEvent *); - void commentDecl(CommentDeclEvent *); - void ignoredChars(IgnoredCharsEvent *); - void markedSectionStart(MarkedSectionStartEvent *); - void markedSectionEnd(MarkedSectionEndEvent *); - void *allocate(size_t); - void freeAll(); - void freeAll1(); - - struct Block { - Block *next; - char *mem; - size_t size; - }; - static void setString(SGMLApplication::CharString &, const StringC &); - static void clearString(SGMLApplication::CharString &); - virtual void reportMessage(const Message &msg, StringC &) = 0; -private: - GenericEventHandler(const GenericEventHandler &); // undefined - void operator=(const GenericEventHandler &); // undefined - void setLocation(SGMLApplication::Position &, const Location &); - void setLocation1(SGMLApplication::Position &, const Location &); - void setAttributes(const SGMLApplication::Attribute *&attributes, - const AttributeList &attributeList); - void setExternalId(SGMLApplication::ExternalId &to, - const ExternalId &from); - void setEntity(SGMLApplication::Entity &to, const Entity &from); - void setNotation(SGMLApplication::Notation &, const Notation ¬ation); - static void clearNotation(SGMLApplication::Notation &); - static void clearExternalId(SGMLApplication::ExternalId &); - ConstPtr lastOrigin_; - SGMLApplication::OpenEntityPtr openEntityPtr_; - size_t firstBlockUsed_; - size_t firstBlockSpare_; - Block *freeBlocks_; - Block *allocBlocks_; - bool generalEntities_; - SGMLApplication *app_; -}; - -class SP_API MsgGenericEventHandler : public GenericEventHandler { -public: - MsgGenericEventHandler(SGMLApplication &, - bool generalEntities, - MessageReporter &reporter, - const bool *messagesInhibitedPtr); - void reportMessage(const Message &msg, StringC &); -private: - MsgGenericEventHandler(const MsgGenericEventHandler &); // undefined - void operator=(const MsgGenericEventHandler &); // undefined - struct WrapReporter { - WrapReporter(MessageReporter *r) : reporter(r), origStream(0) { - origStream = reporter->releaseMessageStream(); - reporter->setMessageStream(&strStream); - } - ~WrapReporter() { - if (origStream) { - reporter->releaseMessageStream(); - reporter->setMessageStream(origStream); - } - } - MessageReporter *reporter; - OutputCharStream *origStream; - StrOutputCharStream strStream; - }; - const bool *messagesInhibitedPtr_; - MessageReporter *reporter_; -}; - -inline void -GenericEventHandler::setString(SGMLApplication::CharString &to, - const StringC &from) -{ - to.ptr = from.data(); - to.len = from.size(); -} - -inline -void GenericEventHandler::clearString(SGMLApplication::CharString &to) -{ - to.len = 0; -} - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* not GenericEventHandler_INCLUDED */ diff --git a/cde/programs/nsgmls/Group.C b/cde/programs/nsgmls/Group.C deleted file mode 100644 index 803f4c544..000000000 --- a/cde/programs/nsgmls/Group.C +++ /dev/null @@ -1,187 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: Group.C /main/1 1996/07/29 16:52:27 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#ifdef __GNUG__ -#pragma implementation -#endif -#include "splib.h" -#include "Group.h" -#include "MessageBuilder.h" -#include "ParserMessages.h" -#include "macros.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -AllowedGroupTokens::AllowedGroupTokens(GroupToken::Type t1, GroupToken::Type t2, - GroupToken::Type t3, GroupToken::Type t4) -: flags_(0) -{ - allow(t1); - allow(t2); - allow(t3); - allow(t4); -} - -AllowedGroupConnectors::AllowedGroupConnectors(GroupConnector::Type c1) -: flags_(0) -{ - allow(c1); -} - -AllowedGroupConnectors::AllowedGroupConnectors(GroupConnector::Type c1, - GroupConnector::Type c2) -: flags_(0) -{ - allow(c1); - allow(c2); -} - -AllowedGroupConnectors::AllowedGroupConnectors(GroupConnector::Type c1, - GroupConnector::Type c2, - GroupConnector::Type c3) -: flags_(0) -{ - allow(c1); - allow(c2); - allow(c3); -} - -AllowedGroupConnectors::AllowedGroupConnectors(GroupConnector::Type c1, - GroupConnector::Type c2, - GroupConnector::Type c3, - GroupConnector::Type c4) -: flags_(0) -{ - allow(c1); - allow(c2); - allow(c3); - allow(c4); -} - - -AllowedGroupConnectorsMessageArg::AllowedGroupConnectorsMessageArg( - const AllowedGroupConnectors &allow, - const ConstPtr &syntax) -: allow_(allow), - syntax_(syntax) -{ -} - -MessageArg *AllowedGroupConnectorsMessageArg::copy() const -{ - return new AllowedGroupConnectorsMessageArg(*this); -} - -void AllowedGroupConnectorsMessageArg::append(MessageBuilder &builder) const -{ - static GroupConnector::Type types[] = { - GroupConnector::andGC, GroupConnector::orGC, GroupConnector::seqGC, - GroupConnector::grpcGC, GroupConnector::dtgcGC - }; - static Syntax::DelimGeneral delims[] = { - Syntax::dAND, Syntax::dOR, Syntax::dSEQ, - Syntax::dGRPC, Syntax::dDTGC - }; - Boolean first = 1; - for (size_t i = 0; i < SIZEOF(types); i++) - if (allow_.groupConnector(types[i])) { - if (!first) - builder.appendFragment(ParserMessages::listSep); - else - first = 0; - const StringC &delim = syntax_->delimGeneral(delims[i]); - builder.appendFragment(ParserMessages::delimStart); - builder.appendChars(delim.data(), delim.size()); - builder.appendFragment(ParserMessages::delimEnd); - } -} - -AllowedGroupTokensMessageArg::AllowedGroupTokensMessageArg( - const AllowedGroupTokens &allow, - const ConstPtr &syntax) -: allow_(allow), - syntax_(syntax) -{ -} - -MessageArg *AllowedGroupTokensMessageArg::copy() const -{ - return new AllowedGroupTokensMessageArg(*this); -} - -void AllowedGroupTokensMessageArg::append(MessageBuilder &builder) const -{ - const MessageFragment *fragment[4]; - int nFragments = 0; - if (allow_.groupToken(GroupToken::dataTagLiteral)) - fragment[nFragments++] = &ParserMessages::parameterLiteral; - if (allow_.groupToken(GroupToken::dataTagGroup)) - fragment[nFragments++] = &ParserMessages::dataTagGroup; - switch (allow_.group()) { - case GroupToken::modelGroup: - fragment[nFragments++] = &ParserMessages::modelGroup; - break; - case GroupToken::dataTagTemplateGroup: - fragment[nFragments++] = &ParserMessages::dataTagTemplateGroup; - break; - default: - break; - } - switch (allow_.nameStart()) { - case GroupToken::name: - fragment[nFragments++] = &ParserMessages::name; - break; - case GroupToken::nameToken: - fragment[nFragments++] = &ParserMessages::nameToken; - break; - case GroupToken::elementToken: - fragment[nFragments++] = &ParserMessages::elementToken; - break; - default: - break; - } - Boolean first = 1; - for (int i = 0; i < nFragments; i++) { - if (!first) - builder.appendFragment(ParserMessages::listSep); - else - first = 0; - builder.appendFragment(*fragment[i]); - } - if (allow_.groupToken(GroupToken::pcdata)) { - if (!first) - builder.appendFragment(ParserMessages::listSep); - StringC pcdata(syntax_->delimGeneral(Syntax::dRNI)); - pcdata += syntax_->reservedName(Syntax::rPCDATA); - builder.appendChars(pcdata.data(), pcdata.size()); - } -} - -#ifdef SP_NAMESPACE -} -#endif diff --git a/cde/programs/nsgmls/Group.h b/cde/programs/nsgmls/Group.h deleted file mode 100644 index fd2567594..000000000 --- a/cde/programs/nsgmls/Group.h +++ /dev/null @@ -1,186 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: Group.h /main/1 1996/07/29 16:52:34 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#ifndef Group_INCLUDED -#define Group_INCLUDED 1 -#ifdef __GNUG__ -#pragma interface -#endif - -#include "Boolean.h" -#include "ContentToken.h" -#include "StringC.h" -#include "MessageArg.h" -#include "Owner.h" -#include "Syntax.h" -#include "Text.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -class GroupToken { -public: - GroupToken() : type(invalid) { } - enum Type { - invalid, - nameToken, - name, - dataTagLiteral, // data tag (padding) template - dataTagGroup, - elementToken, - modelGroup, - pcdata, - dataTagTemplateGroup - }; - Type type; - StringC token; // name nameToken; with substitution - Owner model; - Owner contentToken; // elementToken pcdata dataTagGroup - Text text; - Vector textVector; -private: - GroupToken(const GroupToken &); // undefined - void operator=(const GroupToken &); // undefined -}; - -class AllowedGroupTokens { -public: - AllowedGroupTokens(GroupToken::Type, - GroupToken::Type = GroupToken::invalid, - GroupToken::Type = GroupToken::invalid, - GroupToken::Type = GroupToken::invalid); - Boolean groupToken(GroupToken::Type) const; - // modelGroup, dataTagTemplateGroup - GroupToken::Type group() const; - GroupToken::Type nameStart() const; -private: - void allow(GroupToken::Type); - unsigned flags_; -}; - -struct GroupConnector { - enum Type { - andGC, - orGC, - seqGC, - grpcGC, - dtgcGC - }; - Type type; -}; - -class AllowedGroupConnectors { -public: - AllowedGroupConnectors(GroupConnector::Type); - AllowedGroupConnectors(GroupConnector::Type, GroupConnector::Type); - AllowedGroupConnectors(GroupConnector::Type, GroupConnector::Type, - GroupConnector::Type); - AllowedGroupConnectors(GroupConnector::Type, GroupConnector::Type, - GroupConnector::Type, GroupConnector::Type); - Boolean groupConnector(GroupConnector::Type) const; -private: - void allow(GroupConnector::Type); - unsigned flags_; -}; - -class AllowedGroupTokensMessageArg : public MessageArg { -public: - AllowedGroupTokensMessageArg(const AllowedGroupTokens &allow, - const ConstPtr &syntax); - MessageArg *copy() const; - void append(MessageBuilder &) const; -private: - AllowedGroupTokens allow_; - ConstPtr syntax_; -}; - -class AllowedGroupConnectorsMessageArg : public MessageArg { -public: - AllowedGroupConnectorsMessageArg(const AllowedGroupConnectors &allow, - const ConstPtr &syntax); - MessageArg *copy() const; - void append(MessageBuilder &) const; -private: - AllowedGroupConnectors allow_; - ConstPtr syntax_; -}; - -inline -Boolean AllowedGroupTokens::groupToken(GroupToken::Type i) const -{ - return ((1 << i) & flags_) != 0; -} - -inline -GroupToken::Type AllowedGroupTokens::group() const -{ - if (groupToken(GroupToken::modelGroup)) - return GroupToken::modelGroup; - else if (groupToken(GroupToken::dataTagTemplateGroup)) - return GroupToken::dataTagTemplateGroup; - else - return GroupToken::invalid; -} - -inline -GroupToken::Type AllowedGroupTokens::nameStart() const -{ - if (groupToken(GroupToken::elementToken)) - return GroupToken::elementToken; - else if (groupToken(GroupToken::nameToken)) - return GroupToken::nameToken; - else if (groupToken(GroupToken::name)) - return GroupToken::name; - else - return GroupToken::invalid; -} - -inline -void AllowedGroupTokens::allow(GroupToken::Type t) -{ - flags_ |= (1 << t); -} - - -inline -Boolean AllowedGroupConnectors::groupConnector(GroupConnector::Type c) const -{ - return (flags_ & (1 << c)) != 0; -} - -inline -void AllowedGroupConnectors::allow(GroupConnector::Type c) -{ - flags_ |= (1 << c); -} - - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* not Group_INCLUDED */ diff --git a/cde/programs/nsgmls/Hash.C b/cde/programs/nsgmls/Hash.C deleted file mode 100644 index 6599768b2..000000000 --- a/cde/programs/nsgmls/Hash.C +++ /dev/null @@ -1,49 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: Hash.C /main/1 1996/07/29 16:52:41 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#ifdef __GNUG__ -#pragma implementation -#endif -#include "splib.h" -#include "Hash.h" -#include "StringC.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -unsigned long Hash::hash(const StringC &str) -{ - const Char *p = str.data(); - unsigned long h = 0; - for (size_t n = str.size(); n > 0; n--) - h = (h << 5) + h + *p++; // from Chris Torek - return h; -} - -#ifdef SP_NAMESPACE -} -#endif diff --git a/cde/programs/nsgmls/Hash.h b/cde/programs/nsgmls/Hash.h deleted file mode 100644 index 297d880ac..000000000 --- a/cde/programs/nsgmls/Hash.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: Hash.h /main/1 1996/07/29 16:52:46 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#ifndef Hash_INCLUDED -#define Hash_INCLUDED 1 -#ifdef __GNUG__ -#pragma interface -#endif - -#include "StringC.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -#ifndef SP_API -#define SP_API /* as nothing */ -#endif - -class SP_API Hash { -public: - static unsigned long hash(const StringC &); -}; - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* not Hash_INCLUDED */ diff --git a/cde/programs/nsgmls/HashTable.C b/cde/programs/nsgmls/HashTable.C deleted file mode 100644 index 6eca3b65f..000000000 --- a/cde/programs/nsgmls/HashTable.C +++ /dev/null @@ -1,64 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: HashTable.C /main/1 1996/07/29 16:52:50 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#ifndef HashTable_DEF_INCLUDED -#define HashTable_DEF_INCLUDED 1 - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -template -void HashTable::insert(const K &key, const V &value, Boolean replace) -{ - HashTableItem *newItem = new HashTableItem(key, value); - HashTableItem *tem = (HashTableItem *)table_.insert(newItem); - if (tem) { - delete newItem; - if (replace) { - tem->key = key; - tem->value = value; - } - } -} - -template -HashTableItem::HashTableItem(const K &k, const V &v) -: HashTableItemBase(k), value(v) -{ -} - -template -HashTableItemBase *HashTableItem::copy() const -{ - return new HashTableItem(*this); -} - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* not HashTable_DEF_INCLUDED */ diff --git a/cde/programs/nsgmls/HashTable.h b/cde/programs/nsgmls/HashTable.h deleted file mode 100644 index b6318f5f5..000000000 --- a/cde/programs/nsgmls/HashTable.h +++ /dev/null @@ -1,91 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: HashTable.h /main/1 1996/07/29 16:52:57 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#ifndef HashTable_INCLUDED -#define HashTable_INCLUDED 1 - -#include -#include "OwnerTable.h" -#include "Hash.h" -#include "Boolean.h" -#include "HashTableItemBase.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -template -class HashTableItem : public HashTableItemBase { -public: - HashTableItem(const K &k, const V &v); - HashTableItemBase *copy() const; - V value; -}; - -template class HashTableIter; - -template -class HashTable { -public: - HashTable() { } - void insert(const K &key, const V &value, Boolean replace = 1); - const V *lookup(const K &key) const { - HashTableItem *tem = (HashTableItem *)table_.lookup(key); - return tem ? &tem->value : 0; - } - size_t count() const { return table_.count(); } -private: - CopyOwnerTable, K, Hash, HashTableKeyFunction > table_; -friend class HashTableIter; -}; - -template -class HashTableIter { -public: - HashTableIter(const HashTable &table) : iter_(table.table_) { } - Boolean next(const K *&key, const V *&value) { - HashTableItem *p = (HashTableItem *)iter_.next(); - if (p) { - key = &p->key; - value = &p->value; - return 1; - } - else - return 0; - } -private: - OwnerTableIter, K, Hash, HashTableKeyFunction > iter_; -}; - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* not HashTable_INCLUDED */ - -#ifdef SP_DEFINE_TEMPLATES -#include "HashTable.C" -#endif diff --git a/cde/programs/nsgmls/HashTableItemBase.C b/cde/programs/nsgmls/HashTableItemBase.C deleted file mode 100644 index 87715d994..000000000 --- a/cde/programs/nsgmls/HashTableItemBase.C +++ /dev/null @@ -1,49 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: HashTableItemBase.C /main/1 1996/07/29 16:53:04 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#ifndef HashTableItemBase_DEF_INCLUDED -#define HashTableItemBase_DEF_INCLUDED 1 - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -template -HashTableItemBase::~HashTableItemBase() -{ -} - -template -HashTableItemBase::HashTableItemBase(const K &k) : key(k) -{ -} - - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* not HashTableItemBase_DEF_INCLUDED */ diff --git a/cde/programs/nsgmls/HashTableItemBase.h b/cde/programs/nsgmls/HashTableItemBase.h deleted file mode 100644 index abc525ce7..000000000 --- a/cde/programs/nsgmls/HashTableItemBase.h +++ /dev/null @@ -1,61 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: HashTableItemBase.h /main/1 1996/07/29 16:53:09 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#ifndef HashTableItemBase_INCLUDED -#define HashTableItemBase_INCLUDED 1 - -// All hash tables with the same type of key share object code. -// The cost of this is a virtual dtor in HashTableItemBase. - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -template -class HashTableItemBase { -public: - HashTableItemBase(const K &k); - virtual ~HashTableItemBase(); - virtual HashTableItemBase *copy() const = 0; - K key; -}; - -template -struct HashTableKeyFunction { - static inline const K &key(const HashTableItemBase &obj) { - return obj.key; - } -}; - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* not HashTableItemBase_INCLUDED */ - -#ifdef SP_DEFINE_TEMPLATES -#include "HashTableItemBase.C" -#endif diff --git a/cde/programs/nsgmls/IList.h b/cde/programs/nsgmls/IList.h deleted file mode 100644 index f39b52386..000000000 --- a/cde/programs/nsgmls/IList.h +++ /dev/null @@ -1,64 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: IList.h /main/2 1996/08/13 10:08:48 mgreess $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#ifndef IList_INCLUDED -#define IList_INCLUDED 1 - -#include "IListBase.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -template class IListIter; - -// This owns the objects that are put in it. - -template -class IList : private IListBase { -public: - IList() { } - IList(T *p) : IListBase(p) { } - ~IList() { clear(); } - void append(T *p) { IListBase::append(p); } - void insert(T *p) { IListBase::insert(p); } - void remove(T *p) { IListBase::remove(p); } - void swap(IList &list) { IListBase::swap(list); } - T *head() const { return (T *)IListBase::head(); } - T *get() { return (T *)IListBase::get(); } - using IListBase::clear; - using IListBase::empty; -friend class IListIter; -private: - IList(const IList &) {} - IList &operator=(const IList &) { return *this; } -}; - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* not IList_INCLUDED */ diff --git a/cde/programs/nsgmls/IListBase.C b/cde/programs/nsgmls/IListBase.C deleted file mode 100644 index 52b5de6f4..000000000 --- a/cde/programs/nsgmls/IListBase.C +++ /dev/null @@ -1,59 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: IListBase.C /main/1 1996/07/29 16:53:20 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#include "splib.h" -#include "IListBase.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -void IListBase::append(Link *p) -{ - Link **pp; - for (pp = &head_; *pp; pp = &(*pp)->next_) - ; - *pp = p; -} - -void IListBase::remove(Link *p) -{ - for (Link **pp = &head_; *pp; pp = &(*pp)->next_) - if (*pp == p) { - *pp = p->next_; - break; - } -} - -void IListBase::clear() -{ - while (!empty()) - delete get(); -} - -#ifdef SP_NAMESPACE -} -#endif diff --git a/cde/programs/nsgmls/IListBase.h b/cde/programs/nsgmls/IListBase.h deleted file mode 100644 index a20297f8f..000000000 --- a/cde/programs/nsgmls/IListBase.h +++ /dev/null @@ -1,103 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: IListBase.h /main/1 1996/07/29 16:53:26 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#ifndef IListBase_INCLUDED -#define IListBase_INCLUDED 1 - -#include "Link.h" -#include "Boolean.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -class SP_API IListBase { -public: - IListBase(); - IListBase(Link *); - void append(Link *); - void insert(Link *); - Link *head() const; - Boolean empty() const; - Link *get(); - void remove(Link *); - void swap(IListBase &); - void clear(); -private: - Link *head_; -friend class IListIterBase; -}; - -inline -IListBase::IListBase() : head_(0) -{ -} - -inline -IListBase::IListBase(Link *head) : head_(head) -{ -} - -inline -void IListBase::insert(Link *p) -{ - p->next_ = head_; - head_ = p; -} - -inline -Link *IListBase::head() const -{ - return head_; -} - -inline -Boolean IListBase::empty() const -{ - return head_ == 0; -} - -inline -Link *IListBase::get() -{ - Link *tem = head_; - head_ = head_->next_; - return tem; -} - -inline -void IListBase::swap(IListBase &list) -{ - Link *tem = head_; - head_ = list.head_; - list.head_ = tem; -} - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* not IListBase_INCLUDED */ diff --git a/cde/programs/nsgmls/IListIter.h b/cde/programs/nsgmls/IListIter.h deleted file mode 100644 index c2669dfa5..000000000 --- a/cde/programs/nsgmls/IListIter.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: IListIter.h /main/1 1996/07/29 16:53:32 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#ifndef IListIter_INCLUDED -#define IListIter_INCLUDED 1 - -#include "IListIterBase.h" -#include "IList.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -template -class IListIter : private IListIterBase { -public: - IListIter(const IList &list) : IListIterBase(list) { } - T *cur() { return (T *)IListIterBase::cur(); } - - using IListIterBase::next; - using IListIterBase::done; -}; - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* not IListIter_INCLUDED */ diff --git a/cde/programs/nsgmls/IListIterBase.h b/cde/programs/nsgmls/IListIterBase.h deleted file mode 100644 index 66e19da51..000000000 --- a/cde/programs/nsgmls/IListIterBase.h +++ /dev/null @@ -1,74 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: IListIterBase.h /main/1 1996/07/29 16:53:38 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#ifndef IListIterBase_INCLUDED -#define IListIterBase_INCLUDED 1 - -#include "Link.h" -#include "IListBase.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -class SP_API IListIterBase { -public: - IListIterBase(const IListBase &); - int done(); - Link *cur(); - void next(); -private: - Link *p_; -}; - -inline -IListIterBase::IListIterBase(const IListBase &list) : p_(list.head_) -{ -} - -inline -int IListIterBase::done() -{ - return p_ == 0; -} - -inline -Link *IListIterBase::cur() -{ - return p_; -} - -inline -void IListIterBase::next() -{ - p_ = p_->next_; -} - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* not IListIterBase_INCLUDED */ diff --git a/cde/programs/nsgmls/IQueue.C b/cde/programs/nsgmls/IQueue.C deleted file mode 100644 index 51a4e8d39..000000000 --- a/cde/programs/nsgmls/IQueue.C +++ /dev/null @@ -1,45 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: IQueue.C /main/1 1996/07/29 16:53:45 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#ifndef IQueue_DEF_INCLUDED -#define IQueue_DEF_INCLUDED 1 - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -template -void IQueue::clear() -{ - while (!empty()) - delete get(); -} - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* not IQueue_DEF_INCLUDED */ diff --git a/cde/programs/nsgmls/IQueue.h b/cde/programs/nsgmls/IQueue.h deleted file mode 100644 index 5cd5faa1e..000000000 --- a/cde/programs/nsgmls/IQueue.h +++ /dev/null @@ -1,88 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: IQueue.h /main/1 1996/07/29 16:53:51 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#ifndef IQueue_INCLUDED -#define IQueue_INCLUDED 1 - -#include "Boolean.h" -#include "Link.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -class IQueueBase { -public: - IQueueBase() : last_(0) { } - ~IQueueBase() { } - Boolean empty() const { return last_ == 0; } - Link *get() { - Link *tem = last_->next_; - if (tem == last_) - last_ = 0; - else - last_->next_ = tem->next_; - return tem; - } - void append(Link *p) { - if (last_) { - p->next_ = last_->next_; - last_ = last_->next_ = p; - } - else - last_ = p->next_ = p; - } - void swap(IQueueBase &with) { - Link *tem = last_; - last_ = with.last_; - with.last_ = tem; - } -private: - Link *last_; - -}; - -template -class IQueue : private IQueueBase { -public: - IQueue() { } - ~IQueue() { clear(); } - void clear(); - T *get() { return (T *)IQueueBase::get(); } - void append(T *p) { IQueueBase::append(p); } - Boolean empty() const { return IQueueBase::empty(); } - void swap(IQueue &to) { IQueueBase::swap(to); } -}; - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* not IQueue_INCLUDED */ - -#ifdef SP_DEFINE_TEMPLATES -#include "IQueue.C" -#endif diff --git a/cde/programs/nsgmls/ISO8859InputCodingSystem.C b/cde/programs/nsgmls/ISO8859InputCodingSystem.C deleted file mode 100644 index 4a3c2e469..000000000 --- a/cde/programs/nsgmls/ISO8859InputCodingSystem.C +++ /dev/null @@ -1,338 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: ISO8859InputCodingSystem.C /main/1 1996/07/29 16:53:56 cde-hp $ */ -// Copyright (c) 1995 James Clark -// See the file COPYING for copying permission. - -#include "splib.h" -#ifdef SP_MULTI_BYTE - -#include "ISO8859InputCodingSystem.h" -#include "macros.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -inline const Char *ISO8859InputCodingSystem::partMap(int part) -{ - ASSERT(2 <= part && part <= 9); - return maps[part - 2]; -} - -ISO8859InputCodingSystem::ISO8859InputCodingSystem(int part) -: TranslateInputCodingSystem(partMap(part)) -{ -} - -#define INVALID 0xFFFD - -// Tables mapping ISO 8859-2 through ISO 8859-9 to ISO 10646. -// Generated from Unicode Consortium data. - -const Char ISO8859InputCodingSystem::maps[8][256] = { - { - 0, 1, 2, 3, 4, 5, 6, 7, - 8, 9, 10, 11, 12, 13, 14, 15, - 16, 17, 18, 19, 20, 21, 22, 23, - 24, 25, 26, 27, 28, 29, 30, 31, - 32, 33, 34, 35, 36, 37, 38, 39, - 40, 41, 42, 43, 44, 45, 46, 47, - 48, 49, 50, 51, 52, 53, 54, 55, - 56, 57, 58, 59, 60, 61, 62, 63, - 64, 65, 66, 67, 68, 69, 70, 71, - 72, 73, 74, 75, 76, 77, 78, 79, - 80, 81, 82, 83, 84, 85, 86, 87, - 88, 89, 90, 91, 92, 93, 94, 95, - 96, 97, 98, 99, 100, 101, 102, 103, - 104, 105, 106, 107, 108, 109, 110, 111, - 112, 113, 114, 115, 116, 117, 118, 119, - 120, 121, 122, 123, 124, 125, 126, 127, - 128, 129, 130, 131, 132, 133, 134, 135, - 136, 137, 138, 139, 140, 141, 142, 143, - 144, 145, 146, 147, 148, 149, 150, 151, - 152, 153, 154, 155, 156, 157, 158, 159, - 160, 260, 728, 321, 164, 317, 346, 167, - 168, 352, 350, 356, 377, 173, 381, 379, - 176, 261, 731, 322, 180, 318, 347, 711, - 184, 353, 351, 357, 378, 733, 382, 380, - 340, 193, 194, 258, 196, 313, 262, 199, - 268, 201, 280, 203, 282, 205, 206, 270, - 272, 323, 327, 211, 212, 336, 214, 215, - 344, 366, 218, 368, 220, 221, 354, 223, - 341, 225, 226, 259, 228, 314, 263, 231, - 269, 233, 281, 235, 283, 237, 238, 271, - 273, 324, 328, 243, 244, 337, 246, 247, - 345, 367, 250, 369, 252, 253, 355, 729, - }, - { - 0, 1, 2, 3, 4, 5, 6, 7, - 8, 9, 10, 11, 12, 13, 14, 15, - 16, 17, 18, 19, 20, 21, 22, 23, - 24, 25, 26, 27, 28, 29, 30, 31, - 32, 33, 34, 35, 36, 37, 38, 39, - 40, 41, 42, 43, 44, 45, 46, 47, - 48, 49, 50, 51, 52, 53, 54, 55, - 56, 57, 58, 59, 60, 61, 62, 63, - 64, 65, 66, 67, 68, 69, 70, 71, - 72, 73, 74, 75, 76, 77, 78, 79, - 80, 81, 82, 83, 84, 85, 86, 87, - 88, 89, 90, 91, 92, 93, 94, 95, - 96, 97, 98, 99, 100, 101, 102, 103, - 104, 105, 106, 107, 108, 109, 110, 111, - 112, 113, 114, 115, 116, 117, 118, 119, - 120, 121, 122, 123, 124, 125, 126, 127, - 128, 129, 130, 131, 132, 133, 134, 135, - 136, 137, 138, 139, 140, 141, 142, 143, - 144, 145, 146, 147, 148, 149, 150, 151, - 152, 153, 154, 155, 156, 157, 158, 159, - 160, 294, 728, 163, 164, INVALID, 292, 167, - 168, 304, 350, 286, 308, 173, INVALID, 379, - 176, 295, 178, 179, 180, 181, 293, 183, - 184, 305, 351, 287, 309, 189, INVALID, 380, - 192, 193, 194, INVALID, 196, 266, 264, 199, - 200, 201, 202, 203, 204, 205, 206, 207, - INVALID, 209, 210, 211, 212, 288, 214, 215, - 284, 217, 218, 219, 220, 364, 348, 223, - 224, 225, 226, INVALID, 228, 267, 265, 231, - 232, 233, 234, 235, 236, 237, 238, 239, - INVALID, 241, 242, 243, 244, 289, 246, 247, - 285, 249, 250, 251, 252, 365, 349, 729, - }, - { - 0, 1, 2, 3, 4, 5, 6, 7, - 8, 9, 10, 11, 12, 13, 14, 15, - 16, 17, 18, 19, 20, 21, 22, 23, - 24, 25, 26, 27, 28, 29, 30, 31, - 32, 33, 34, 35, 36, 37, 38, 39, - 40, 41, 42, 43, 44, 45, 46, 47, - 48, 49, 50, 51, 52, 53, 54, 55, - 56, 57, 58, 59, 60, 61, 62, 63, - 64, 65, 66, 67, 68, 69, 70, 71, - 72, 73, 74, 75, 76, 77, 78, 79, - 80, 81, 82, 83, 84, 85, 86, 87, - 88, 89, 90, 91, 92, 93, 94, 95, - 96, 97, 98, 99, 100, 101, 102, 103, - 104, 105, 106, 107, 108, 109, 110, 111, - 112, 113, 114, 115, 116, 117, 118, 119, - 120, 121, 122, 123, 124, 125, 126, 127, - 128, 129, 130, 131, 132, 133, 134, 135, - 136, 137, 138, 139, 140, 141, 142, 143, - 144, 145, 146, 147, 148, 149, 150, 151, - 152, 153, 154, 155, 156, 157, 158, 159, - 160, 260, 312, 342, 164, 296, 315, 167, - 168, 352, 274, 290, 358, 173, 381, 175, - 176, 261, 731, 343, 180, 297, 316, 711, - 184, 353, 275, 291, 359, 330, 382, 331, - 256, 193, 194, 195, 196, 197, 198, 302, - 268, 201, 280, 203, 278, 205, 206, 298, - 272, 325, 332, 310, 212, 213, 214, 215, - 216, 370, 218, 219, 220, 360, 362, 223, - 257, 225, 226, 227, 228, 229, 230, 303, - 269, 233, 281, 235, 279, 237, 238, 299, - 273, 326, 333, 311, 244, 245, 246, 247, - 248, 371, 250, 251, 252, 361, 363, 729, - }, - { - 0, 1, 2, 3, 4, 5, 6, 7, - 8, 9, 10, 11, 12, 13, 14, 15, - 16, 17, 18, 19, 20, 21, 22, 23, - 24, 25, 26, 27, 28, 29, 30, 31, - 32, 33, 34, 35, 36, 37, 38, 39, - 40, 41, 42, 43, 44, 45, 46, 47, - 48, 49, 50, 51, 52, 53, 54, 55, - 56, 57, 58, 59, 60, 61, 62, 63, - 64, 65, 66, 67, 68, 69, 70, 71, - 72, 73, 74, 75, 76, 77, 78, 79, - 80, 81, 82, 83, 84, 85, 86, 87, - 88, 89, 90, 91, 92, 93, 94, 95, - 96, 97, 98, 99, 100, 101, 102, 103, - 104, 105, 106, 107, 108, 109, 110, 111, - 112, 113, 114, 115, 116, 117, 118, 119, - 120, 121, 122, 123, 124, 125, 126, 127, - 128, 129, 130, 131, 132, 133, 134, 135, - 136, 137, 138, 139, 140, 141, 142, 143, - 144, 145, 146, 147, 148, 149, 150, 151, - 152, 153, 154, 155, 156, 157, 158, 159, - 160, 1025, 1026, 1027, 1028, 1029, 1030, 1031, - 1032, 1033, 1034, 1035, 1036, 173, 1038, 1039, - 1040, 1041, 1042, 1043, 1044, 1045, 1046, 1047, - 1048, 1049, 1050, 1051, 1052, 1053, 1054, 1055, - 1056, 1057, 1058, 1059, 1060, 1061, 1062, 1063, - 1064, 1065, 1066, 1067, 1068, 1069, 1070, 1071, - 1072, 1073, 1074, 1075, 1076, 1077, 1078, 1079, - 1080, 1081, 1082, 1083, 1084, 1085, 1086, 1087, - 1088, 1089, 1090, 1091, 1092, 1093, 1094, 1095, - 1096, 1097, 1098, 1099, 1100, 1101, 1102, 1103, - 8470, 1105, 1106, 1107, 1108, 1109, 1110, 1111, - 1112, 1113, 1114, 1115, 1116, 167, 1118, 1119, - }, - { - 0, 1, 2, 3, 4, 5, 6, 7, - 8, 9, 10, 11, 12, 13, 14, 15, - 16, 17, 18, 19, 20, 21, 22, 23, - 24, 25, 26, 27, 28, 29, 30, 31, - 32, 33, 34, 35, 36, 37, 38, 39, - 40, 41, 42, 43, 44, 45, 46, 47, - 1632, 1633, 1634, 1635, 1636, 1637, 1638, 1639, - 1640, 1641, 58, 59, 60, 61, 62, 63, - 64, 65, 66, 67, 68, 69, 70, 71, - 72, 73, 74, 75, 76, 77, 78, 79, - 80, 81, 82, 83, 84, 85, 86, 87, - 88, 89, 90, 91, 92, 93, 94, 95, - 96, 97, 98, 99, 100, 101, 102, 103, - 104, 105, 106, 107, 108, 109, 110, 111, - 112, 113, 114, 115, 116, 117, 118, 119, - 120, 121, 122, 123, 124, 125, 126, 127, - 128, 129, 130, 131, 132, 133, 134, 135, - 136, 137, 138, 139, 140, 141, 142, 143, - 144, 145, 146, 147, 148, 149, 150, 151, - 152, 153, 154, 155, 156, 157, 158, 159, - 160, INVALID, INVALID, INVALID, 164, INVALID, INVALID, INVALID, - INVALID, INVALID, INVALID, INVALID, 1548, 173, INVALID, INVALID, - INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, - INVALID, INVALID, INVALID, 1563, INVALID, INVALID, INVALID, 1567, - INVALID, 1569, 1570, 1571, 1572, 1573, 1574, 1575, - 1576, 1577, 1578, 1579, 1580, 1581, 1582, 1583, - 1584, 1585, 1586, 1587, 1588, 1589, 1590, 1591, - 1592, 1593, 1594, INVALID, INVALID, INVALID, INVALID, INVALID, - 1600, 1601, 1602, 1603, 1604, 1605, 1606, 1607, - 1608, 1609, 1610, 1611, 1612, 1613, 1614, 1615, - 1616, 1617, 1618, INVALID, INVALID, INVALID, INVALID, INVALID, - INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, - }, - { - 0, 1, 2, 3, 4, 5, 6, 7, - 8, 9, 10, 11, 12, 13, 14, 15, - 16, 17, 18, 19, 20, 21, 22, 23, - 24, 25, 26, 27, 28, 29, 30, 31, - 32, 33, 34, 35, 36, 37, 38, 39, - 40, 41, 42, 43, 44, 45, 46, 47, - 48, 49, 50, 51, 52, 53, 54, 55, - 56, 57, 58, 59, 60, 61, 62, 63, - 64, 65, 66, 67, 68, 69, 70, 71, - 72, 73, 74, 75, 76, 77, 78, 79, - 80, 81, 82, 83, 84, 85, 86, 87, - 88, 89, 90, 91, 92, 93, 94, 95, - 96, 97, 98, 99, 100, 101, 102, 103, - 104, 105, 106, 107, 108, 109, 110, 111, - 112, 113, 114, 115, 116, 117, 118, 119, - 120, 121, 122, 123, 124, 125, 126, 127, - 128, 129, 130, 131, 132, 133, 134, 135, - 136, 137, 138, 139, 140, 141, 142, 143, - 144, 145, 146, 147, 148, 149, 150, 151, - 152, 153, 154, 155, 156, 157, 158, 159, - 160, 701, 700, 163, INVALID, INVALID, 166, 167, - 168, 169, INVALID, 171, 172, 173, INVALID, 8213, - 176, 177, 178, 179, 900, 901, 902, 183, - 904, 905, 906, 187, 908, 189, 910, 911, - 912, 913, 914, 915, 916, 917, 918, 919, - 920, 921, 922, 923, 924, 925, 926, 927, - 928, 929, INVALID, 931, 932, 933, 934, 935, - 936, 937, 938, 939, 940, 941, 942, 943, - 944, 945, 946, 947, 948, 949, 950, 951, - 952, 953, 954, 955, 956, 957, 958, 959, - 960, 961, 962, 963, 964, 965, 966, 967, - 968, 969, 970, 971, 972, 973, 974, INVALID, - }, - { - 0, 1, 2, 3, 4, 5, 6, 7, - 8, 9, 10, 11, 12, 13, 14, 15, - 16, 17, 18, 19, 20, 21, 22, 23, - 24, 25, 26, 27, 28, 29, 30, 31, - 32, 33, 34, 35, 36, 37, 38, 39, - 40, 41, 42, 43, 44, 45, 46, 47, - 48, 49, 50, 51, 52, 53, 54, 55, - 56, 57, 58, 59, 60, 61, 62, 63, - 64, 65, 66, 67, 68, 69, 70, 71, - 72, 73, 74, 75, 76, 77, 78, 79, - 80, 81, 82, 83, 84, 85, 86, 87, - 88, 89, 90, 91, 92, 93, 94, 95, - 96, 97, 98, 99, 100, 101, 102, 103, - 104, 105, 106, 107, 108, 109, 110, 111, - 112, 113, 114, 115, 116, 117, 118, 119, - 120, 121, 122, 123, 124, 125, 126, 127, - 128, 129, 130, 131, 132, 133, 134, 135, - 136, 137, 138, 139, 140, 141, 142, 143, - 144, 145, 146, 147, 148, 149, 150, 151, - 152, 153, 154, 155, 156, 157, 158, 159, - 160, INVALID, 162, 163, 164, 165, 166, 167, - 168, 169, 215, 171, 172, 173, 174, 8254, - 176, 177, 178, 179, 180, 181, 182, 183, - 184, 185, 247, 187, 188, 189, 190, INVALID, - INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, - INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, - INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, - INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, INVALID, 8215, - 1488, 1489, 1490, 1491, 1492, 1493, 1494, 1495, - 1496, 1497, 1498, 1499, 1500, 1501, 1502, 1503, - 1504, 1505, 1506, 1507, 1508, 1509, 1510, 1511, - 1512, 1513, 1514, INVALID, INVALID, INVALID, INVALID, INVALID, - }, - { - 0, 1, 2, 3, 4, 5, 6, 7, - 8, 9, 10, 11, 12, 13, 14, 15, - 16, 17, 18, 19, 20, 21, 22, 23, - 24, 25, 26, 27, 28, 29, 30, 31, - 32, 33, 34, 35, 36, 37, 38, 39, - 40, 41, 42, 43, 44, 45, 46, 47, - 48, 49, 50, 51, 52, 53, 54, 55, - 56, 57, 58, 59, 60, 61, 62, 63, - 64, 65, 66, 67, 68, 69, 70, 71, - 72, 73, 74, 75, 76, 77, 78, 79, - 80, 81, 82, 83, 84, 85, 86, 87, - 88, 89, 90, 91, 92, 93, 94, 95, - 96, 97, 98, 99, 100, 101, 102, 103, - 104, 105, 106, 107, 108, 109, 110, 111, - 112, 113, 114, 115, 116, 117, 118, 119, - 120, 121, 122, 123, 124, 125, 126, 127, - 128, 129, 130, 131, 132, 133, 134, 135, - 136, 137, 138, 139, 140, 141, 142, 143, - 144, 145, 146, 147, 148, 149, 150, 151, - 152, 153, 154, 155, 156, 157, 158, 159, - 160, 161, 162, 163, 164, 165, 166, 167, - 168, 169, 170, 171, 172, 173, 174, 175, - 176, 177, 178, 179, 180, 181, 182, 183, - 184, 185, 186, 187, 188, 189, 190, 191, - 192, 193, 194, 195, 196, 197, 198, 199, - 200, 201, 202, 203, 204, 205, 206, 207, - 286, 209, 210, 211, 212, 213, 214, 215, - 216, 217, 218, 219, 220, 304, 350, 223, - 224, 225, 226, 227, 228, 229, 230, 231, - 232, 233, 234, 235, 236, 237, 238, 239, - 287, 241, 242, 243, 244, 245, 246, 247, - 248, 249, 250, 251, 252, 305, 351, 255, - } -}; - -#ifdef SP_NAMESPACE -} -#endif - -#else /* not SP_MULTI_BYTE */ - -#ifndef __GNUG__ -static char non_empty_translation_unit; // sigh -#endif - -#endif /* not SP_MULTI_BYTE */ diff --git a/cde/programs/nsgmls/ISO8859InputCodingSystem.h b/cde/programs/nsgmls/ISO8859InputCodingSystem.h deleted file mode 100644 index f88ac4f85..000000000 --- a/cde/programs/nsgmls/ISO8859InputCodingSystem.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: ISO8859InputCodingSystem.h /main/1 1996/07/29 16:54:04 cde-hp $ */ -// Copyright (c) 1995 James Clark -// See the file COPYING for copying permission. - -#ifndef ISO8859InputCodingSystem_INCLUDED -#define ISO8859InputCodingSystem_INCLUDED 1 - -#include "TranslateInputCodingSystem.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -class SP_API ISO8859InputCodingSystem : public TranslateInputCodingSystem { -public: - // part must be between 2 and 9 - ISO8859InputCodingSystem(int part); -private: - const Char *partMap(int); - static const Char maps[8][256]; -}; - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* not ISO8859InputCodingSystem_INCLUDED */ diff --git a/cde/programs/nsgmls/ISet.C b/cde/programs/nsgmls/ISet.C deleted file mode 100644 index 449a288eb..000000000 --- a/cde/programs/nsgmls/ISet.C +++ /dev/null @@ -1,153 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: ISet.C /main/1 1996/07/29 16:54:10 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#ifndef ISet_DEF_INCLUDED -#define ISet_DEF_INCLUDED 1 - -#include - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -template -ISet::ISet() -{ -} - -template -ISet::~ISet() -{ -} - -template -ISet::ISet(const T *v, size_t n) -{ - for (size_t i = 0; i < n; i++) - add(v[i]); -} - -template -Boolean ISet::contains(T x) const -{ - for (size_t i = 0; i < r_.size(); i++) - if (r_[i].max >= x) - return r_[i].min <= x ? 1 : 0; - return 0; -} - -template -void ISet::addRange(T min, T max) -{ - size_t i; - if (min == 0) - i = 0; - else { - for (i = r_.size(); i > 0 && min - 1 <= r_[i - 1].max; i--) - ; - } - // r_[i - 1].max < min - 1 <= r_[i].max - if (i < r_.size() && (r_[i].min == 0 || max >= r_[i].min - 1)) { - // we can coelesce - if (min < r_[i].min) - r_[i].min = min; - if (max > r_[i].max) { - r_[i].max = max; - size_t j; - for (j = i + 1; j < r_.size() && r_[i].max >= r_[j].min - 1; j++) - r_[i].max = r_[j].max; - // get rid of i + 1 ... j - 1 - if (j > i + 1) { - for (size_t k = j; k < r_.size(); k++) - r_[k - (j - i - 1)] = r_[k]; - r_.resize(r_.size() - (j - i - 1)); - } - } - } - else { - // r_[i - 1].max < min - 1 - // max + 1 < r_[i].min - r_.resize(r_.size() + 1); - for (size_t j = r_.size() - 1; j > i; j--) - r_[j] = r_[j - 1]; - r_[i].max = max; - r_[i].min = min; - } -} - -template -void ISet::remove(T c) -{ - for (size_t i = 0; i < r_.size(); i++) - if (r_[i].max >= c) { - if (r_[i].min <= c) { - if (r_[i].min == r_[i].max) { - while (++i < r_.size()) - r_[i - 1] = r_[i]; - r_.resize(r_.size() - 1); - } - else if (c == r_[i].min) - r_[i].min += 1; - else if (c == r_[i].max) - r_[i].max -= 1; - else { - r_.resize(r_.size() + 1); - // split the range - // subtracting 2 is safe since we know that the length is >= 2 - for (size_t j = r_.size() - 2; j > i; j--) - r_[j + 1] = r_[j]; - r_[i + 1].max = r_[i].max; - r_[i + 1].min = c + 1; - r_[i].max = c - 1; - } - } - break; - } -} - -template -void ISet::check() -{ - for (size_t i = 0; i < r_.size(); i++) { - if (r_[i].min > r_[i].max) - abort(); - // adjacent ranges must be coalesced - if (i > 0 && r_[i].min - 1 <= r_[i - 1].max) - abort(); - } -} - -template -void ISet::clear() -{ - r_.resize(0); -} - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* not ISet_DEF_INCLUDED */ diff --git a/cde/programs/nsgmls/ISet.h b/cde/programs/nsgmls/ISet.h deleted file mode 100644 index 9fb196c3f..000000000 --- a/cde/programs/nsgmls/ISet.h +++ /dev/null @@ -1,83 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: ISet.h /main/1 1996/07/29 16:54:18 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#ifndef ISet_INCLUDED -#define ISet_INCLUDED - - -#include -#include "Vector.h" -#include "Boolean.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -template class ISetIter; - -template -struct ISetRange { - ISetRange() { } - ~ISetRange() { } - T min; - T max; -}; - -template -class ISet { -public: - ISet(); - ISet(const T *, size_t); - ~ISet(); - Boolean contains(T) const; - void remove(T); - void add(T x) { addRange(x, x); } - void addRange(T, T); -#if 0 - void add(const ISet &); -#endif - void check(); - void operator+=(T x) { addRange(x, x); } - void clear(); - Boolean isSingleton() const { - return r_.size() == 1 && r_[0].min == r_[0].max; - } - Boolean isEmpty() const { return r_.size() == 0; } - void swap(ISet &x) { r_.swap(x.r_); } -friend class ISetIter; -private: - Vector > r_; -}; - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* not ISet_INCLUDED */ - -#ifdef SP_DEFINE_TEMPLATES -#include "ISet.C" -#endif diff --git a/cde/programs/nsgmls/ISetIter.h b/cde/programs/nsgmls/ISetIter.h deleted file mode 100644 index c15eb573d..000000000 --- a/cde/programs/nsgmls/ISetIter.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: ISetIter.h /main/1 1996/07/29 16:54:26 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#ifndef ISetIter_INCLUDED -#define ISetIter_INCLUDED - -#include -#include "ISet.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -template -class ISetIter { -public: - ISetIter(const ISet &s) : p_(&s), i_(0) { } - // min and max are not changed if 0 is returned. - int next(T &min, T &max) - { - if (i_ < p_->r_.size()) { - min = p_->r_[i_].min; - max = p_->r_[i_].max; - i_++; - return 1; - } - else - return 0; - } - -private: - const ISet *p_; - size_t i_; -}; - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* ISetIter_INCLUDED */ diff --git a/cde/programs/nsgmls/Id.C b/cde/programs/nsgmls/Id.C deleted file mode 100644 index 35fa1c8a4..000000000 --- a/cde/programs/nsgmls/Id.C +++ /dev/null @@ -1,53 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: Id.C /main/1 1996/07/29 16:54:32 cde-hp $ */ -// Copyright (c) 1996 James Clark -// See the file COPYING for copying permission. - -#ifdef __GNUG__ -#pragma implementation -#endif - -#include "splib.h" -#include "Id.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -Id::Id(const StringC &name) -: Named(name) -{ -} - -void Id::define(const Location &loc) -{ - defLocation_ = loc; - // release memory for pendingRefs_ - Vector tem; - pendingRefs_.swap(tem); -} - -#ifdef SP_NAMESPACE -} -#endif diff --git a/cde/programs/nsgmls/Id.h b/cde/programs/nsgmls/Id.h deleted file mode 100644 index 85b45a1e2..000000000 --- a/cde/programs/nsgmls/Id.h +++ /dev/null @@ -1,83 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: Id.h /main/1 1996/07/29 16:54:38 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#ifndef Id_INCLUDED -#define Id_INCLUDED 1 - -#ifdef __GNUG__ -#pragma interface -#endif - -#include "Named.h" -#include "Location.h" -#include "Vector.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -class Id : public Named { -public: - Id(const StringC &); - void define(const Location &); - void addPendingRef(const Location &); - Boolean defined() const; - const Location &defLocation() const; - const Vector &pendingRefs() const; -private: - Location defLocation_; - Vector pendingRefs_; -}; - -inline -Boolean Id::defined() const -{ - return !defLocation_.origin().isNull(); -} - -inline -const Location &Id::defLocation() const -{ - return defLocation_; -} - -inline -const Vector &Id::pendingRefs() const -{ - return pendingRefs_; -} - -inline -void Id::addPendingRef(const Location &loc) -{ - pendingRefs_.push_back(loc); -} - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* not Id_INCLUDED */ diff --git a/cde/programs/nsgmls/IdentityCodingSystem.C b/cde/programs/nsgmls/IdentityCodingSystem.C deleted file mode 100644 index d69dd4f48..000000000 --- a/cde/programs/nsgmls/IdentityCodingSystem.C +++ /dev/null @@ -1,158 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: IdentityCodingSystem.C /main/1 1996/07/29 16:54:48 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#include "splib.h" -#include "IdentityCodingSystem.h" -#if defined(__linux__) || defined(CSRG_BASED) || defined(sun) -#include -#else -#include -#endif -#include - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -class IdentityDecoder : public Decoder { -public: - size_t decode(Char *to, const char *from, size_t fromLen, - const char **rest); - Boolean convertOffset(unsigned long &offset) const; -}; - -class IdentityEncoder : public Encoder { -public: - IdentityEncoder(); - ~IdentityEncoder(); - void output(Char *, size_t, streambuf *); - void output(const Char *, size_t, streambuf *); -private: - void allocBuf(size_t); - char *buf_; - size_t bufSize_; -}; - -IdentityCodingSystem::IdentityCodingSystem() -{ -} - -Decoder *IdentityCodingSystem::makeDecoder() const -{ - return new IdentityDecoder; -} - -Encoder *IdentityCodingSystem::makeEncoder() const -{ - return new IdentityEncoder; -} - -Boolean IdentityCodingSystem::isIdentity() const -{ - return 1; -} - -size_t IdentityDecoder::decode(Char *to, const char *from, size_t fromLen, - const char **rest) -{ - if (sizeof(Char) == sizeof(char) && from == (char *)to) { - *rest = from + fromLen; - return fromLen; - } - for (size_t n = fromLen; n > 0; n--) - *to++ = (unsigned char)*from++; // zero extend - *rest = from; - return fromLen; -} - -Boolean IdentityDecoder::convertOffset(unsigned long &) const -{ - return true; -} - -IdentityEncoder::IdentityEncoder() -: buf_(0), bufSize_(0) -{ -} - -IdentityEncoder::~IdentityEncoder() -{ - delete [] buf_; -} - -void IdentityEncoder::allocBuf(size_t n) -{ - if (bufSize_ < n) { - delete [] buf_; - buf_ = new char[bufSize_ = n]; - } -} - -// FIXME handle errors from streambuf::sputn - -void IdentityEncoder::output(Char *s, size_t n, streambuf *sb) -{ - char *p = (char *)s; - if (sizeof(Char) != sizeof(char)) { - size_t j = 0; - for (size_t i = 0; i < n; i++) { - if (s[i] > UCHAR_MAX) { - sb->sputn(p, j); - j = 0; - handleUnencodable(s[i], sb); - } - else - p[j++] = char(s[i]); - } - sb->sputn(p, j); - } - else - sb->sputn(p, n); -} - -void IdentityEncoder::output(const Char *s, size_t n, streambuf *sb) -{ - if (sizeof(Char) != sizeof(char)) { - allocBuf(n); - size_t j = 0; - for (size_t i = 0; i < n; i++) { - if (s[i] > UCHAR_MAX) { - sb->sputn(buf_, j); - j = 0; - handleUnencodable(s[i], sb); - } - else - buf_[j++] = char(s[i]); - } - sb->sputn(buf_, j); - } - else - sb->sputn((const char *)s, n); -} - -#ifdef SP_NAMESPACE -} -#endif diff --git a/cde/programs/nsgmls/IdentityCodingSystem.h b/cde/programs/nsgmls/IdentityCodingSystem.h deleted file mode 100644 index 378c09061..000000000 --- a/cde/programs/nsgmls/IdentityCodingSystem.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: IdentityCodingSystem.h /main/1 1996/07/29 16:54:59 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#ifndef IdentityCodingSystem_INCLUDED -#define IdentityCodingSystem_INCLUDED 1 - -#include "CodingSystem.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -class SP_API IdentityCodingSystem : public CodingSystem { -public: - IdentityCodingSystem(); - Decoder *makeDecoder() const; - Encoder *makeEncoder() const; - Boolean isIdentity() const; -}; - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* not IdentityCodingSystem_INCLUDED */ diff --git a/cde/programs/nsgmls/InputSource.C b/cde/programs/nsgmls/InputSource.C deleted file mode 100644 index fc6674f19..000000000 --- a/cde/programs/nsgmls/InputSource.C +++ /dev/null @@ -1,99 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: InputSource.C /main/1 1996/07/29 16:55:11 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#ifdef __GNUG__ -#pragma implementation -#endif -#include "splib.h" -#include "InputSource.h" -#include "MarkupScan.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -InputSource::InputSource(InputSourceOrigin *origin, const Char *start, - const Char *end) -: origin_(origin), start_(start), end_(end), cur_(start), accessError_(0), - startLocation_(origin, 0), multicode_(0), scanSuppress_(0), - scanSuppressSingle_(false), scanSuppressIndex_(0) -{ -} - -void InputSource::reset(const Char *start, - const Char *end) -{ - origin_ = origin_->copy(); - start_ = start; - end_ = end; - cur_ = start_; - startLocation_ = Location(origin_.pointer(), 0); - multicode_ = 0; - scanSuppress_ = 0; - markupScanTable_.clear(); -} - -InputSource::~InputSource() -{ -} - -void InputSource::advanceStartMulticode(const Char *to) -{ - while (start_ < to) { - switch (markupScanTable_[*start_]) { - case MarkupScan::normal: - break; - case MarkupScan::in: - scanSuppress_ = 0; - break; - case MarkupScan::out: - if (!scanSuppress()) { - scanSuppress_ = 1; - scanSuppressSingle_ = 0; - } - break; - case MarkupScan::suppress: - // what's the effect of MSSCHAR followed by MSSCHAR - if (!scanSuppress()) { - scanSuppress_ = 1; - scanSuppressSingle_ = 1; - scanSuppressIndex_ = startLocation_.index() + 1; - } - break; - } - start_++; - startLocation_ += 1; - } -} - -void InputSource::willNotRewind() -{ -} - - -#ifdef SP_NAMESPACE -} -#endif diff --git a/cde/programs/nsgmls/InputSource.h b/cde/programs/nsgmls/InputSource.h deleted file mode 100644 index ce9e5481c..000000000 --- a/cde/programs/nsgmls/InputSource.h +++ /dev/null @@ -1,299 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: InputSource.h /main/1 1996/07/29 16:55:17 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#ifndef InputSource_INCLUDED -#define InputSource_INCLUDED 1 -#ifdef __GNUG__ -#pragma interface -#endif - -#include "types.h" -#include "Link.h" -#include "Ptr.h" -#include "Location.h" -#include "XcharMap.h" -#include - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -class Messenger; -class NamedCharRef; - -class SP_API InputSource : public Link { -public: - enum { eE = -1 }; // end of entity signal - - virtual ~InputSource(); - Xchar get(Messenger &); - virtual void pushCharRef(Char ch, const NamedCharRef &) = 0; - const Location ¤tLocation() const; - const Char *currentTokenStart() const; - size_t currentTokenLength() const; - const Char *currentTokenEnd() const; - Index nextIndex() const; - // Discard all but the last character of the current token. - void discardInitial(); - void startToken(); - void startTokenNoMulticode(); - void endToken(size_t length); - Xchar tokenChar(Messenger &); - void ungetToken(); - void setMarkupScanTable(const XcharMap &); - Boolean scanSuppress() const; - void extendToBufferEnd(); - virtual void willNotRewind(); - virtual Boolean rewind(Messenger &) = 0; - Boolean accessError() const; -protected: - InputSource(InputSourceOrigin *origin, const Char *start, const Char *end); - void reset(const Char *start, const Char *end); - InputSourceOrigin *inputSourceOrigin(); - void noteCharRef(Index replacementIndex, const NamedCharRef &); - const Char *cur(); - const Char *start(); - const Char *end(); - Index startIndex(); - void changeBuffer(const Char *newBase, const Char *oldBase); - void advanceEnd(const Char *newEnd); - void moveLeft(); - void moveStart(const Char *newStart); - Char nextChar(); - void setAccessError(); -private: - InputSource(const InputSource &); // undefined - void operator=(const InputSource &); // undefined - virtual Xchar fill(Messenger &) = 0; - void advanceStart(const Char *to); - void advanceStartMulticode(const Char *to); - - const Char *cur_; - const Char *start_; - const Char *end_; - Location startLocation_; - Ptr origin_; - Boolean accessError_; - Boolean scanSuppress_; - Boolean scanSuppressSingle_; - Index scanSuppressIndex_; - Boolean multicode_; - XcharMap markupScanTable_; -}; - -inline -void InputSource::advanceStart(const Char *to) -{ - if (multicode_) - advanceStartMulticode(to); - else { - startLocation_ += to - start_; - start_ = to; - } -} - -inline -Xchar InputSource::get(Messenger &mgr) -{ - advanceStart(cur_); - return cur_ < end_ ? *cur_++ : fill(mgr); -} - -inline -void InputSource::startTokenNoMulticode() -{ - startLocation_ += cur_ - start_; - start_ = cur_; -} - -inline -void InputSource::startToken() -{ - advanceStart(cur_); -} - -inline -void InputSource::endToken(size_t length) -{ - cur_ = start_ + length; -} - -inline -Xchar InputSource::tokenChar(Messenger &mgr) -{ - return cur_ < end_ ? *cur_++ : fill(mgr); -} - -inline -void InputSource::extendToBufferEnd() -{ - cur_ = end_; -} - -inline -const Char *InputSource::cur() -{ - return cur_; -} - -inline -const Char *InputSource::start() -{ - return start_; -} - -inline -const Char *InputSource::end() -{ - return end_; -} - -inline -void InputSource::changeBuffer(const Char *newBase, const Char *oldBase) -{ - cur_ = newBase + (cur_ - oldBase); - start_ = newBase + (start_ - oldBase); - end_ = newBase + (end_ - oldBase); -} - -inline -void InputSource::moveStart(const Char *newStart) -{ - cur_ = newStart + (cur_ - start_); - end_ = newStart + (end_ - start_); - start_ = newStart; -} - -inline -void InputSource::advanceEnd(const Char *newEnd) -{ - end_ = newEnd; -} - -inline -Char InputSource::nextChar() -{ - return *cur_++; -} - -inline -Index InputSource::startIndex() -{ - return startLocation_.index(); -} - -inline -void InputSource::moveLeft() -{ - start_--; - cur_--; -} - -inline -void InputSource::noteCharRef(Index replacementIndex, const NamedCharRef &ref) -{ - origin_->noteCharRef(replacementIndex, ref); -} - -inline -const Location &InputSource::currentLocation() const -{ - return startLocation_; -} - -inline -const Char *InputSource::currentTokenStart() const -{ - return start_; -} - -inline -size_t InputSource::currentTokenLength() const -{ - return cur_ - start_; -} - -inline -Index InputSource::nextIndex() const -{ - return startLocation_.index() + (cur_ - start_); -} - -inline -const Char *InputSource::currentTokenEnd() const -{ - return cur_; -} - -inline -void InputSource::discardInitial() -{ - advanceStart(cur_ - 1); -} - -inline -void InputSource::ungetToken() -{ - cur_ = start_; -} - -inline -void InputSource::setMarkupScanTable(const XcharMap &table) -{ - markupScanTable_ = table; - multicode_ = 1; -} - -inline -Boolean InputSource::scanSuppress() const -{ - return scanSuppress_ && (!scanSuppressSingle_ - || startLocation_.index() == scanSuppressIndex_); -} - -inline -InputSourceOrigin *InputSource::inputSourceOrigin() -{ - return origin_.pointer(); -} - -inline -void InputSource::setAccessError() -{ - accessError_ = 1; -} - -inline -Boolean InputSource::accessError() const -{ - return accessError_; -} - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* not InputSource_INCLUDED */ diff --git a/cde/programs/nsgmls/InternalInputSource.C b/cde/programs/nsgmls/InternalInputSource.C deleted file mode 100644 index 15e20b2ab..000000000 --- a/cde/programs/nsgmls/InternalInputSource.C +++ /dev/null @@ -1,83 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: InternalInputSource.C /main/1 1996/07/29 16:55:23 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#ifdef __GNUG__ -#pragma implementation -#endif -#include "splib.h" -#include -#include "InternalInputSource.h" -#include "macros.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -InternalInputSource::InternalInputSource(const StringC &str, - InputSourceOrigin *origin) -: InputSource(origin, str.data(), str.data() + str.size()), buf_(0), - contents_(&str) -{ -} - -InternalInputSource::~InternalInputSource() -{ - if (buf_) - delete [] buf_; -} - -Xchar InternalInputSource::fill(Messenger &) -{ - return eE; -} - -void InternalInputSource::pushCharRef(Char c, const NamedCharRef &ref) -{ - ASSERT(cur() == start()); - noteCharRef(startIndex() + (cur() - start()), ref); - if (buf_ == 0) { - buf_ = new Char[end() - start() + 1]; - memcpy(buf_ + 1, cur(), (end() - start())*sizeof(Char)); - changeBuffer(buf_ + 1, cur()); - } - moveLeft(); - *(Char *)cur() = c; -} - -Boolean InternalInputSource::rewind(Messenger &) -{ - reset(contents_->data(), - contents_->data() + contents_->size()); - if (buf_) { - delete [] buf_; - buf_ = 0; - } - return 1; -} - -#ifdef SP_NAMESPACE -} -#endif diff --git a/cde/programs/nsgmls/InternalInputSource.h b/cde/programs/nsgmls/InternalInputSource.h deleted file mode 100644 index a5c6b6562..000000000 --- a/cde/programs/nsgmls/InternalInputSource.h +++ /dev/null @@ -1,68 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: InternalInputSource.h /main/1 1996/07/29 16:55:29 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#ifndef InternalInputSource_INCLUDED -#define InternalInputSource_INCLUDED 1 -#ifdef __GNUG__ -#pragma interface -#endif - -#include -#include "InputSource.h" -#include "Allocator.h" -#include "StringC.h" -#include "types.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -class InputSourceOrigin; -class Messenger; -class NamedCharRef; - -class InternalInputSource : public InputSource { -public: - void *operator new(size_t sz, Allocator &alloc) { return alloc.alloc(sz); } - void *operator new(size_t sz) { return Allocator::allocSimple(sz); } - void operator delete(void *p) { Allocator::free(p); } - InternalInputSource(const StringC &, InputSourceOrigin *); - Xchar fill(Messenger &); - void pushCharRef(Char ch, const NamedCharRef &); - Boolean rewind(Messenger &); - ~InternalInputSource(); -private: - InternalInputSource(const InternalInputSource &); // undefined - void operator=(const InternalInputSource &); // undefined - Char *buf_; - const StringC *contents_; -}; - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* not InternalInputSource_INCLUDED */ diff --git a/cde/programs/nsgmls/Link.C b/cde/programs/nsgmls/Link.C deleted file mode 100644 index e816e5713..000000000 --- a/cde/programs/nsgmls/Link.C +++ /dev/null @@ -1,40 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: Link.C /main/1 1996/07/29 16:55:34 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#include "splib.h" -#include "Link.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -Link::~Link() -{ -} - -#ifdef SP_NAMESPACE -} -#endif diff --git a/cde/programs/nsgmls/Link.h b/cde/programs/nsgmls/Link.h deleted file mode 100644 index f6440ddbc..000000000 --- a/cde/programs/nsgmls/Link.h +++ /dev/null @@ -1,65 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: Link.h /main/1 1996/07/29 16:55:39 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#ifndef Link_INCLUDED -#define Link_INCLUDED 1 - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -#ifndef SP_API -#define SP_API -#endif - -class SP_API Link { -public: - Link(); - Link(Link *); - virtual ~Link(); -private: - Link *next_; - -friend class IListBase; -friend class IListIterBase; -friend class IQueueBase; -}; - -inline -Link::Link() : next_(0) -{ -} - -inline -Link::Link(Link *next) : next_(next) -{ -} - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* not Link_INCLUDED */ diff --git a/cde/programs/nsgmls/LinkProcess.C b/cde/programs/nsgmls/LinkProcess.C deleted file mode 100644 index 866ca8b66..000000000 --- a/cde/programs/nsgmls/LinkProcess.C +++ /dev/null @@ -1,208 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: LinkProcess.C /main/1 1996/07/29 16:55:45 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#ifdef __GNUG__ -#pragma implementation -#endif -#include "splib.h" -#include "LinkProcess.h" -// ParserState is used for access to parser messages -#include "ParserState.h" -#include "MessageArg.h" -#include "ParserMessages.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -LinkProcess::LinkProcess() -{ -} - -void LinkProcess::init(const ConstPtr &lpd) -{ - lpd_ = lpd; - open_.clear(); - open_.insert(new LinkProcessOpenElement(lpd_->initialLinkSet())); -} - -Boolean LinkProcess::startElement(const ElementType *element, - const AttributeList &attributes, - const Location &location, - Messenger &mgr, - const AttributeList *&linkAttributes, - const ResultElementSpec *&resultElementSpec) -{ - if (lpd_.isNull()) { - linkAttributes = 0; - resultElementSpec = 0; - return 1; - } - const StringC *id = attributes.getId(); - if (id) { - const IdLinkRuleGroup *p = lpd_->lookupIdLink(*id); - if (p) { - size_t selected; - if (p->nLinkRules() > 1) { - linkAttributes_.resize(p->nLinkRules()); - for (size_t i = 0; i < linkAttributes_.size(); i++) - linkAttributes_[i] = &p->linkRule(i).attributes(); - if (!selectLinkRule(linkAttributes_, - location, - selected)) - return 0; - } - else - selected = 0; - const IdLinkRule &rule = p->linkRule(selected); - open_.insert(new LinkProcessOpenElement(open_.head()->current, - rule)); - linkAttributes = &rule.attributes(); - resultElementSpec = &rule.resultElementSpec(); - if (!rule.isAssociatedWith(element)) { - mgr.setNextLocation(location); - mgr.message(ParserMessages::idlinkElementType, - StringMessageArg(element->name()), - StringMessageArg(*id)); - } - return 1; - } - } - const LinkSet *currentLinkSet = open_.head()->current; - size_t nRules = currentLinkSet->nLinkRules(element); - if (nRules > 0) { - size_t selected; - if (nRules > 1) { - linkAttributes_.resize(nRules); - for (size_t i = 0; i < nRules; i++) - linkAttributes_[i] - = ¤tLinkSet->linkRule(element, i).attributes(); - if (!selectLinkRule(linkAttributes_, - location, - selected)) - return 0; - } - else - selected = 0; - const SourceLinkRule &rule = currentLinkSet->linkRule(element, selected); - open_.insert(new LinkProcessOpenElement(open_.head()->current, - rule)); - linkAttributes = &rule.attributes(); - resultElementSpec = &rule.resultElementSpec(); - return 1; - } - // FIXME construct attributes from attribute definition list - linkAttributes = 0; - resultElementSpec = 0; - open_.insert(new LinkProcessOpenElement(open_.head()->current)); - return 1; -} - - -void LinkProcess::endElement() -{ - if (lpd_.isNull()) - return; - LinkProcessOpenElement *top = open_.get(); - if (top->post) - open_.head()->current = top->post; - else if (top->postRestore) - open_.head()->current = open_.head()->restore; - delete top; -} - -void LinkProcess::uselink(const LinkSet *linkSet, - Boolean restore, - const Lpd *lpd) -{ - if (lpd_.isNull()) - return; - if (lpd != lpd_.pointer()) - return; - if (restore) - open_.head()->current = open_.head()->restore; - else if (linkSet) - open_.head()->current = linkSet; -} - -size_t LinkProcess::nImpliedLinkRules() const -{ - if (!open_.head()) - return 0; - return open_.head()->current->nImpliedLinkRules(); -} - -const ResultElementSpec &LinkProcess::impliedLinkRule(size_t i) const -{ - return open_.head()->current->impliedLinkRule(i); -} - -// Usually redefined by application. - -Boolean LinkProcess::selectLinkRule(const Vector &, - const Location &, - size_t &selected) -{ - selected = 0; - return 1; -} - -void LinkProcess::clear() -{ - open_.clear(); - lpd_.clear(); - linkAttributes_.clear(); -} - -void LinkProcess::swap(LinkProcess &to) -{ - open_.swap(to.open_); - lpd_.swap(to.lpd_); - linkAttributes_.swap(to.linkAttributes_); -} - -LinkProcessOpenElement::LinkProcessOpenElement(const LinkSet *cur, - const SourceLinkRule &rule) -{ - current = rule.uselink(); - if (!current) - current = cur; - restore = cur; - post = rule.postlink(); - postRestore = rule.postlinkRestore(); -} - -LinkProcessOpenElement::LinkProcessOpenElement(const LinkSet *cur) -{ - restore = current = cur; - post = 0; - postRestore = 0; -} - - -#ifdef SP_NAMESPACE -} -#endif diff --git a/cde/programs/nsgmls/LinkProcess.h b/cde/programs/nsgmls/LinkProcess.h deleted file mode 100644 index 39bba78c7..000000000 --- a/cde/programs/nsgmls/LinkProcess.h +++ /dev/null @@ -1,104 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: LinkProcess.h /main/1 1996/07/29 16:55:50 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#ifndef LinkProcess_INCLUDED -#define LinkProcess_INCLUDED 1 -#ifdef __GNUG__ -#pragma interface -#endif - -#include "Lpd.h" -#include "IList.h" -#include "Link.h" -#include "Vector.h" -#include "Vector.h" -#include "Ptr.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -class Messenger; - -struct SP_API LinkProcessOpenElement : public Link { - LinkProcessOpenElement(const LinkSet *current, const SourceLinkRule &); - LinkProcessOpenElement(const LinkSet *current); - const LinkSet *current; - const LinkSet *restore; - const LinkSet *post; - Boolean postRestore; -}; - -class SP_API LinkProcess { -public: - LinkProcess(); - void init(const ConstPtr &lpd); - Boolean startElement(const ElementType *, - const AttributeList &attributes, - const Location &location, - Messenger &, - const AttributeList *&linkAttributes, - const ResultElementSpec *&resultElementSpec); - void endElement(); - void uselink(const LinkSet *linkSet, - Boolean restore, - const Lpd *); - virtual Boolean selectLinkRule(const Vector &, - const Location &location, - size_t &selected); - size_t nImpliedLinkRules() const; - const ResultElementSpec &impliedLinkRule(size_t) const; - const StringC &name() const; - Boolean isExplicit() const; - void clear(); - void swap(LinkProcess &); -private: - LinkProcess(const LinkProcess &); // undefined - void operator=(const LinkProcess &); // undefined - - IList open_; - ConstPtr lpd_; - Vector > activeLpds_; - Vector linkAttributes_; -}; - -inline -const StringC &LinkProcess::name() const -{ - return lpd_->name(); -} - -inline -Boolean LinkProcess::isExplicit() const -{ - return lpd_->type() == Lpd::explicitLink; -} - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* not LinkProcess_INCLUDED */ diff --git a/cde/programs/nsgmls/List.C b/cde/programs/nsgmls/List.C deleted file mode 100644 index e0697f82b..000000000 --- a/cde/programs/nsgmls/List.C +++ /dev/null @@ -1,60 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: List.C /main/1 1996/07/29 16:55:54 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#ifndef List_DEF_INCLUDED -#define List_DEF_INCLUDED 1 - -#include "IListIter.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -template -void List::remove(const T &value) -{ - for (IListIter > iter(list_); !iter.done(); iter.next()) - if (iter.cur()->value == value) { - list_.remove(iter.cur()); - delete iter.cur(); - break; - } -} - -template -T List::get() -{ - ListItem *p = list_.get(); - T temp(p->value); - delete p; - return temp; -} - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* not List_DEF_INCLUDED */ diff --git a/cde/programs/nsgmls/List.h b/cde/programs/nsgmls/List.h deleted file mode 100644 index 14c4052bc..000000000 --- a/cde/programs/nsgmls/List.h +++ /dev/null @@ -1,72 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: List.h /main/2 1996/08/13 10:08:58 mgreess $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#ifndef List_INCLUDED -#define List_INCLUDED 1 - -#include "IList.h" -#include "Link.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -template -class ListItem : public Link { -public: - ListItem(const T &v) : value(v) { } - T value; -}; - -template class ListIter; - -template -class List { -public: - List() { } - void append(const T &item) { list_.append(new ListItem(item)); } - void insert(const T &item) { list_.insert(new ListItem(item)); } - const T &head() const { return list_.head()->value; } - void remove(const T &); - T get(); - int empty() { return list_.empty(); } - friend class ListIter; -private: - List(const List &) {} - void operator=(const List &) {} - - IList > list_; -}; - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* not List_INCLUDED */ - -#ifdef SP_DEFINE_TEMPLATES -#include "List.C" -#endif diff --git a/cde/programs/nsgmls/ListIter.h b/cde/programs/nsgmls/ListIter.h deleted file mode 100644 index a1543ffc4..000000000 --- a/cde/programs/nsgmls/ListIter.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: ListIter.h /main/1 1996/07/29 16:56:04 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#ifndef ListIter_INCLUDED -#define ListIter_INCLUDED 1 - -#include "List.h" -#include "IListIter.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -template -class ListIter { -public: - ListIter(const List &list) : iter_(list.list_) { } - const T &cur() { return iter_.cur()->value; } - int done() { return iter_.done(); } - void next() { iter_.next(); } -private: - IListIter > iter_; -}; - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* not ListIter_INCLUDED */ diff --git a/cde/programs/nsgmls/LiteralStorage.C b/cde/programs/nsgmls/LiteralStorage.C deleted file mode 100644 index d30518f7f..000000000 --- a/cde/programs/nsgmls/LiteralStorage.C +++ /dev/null @@ -1,153 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: LiteralStorage.C /main/1 1996/07/29 16:56:08 cde-hp $ */ -// Copyright (c) 1996 James Clark -// See the file COPYING for copying permission. - -#ifdef __GNUG__ -#pragma implementation -#endif - -#include "splib.h" -#include "LiteralStorage.h" -#include "CodingSystem.h" -#include - -#ifdef DECLARE_MEMMOVE -extern "C" { - void *memmove(void *, const void *, size_t); -} -#endif - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -class LiteralStorageObject : public StorageObject { -public: - LiteralStorageObject(const StringC &); - Boolean read(char *buf, size_t bufSize, Messenger &, size_t &nread); - Boolean rewind(Messenger &); -private: - LiteralStorageObject(const LiteralStorageObject &); // undefined - void operator=(const LiteralStorageObject &); // undefined - - StringC str_; - size_t nBytesRead_; -}; - -class MemoryInputCodingSystem : public InputCodingSystem { -public: - Decoder *makeDecoder() const; -}; - -class MemoryDecoder : public Decoder { -public: - MemoryDecoder(); - size_t decode(Char *, const char *, size_t, const char **); -}; - -LiteralStorageManager::LiteralStorageManager(const char *type) -: type_(type) -{ -} - -StorageObject *LiteralStorageManager::makeStorageObject(const StringC &id, - const StringC &, - Boolean, - Boolean, - Messenger &, - StringC &foundId) -{ - foundId = id; - return new LiteralStorageObject(id); -} - -const InputCodingSystem *LiteralStorageManager::requiredCodingSystem() const -{ - static MemoryInputCodingSystem cs; - return &cs; -} - -Boolean LiteralStorageManager::requiresCr() const -{ - return 1; -} - -const char *LiteralStorageManager::type() const -{ - return type_; -} - -Boolean LiteralStorageManager::inheritable() const -{ - return 0; -} - -LiteralStorageObject::LiteralStorageObject(const StringC &str) -: str_(str), nBytesRead_(0) -{ -} - -Boolean LiteralStorageObject::rewind(Messenger &) -{ - nBytesRead_ = 0; - return 1; -} - -Boolean LiteralStorageObject::read(char *buf, size_t bufSize, - Messenger &, size_t &nread) -{ - if (nBytesRead_ >= str_.size()*sizeof(Char)) - return 0; - nread = str_.size()*sizeof(Char) - nBytesRead_; - if (nread > bufSize) - nread = bufSize; - memcpy(buf, (char *)str_.data() + nBytesRead_, nread); - nBytesRead_ += nread; - return 1; -} - -Decoder *MemoryInputCodingSystem::makeDecoder() const -{ - return new MemoryDecoder; -} - -MemoryDecoder::MemoryDecoder() -: Decoder(sizeof(Char)) -{ -} - -size_t MemoryDecoder::decode(Char *to, const char *from, size_t fromLen, - const char **rest) -{ - size_t nChars = fromLen/sizeof(Char); - *rest = from + nChars*sizeof(Char); - if (from != (char *)to) - memmove(to, from, nChars*sizeof(Char)); - return nChars; -} - -#ifdef SP_NAMESPACE -} -#endif diff --git a/cde/programs/nsgmls/LiteralStorage.h b/cde/programs/nsgmls/LiteralStorage.h deleted file mode 100644 index 2cb0a31ca..000000000 --- a/cde/programs/nsgmls/LiteralStorage.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: LiteralStorage.h /main/1 1996/07/29 16:56:13 cde-hp $ */ -// Copyright (c) 1996 James Clark -// See the file COPYING for copying permission. - -#ifndef LiteralStorage_INCLUDED -#define LiteralStorage_INCLUDED 1 -#ifdef __GNUG__ -#pragma interface -#endif - -#include "StorageManager.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -class SP_API LiteralStorageManager : public StorageManager { -public: - LiteralStorageManager(const char *type); - StorageObject *makeStorageObject(const StringC &id, - const StringC &, - Boolean, - Boolean mayRewind, - Messenger &, - StringC &found); - const InputCodingSystem *requiredCodingSystem() const; - Boolean requiresCr() const; - const char *type() const; - Boolean inheritable() const; -private: - LiteralStorageManager(const LiteralStorageManager &); // undefined - void operator=(const LiteralStorageManager &); // undefined - - const char *type_; -}; - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* not LiteralStorage_INCLUDED */ diff --git a/cde/programs/nsgmls/Location.C b/cde/programs/nsgmls/Location.C deleted file mode 100644 index dbd6177c6..000000000 --- a/cde/programs/nsgmls/Location.C +++ /dev/null @@ -1,298 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: Location.C /main/1 1996/07/29 16:56:17 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#ifdef __GNUG__ -#pragma implementation -#endif -#include "splib.h" -#include "Location.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -Location::Location() -: index_(0) -{ -} - -Location::Location(Origin *origin, Index i) -: origin_(origin), index_(i) -{ -} - -Location::Location(ConstPtr origin, Index i) -: origin_(origin), index_(i) -{ -} - -Origin::~Origin() -{ -} - -const EntityOrigin *Origin::asEntityOrigin() const -{ - return 0; -} - -const InputSourceOrigin *Origin::asInputSourceOrigin() const -{ - return 0; -} - -Index Origin::refLength() const -{ - return 0; -} - -Boolean Origin::origChars(const Char *&) const -{ - return 0; -} - -Boolean Origin::inBracketedTextOpenDelim() const -{ - return 0; -} - -Boolean Origin::inBracketedTextCloseDelim() const -{ - return 0; -} - -Boolean Origin::isNumericCharRef(const Markup *&) const -{ - return 0; -} - -Boolean Origin::isNamedCharRef(Index, NamedCharRef &) const -{ - return 0; -} - -const EntityDecl *Origin::entityDecl() const -{ - return 0; -} - -BracketOrigin::BracketOrigin(const Location &loc, Position pos) -: loc_(loc), pos_(pos) -{ -} - -const Location &BracketOrigin::parent() const -{ - return loc_; -} - -Boolean BracketOrigin::inBracketedTextOpenDelim() const -{ - return pos_ == open; -} - -Boolean BracketOrigin::inBracketedTextCloseDelim() const -{ - return pos_ == close; -} - -InputSourceOrigin::InputSourceOrigin() -{ -} - -InputSourceOrigin::InputSourceOrigin(const Location &refLocation) -: refLocation_(refLocation) -{ -} - -const InputSourceOrigin *InputSourceOrigin::asInputSourceOrigin() const -{ - return this; -} - -Boolean InputSourceOrigin::defLocation(Offset, Location &) const -{ - return 0; -} - -const StringC *InputSourceOrigin::entityName() const -{ - return 0; -} - -InputSourceOrigin *InputSourceOrigin::copy() const -{ - return new InputSourceOrigin(refLocation_); -} - -const Location &InputSourceOrigin::parent() const -{ - return refLocation_; -} - -void InputSourceOrigin::setExternalInfo(ExternalInfo *info) -{ - externalInfo_ = info; -} - -void InputSourceOrigin::noteCharRef(Index replacementIndex, - const NamedCharRef &ref) -{ - charRefs_.resize(charRefs_.size() + 1); - charRefs_.back().replacementIndex = replacementIndex; - charRefs_.back().refStartIndex = ref.refStartIndex(); - charRefs_.back().refEndType = ref.refEndType(); - charRefs_.back().origNameOffset = charRefOrigNames_.size(); - charRefOrigNames_ += ref.origName(); -} - -// Number of character references whose replacement index < ind. - -size_t InputSourceOrigin::nPrecedingCharRefs(Index ind) const -{ - size_t i; - // Find i such that - // charRefs_[I].replacementIndex >= ind - // charRefs_[i - 1].replacementIndex < ind - if (charRefs_.size() == 0 - || ind > charRefs_.back().replacementIndex) - // This will be a common case, so optimize it. - i = charRefs_.size(); - else { - // Binary search - // Invariant: - // charRefs_ < i have replacementIndex < ind - // charRefs_ >= lim have replacementIndex >= ind - i = 0; - size_t lim = charRefs_.size(); - while (i < lim) { - size_t mid = i + (lim - i)/2; - if (charRefs_[mid].replacementIndex >= ind) - lim = mid; - else - i = mid + 1; - } - } - return i; -} - -Offset InputSourceOrigin::startOffset(Index ind) const -{ - size_t n = nPrecedingCharRefs(ind); - if (n < charRefs_.size() - && ind == charRefs_[n].replacementIndex) { - for (;;) { - ind = charRefs_[n].refStartIndex; - if (n == 0 || charRefs_[n - 1].replacementIndex != ind) - break; - --n; - } - } - // charRefs[n - 1].replacementIndex < ind - return Offset(ind - n); -} - -Boolean InputSourceOrigin::isNamedCharRef(Index ind, NamedCharRef &ref) const -{ - size_t n = nPrecedingCharRefs(ind); - if (n < charRefs_.size() && ind == charRefs_[n].replacementIndex) { - ref.set(charRefs_[n].refStartIndex, - charRefs_[n].refEndType, - charRefOrigNames_.data() + charRefs_[n].origNameOffset, - (n + 1 < charRefs_.size() - ? charRefs_[n + 1].origNameOffset - : charRefOrigNames_.size()) - - charRefs_[n].origNameOffset); - return 1; - } - return 0; -} - -ReplacementOrigin::ReplacementOrigin(const Location &loc, Char origChar) -: loc_(loc), origChar_(origChar) -{ -} - -const Location &ReplacementOrigin::parent() const -{ - return loc_; -} - -Boolean ReplacementOrigin::origChars(const Char *&s) const -{ - if (loc_.origin().isNull() || !loc_.origin()->origChars(s)) - s = &origChar_; - return 1; -} - -MultiReplacementOrigin::MultiReplacementOrigin(const Location &loc, - StringC &origChars) -: loc_(loc) -{ - origChars.swap(origChars_); -} - -const Location &MultiReplacementOrigin::parent() const -{ - return loc_; -} - -Boolean MultiReplacementOrigin::origChars(const Char *&s) const -{ - if (loc_.origin().isNull() || !loc_.origin()->origChars(s)) - s = origChars_.data(); - return 1; -} - -ExternalInfo::~ExternalInfo() -{ -} - -RTTI_DEF0(ExternalInfo) - -NamedCharRef::NamedCharRef() -: refStartIndex_(0), refEndType_(endOmitted) -{ -} - -NamedCharRef::NamedCharRef(Index refStartIndex, RefEndType refEndType, - const StringC &origName) -: refStartIndex_(refStartIndex), - refEndType_(refEndType), - origName_(origName) -{ -} - -void NamedCharRef::set(Index refStartIndex, RefEndType refEndType, - const Char *s, size_t n) -{ - refStartIndex_ = refStartIndex; - refEndType_ = refEndType; - origName_.assign(s, n); -} - -#ifdef SP_NAMESPACE -} -#endif diff --git a/cde/programs/nsgmls/Location.h b/cde/programs/nsgmls/Location.h deleted file mode 100644 index 139474e90..000000000 --- a/cde/programs/nsgmls/Location.h +++ /dev/null @@ -1,213 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: Location.h /main/1 1996/07/29 16:56:22 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#ifndef Location_INCLUDED -#define Location_INCLUDED 1 -#ifdef __GNUG__ -#pragma interface -#endif - -#include "types.h" -#include "Boolean.h" -#include "Ptr.h" -#include "Resource.h" -#include "Boolean.h" -#include "Vector.h" -#include "Owner.h" -#include "StringC.h" -#include "rtti.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -class ExternalInfo; -class EntityOrigin; -class InputSourceOrigin; -class Entity; -class EntityDecl; -class Location; -class Markup; -class Text; -class NamedCharRef; - -class SP_API Origin : public Resource { -public: - virtual ~Origin(); - virtual const EntityOrigin *asEntityOrigin() const; - virtual const InputSourceOrigin *asInputSourceOrigin() const; - virtual const Location &parent() const = 0; - virtual Index refLength() const; - virtual Boolean origChars(const Char *&) const; - virtual Boolean inBracketedTextOpenDelim() const; - virtual Boolean inBracketedTextCloseDelim() const; - virtual Boolean isNumericCharRef(const Markup *&markup) const; - virtual Boolean isNamedCharRef(Index ind, NamedCharRef &ref) const; - virtual const EntityDecl *entityDecl() const; -}; - -class SP_API Location { -public: - Location(); - Location(Origin *, Index); - Location(ConstPtr, Index); - void operator+=(Index i) { index_ += i; } - void operator-=(Index i) { index_ -= i; } - Index index() const { return index_; } - const ConstPtr &origin() const { return origin_; } - void clear() { origin_.clear(); } - void swap(Location &to) { - origin_.swap(to.origin_); - Index tem = to.index_; - to.index_ = index_; - index_ = tem; - } -private: - ConstPtr origin_; - Index index_; -}; - -class SP_API ExternalInfo { - RTTI_CLASS -public: - virtual ~ExternalInfo(); -}; - -class SP_API NamedCharRef { -public: - enum RefEndType { - endOmitted, - endRE, - endRefc - }; - NamedCharRef(); - NamedCharRef(Index, RefEndType, const StringC &); - Index refStartIndex() const; - RefEndType refEndType() const; - const StringC &origName() const; - void set(Index, RefEndType, const Char *, size_t); -private: - Index refStartIndex_; - RefEndType refEndType_; - StringC origName_; -}; - -struct SP_API InputSourceOriginNamedCharRef { - InputSourceOriginNamedCharRef() { } - ~InputSourceOriginNamedCharRef() { } - Index replacementIndex; - size_t origNameOffset; - Index refStartIndex; - NamedCharRef::RefEndType refEndType; -}; - -class SP_API InputSourceOrigin : public Origin { -public: - InputSourceOrigin(); - InputSourceOrigin(const Location &refLocation); - const Location &parent() const; - const ExternalInfo *externalInfo() const; - Offset startOffset(Index ind) const; - void noteCharRef(Index replacementIndex, const NamedCharRef &); - Boolean isNamedCharRef(Index ind, NamedCharRef &ref) const; - void setExternalInfo(ExternalInfo *); - virtual Boolean defLocation(Offset off, Location &) const; - virtual InputSourceOrigin *copy() const; - const InputSourceOrigin *asInputSourceOrigin() const; - virtual const StringC *entityName() const; -private: - InputSourceOrigin(const InputSourceOrigin &); // undefined - void operator=(const InputSourceOrigin &); // undefined - size_t nPrecedingCharRefs(Index ind) const; - Vector charRefs_; - StringC charRefOrigNames_; - Owner externalInfo_; // 0 for internal entities - Location refLocation_; // where referenced from -}; - -// a delimiter specified in bracketed text - -class SP_API BracketOrigin : public Origin { -public: - enum Position { open, close }; - BracketOrigin(const Location &, Position); - const Location &parent() const; - Boolean inBracketedTextOpenDelim() const; - Boolean inBracketedTextCloseDelim() const; -private: - Position pos_; - Location loc_; -}; - -class SP_API ReplacementOrigin : public Origin { -public: - ReplacementOrigin(const Location &, Char origChar); - const Location &parent() const; - Boolean origChars(const Char *&) const; -private: - Location loc_; - Char origChar_; -}; - -class SP_API MultiReplacementOrigin : public Origin { -public: - MultiReplacementOrigin(const Location &, StringC &origChars); - const Location &parent() const; - Boolean origChars(const Char *&) const; -private: - Location loc_; - StringC origChars_; -}; - -inline -Index NamedCharRef::refStartIndex() const -{ - return refStartIndex_; -} - -inline -NamedCharRef::RefEndType NamedCharRef::refEndType() const -{ - return refEndType_; -} - -inline -const StringC &NamedCharRef::origName() const -{ - return origName_; -} - -inline -const ExternalInfo *InputSourceOrigin::externalInfo() const -{ - return externalInfo_.pointer(); -} - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* not Location_INCLUDED */ diff --git a/cde/programs/nsgmls/Lpd.C b/cde/programs/nsgmls/Lpd.C deleted file mode 100644 index 9841c4f1d..000000000 --- a/cde/programs/nsgmls/Lpd.C +++ /dev/null @@ -1,199 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: Lpd.C /main/1 1996/07/29 16:56:26 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#ifdef __GNUG__ -#pragma implementation -#endif -#include "splib.h" -#include "Lpd.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -Lpd::Lpd(const StringC &name, Type type, const Location &location, - const Ptr &sourceDtd) -: name_(new StringResource(name)), type_(type), location_(location), - active_(0), sourceDtd_(sourceDtd) -{ -} - -Lpd::~Lpd() -{ -} - -SimpleLpd::SimpleLpd(const StringC &name, const Location &location, - const Ptr &sourceDtd) -: Lpd(name, simpleLink, location, sourceDtd) -{ -} - -ResultElementSpec::ResultElementSpec() -: elementType(0) -{ -} - -void ResultElementSpec::swap(ResultElementSpec &to) -{ - attributeList.swap(to.attributeList); - { - const ElementType *tem = to.elementType; - to.elementType = elementType; - elementType = tem; - } -} - -SourceLinkRule::SourceLinkRule() -: uselink_(0), postlink_(0), postlinkRestore_(0) -{ -} - -void SourceLinkRule::swap(SourceLinkRule &to) -{ - linkAttributes_.swap(to.linkAttributes_); - resultElementSpec_.swap(to.resultElementSpec_); - { - const LinkSet *tem = to.uselink_; - to.uselink_ = uselink_; - uselink_ = tem; - } - { - const LinkSet *tem = to.postlink_; - to.postlink_ = postlink_; - postlink_ = tem; - } - { - Boolean tem = to.postlinkRestore_; - to.postlinkRestore_ = postlinkRestore_; - postlinkRestore_ = tem; - } -} - -SourceLinkRuleResource::SourceLinkRuleResource() -{ -} - -LinkSet::LinkSet(const StringC &name, const Dtd *dtd) -: Named(name), defined_(0), linkRules_(dtd ? dtd->nElementTypeIndex() : 0) -{ -} - -void LinkSet::addLinkRule(const ElementType *element, - const ConstPtr &rule) -{ - linkRules_[element->index()].push_back(rule); -} - -void LinkSet::addImplied(const ElementType *element, AttributeList &attributes) -{ - impliedSourceLinkRules_.resize(impliedSourceLinkRules_.size() + 1); - ResultElementSpec &result = impliedSourceLinkRules_.back(); - result.elementType = element; - result.attributeList = attributes; -} - -Boolean LinkSet::impliedResultAttributes(const ElementType *resultType, - const AttributeList *&attributes) -{ - for (size_t i = 0; i < impliedSourceLinkRules_.size(); i++) - if (impliedSourceLinkRules_[i].elementType == resultType) { - attributes = &impliedSourceLinkRules_[i].attributeList; - return 1; - } - return 0; -} - -size_t LinkSet::nLinkRules(const ElementType *e) const -{ - if (e->index() >= linkRules_.size()) - return 0; - return linkRules_[e->index()].size(); -} - -IdLinkRule::IdLinkRule() -{ -} - -Boolean IdLinkRule::isAssociatedWith(const ElementType *e) const -{ - for (size_t i = 0; i < assocElementTypes_.size(); i++) - if (assocElementTypes_[i] == e) - return 1; - return 0; -} - -void IdLinkRule::setAssocElementTypes(Vector &v) -{ - v.swap(assocElementTypes_); -} - -void IdLinkRule::swap(IdLinkRule &to) -{ - SourceLinkRule::swap(to); - assocElementTypes_.swap(to.assocElementTypes_); -} - -IdLinkRuleGroup::IdLinkRuleGroup(const StringC &name) -: Named(name) -{ -} - -void IdLinkRuleGroup::addLinkRule(IdLinkRule &rule) -{ - linkRules_.resize(linkRules_.size() + 1); - rule.swap(linkRules_.back()); -} - -ComplexLpd::ComplexLpd(const StringC &name, Type type, - const Location &location, - const Syntax &syntax, - const Ptr &sourceDtd, - const Ptr &resultDtd) -: Lpd(name, type, location, sourceDtd), resultDtd_(resultDtd), - hadIdLinkSet_(0), nAttributeDefinitionList_(0), - initialLinkSet_(syntax.rniReservedName(Syntax::rINITIAL), - sourceDtd.pointer()), - emptyLinkSet_(syntax.rniReservedName(Syntax::rEMPTY), - sourceDtd.pointer()), - linkAttributeDefs_(sourceDtd.isNull() ? 0 : sourceDtd->nElementTypeIndex()) -{ -} - -IdLinkRuleGroup *ComplexLpd::lookupCreateIdLink(const StringC &id) -{ - IdLinkRuleGroup *group = idLinkTable_.lookup(id); - if (!group) { - group = new IdLinkRuleGroup(id); - idLinkTable_.insert(group); - } - return group; -} - - - -#ifdef SP_NAMESPACE -} -#endif diff --git a/cde/programs/nsgmls/Lpd.h b/cde/programs/nsgmls/Lpd.h deleted file mode 100644 index d73847f57..000000000 --- a/cde/programs/nsgmls/Lpd.h +++ /dev/null @@ -1,469 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: Lpd.h /main/1 1996/07/29 16:56:30 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#ifndef Lpd_INCLUDED -#define Lpd_INCLUDED 1 -#ifdef __GNUG__ -#pragma interface -#endif - -#include "Attribute.h" -#include "StringC.h" -#include "Ptr.h" -#include "Resource.h" -#include "Boolean.h" -#include "Named.h" -#include "NamedTable.h" -#include "Syntax.h" -#include "Location.h" -#include "Dtd.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -class ElementType; - -struct SP_API ResultElementSpec { - ResultElementSpec(); - const ElementType *elementType; - AttributeList attributeList; - void swap(ResultElementSpec &); -}; - -class SP_API Lpd : public Resource { -public: - enum Type { simpleLink, implicitLink, explicitLink }; - Lpd(const StringC &, Type, const Location &, - const Ptr &sourceDtd); - virtual ~Lpd(); - Type type() const; - const Location &location() const; - const Ptr &sourceDtd(); - ConstPtr sourceDtd() const; - Boolean active() const; - void activate(); - const ConstPtr > &namePointer() const; - const StringC &name() const; -private: - Lpd(const Lpd &); // undefined - void operator=(const Lpd &); // undefined - Type type_; - Location location_; - Boolean active_; - Ptr sourceDtd_; - ConstPtr > name_; -}; - -class SP_API SimpleLpd : public Lpd, public Attributed { -public: - SimpleLpd(const StringC &, const Location &, - const Ptr &sourceDtd); -private: - SimpleLpd(const SimpleLpd &); // undefined - void operator=(const SimpleLpd &); // undefined -}; - -class LinkSet; - -// A link rule whose source element specification is not implied. - -class SP_API SourceLinkRule { -public: - SourceLinkRule(); - void setLinkAttributes(AttributeList &); - void setResult(const ElementType *, AttributeList &); - void setUselink(const LinkSet *); - void setPostlink(const LinkSet *); - void setPostlinkRestore(); - void swap(SourceLinkRule &); - const AttributeList &attributes() const; - const ResultElementSpec &resultElementSpec() const; - const LinkSet *uselink() const; - const LinkSet *postlink() const; - Boolean postlinkRestore() const; -private: - const LinkSet *uselink_; - const LinkSet *postlink_; - Boolean postlinkRestore_; - AttributeList linkAttributes_; - ResultElementSpec resultElementSpec_; -}; - -class SP_API SourceLinkRuleResource : public Resource, public SourceLinkRule { -public: - SourceLinkRuleResource(); -}; - -class SP_API LinkSet : public Named { -public: - LinkSet(const StringC &, const Dtd *); - void setDefined(); - Boolean defined() const; - void addImplied(const ElementType *, AttributeList &); - size_t nLinkRules(const ElementType *) const; - const SourceLinkRule &linkRule(const ElementType *, size_t) const; - void addLinkRule(const ElementType *, - const ConstPtr &); - size_t nImpliedLinkRules() const; - const ResultElementSpec &impliedLinkRule(size_t) const; - Boolean impliedResultAttributes(const ElementType *, - const AttributeList *&); -private: - LinkSet(const LinkSet &); // undefined - void operator=(const LinkSet &); // undefined - Boolean defined_; - // indexed by typeIndex of source elements - Vector > > - linkRules_; - Vector impliedSourceLinkRules_; -}; - -class SP_API IdLinkRule : public SourceLinkRule { -public: - IdLinkRule(); - Boolean isAssociatedWith(const ElementType *) const; - void setAssocElementTypes(Vector &); - void swap(IdLinkRule &); -private: - Vector assocElementTypes_; -}; - -// A collection of link rules in a ID link set that are -// assocated with the same name (unique identifier). - -class SP_API IdLinkRuleGroup : public Named { -public: - IdLinkRuleGroup(const StringC &); - size_t nLinkRules() const; - const IdLinkRule &linkRule(size_t) const; - void addLinkRule(IdLinkRule &); -private: - IdLinkRuleGroup(const IdLinkRuleGroup &); // undefined - void operator=(const IdLinkRuleGroup &); // undefined - Vector linkRules_; -}; - -// An implicit or explicit LPD. - -class SP_API ComplexLpd : public Lpd { -public: - typedef ConstNamedTableIter ConstLinkSetIter; - ComplexLpd(const StringC &, Type, - const Location &, - const Syntax &syntax, - const Ptr &sourceDtd, - const Ptr &resultDtd); - size_t allocAttributeDefinitionListIndex(); - size_t nAttributeDefinitionList() const; - LinkSet *initialLinkSet(); - const LinkSet *initialLinkSet() const; - const LinkSet *emptyLinkSet() const; - const LinkSet *lookupLinkSet(const StringC &) const; - const IdLinkRuleGroup *lookupIdLink(const StringC &) const; - IdLinkRuleGroup *lookupCreateIdLink(const StringC &); - void insertIdLink(IdLinkRuleGroup *); - ConstLinkSetIter linkSetIter() const; - Boolean hadIdLinkSet() const; - void setHadIdLinkSet(); - - LinkSet *lookupLinkSet(const StringC &); - LinkSet *insertLinkSet(LinkSet *); - const Ptr &resultDtd(); - ConstPtr resultDtd() const; - const ConstPtr & - attributeDef(const ElementType *) const; - void setAttributeDef(const ElementType *, - const ConstPtr &); -private: - ComplexLpd(const ComplexLpd &); // undefined - void operator=(const ComplexLpd &); // undefined - Ptr resultDtd_; - Vector > linkAttributeDefs_; - NamedTable linkSetTable_; - LinkSet initialLinkSet_; - LinkSet emptyLinkSet_; - Boolean hadIdLinkSet_; - NamedTable idLinkTable_; - size_t nAttributeDefinitionList_; -}; - -inline -Lpd::Type Lpd::type() const -{ - return type_; -} - -inline -const Location &Lpd::location() const -{ - return location_; -} - -inline -Boolean Lpd::active() const -{ - return active_; -} - -inline -void Lpd::activate() -{ - active_ = 1; -} - -inline -ConstPtr Lpd::sourceDtd() const -{ - return sourceDtd_; -} - -inline -const Ptr &Lpd::sourceDtd() -{ - return sourceDtd_; -} - -inline -const ConstPtr > &Lpd::namePointer() const -{ - return name_; -} - -inline -const StringC &Lpd::name() const -{ - return *name_; -} - -inline -void SourceLinkRule::setLinkAttributes(AttributeList &attributes) -{ - attributes.swap(linkAttributes_); -} - -inline -const AttributeList &SourceLinkRule::attributes() const -{ - return linkAttributes_; -} - -inline -void SourceLinkRule::setResult(const ElementType *element, - AttributeList &attributes) -{ - resultElementSpec_.elementType = element; - attributes.swap(resultElementSpec_.attributeList); -} - -inline -const ResultElementSpec &SourceLinkRule::resultElementSpec() const -{ - return resultElementSpec_; -} - -inline -void SourceLinkRule::setUselink(const LinkSet *linkSet) -{ - uselink_ = linkSet; -} - -inline -void SourceLinkRule::setPostlink(const LinkSet *linkSet) -{ - postlink_ = linkSet; -} - -inline -void SourceLinkRule::setPostlinkRestore() -{ - postlinkRestore_ = 1; -} - -inline -const LinkSet *SourceLinkRule::uselink() const -{ - return uselink_; -} - -inline -const LinkSet *SourceLinkRule::postlink() const -{ - return postlink_; -} - -inline -Boolean SourceLinkRule::postlinkRestore() const -{ - return postlinkRestore_; -} - -inline -Boolean LinkSet::defined() const -{ - return defined_; -} - -inline -void LinkSet::setDefined() -{ - defined_ = 1; -} - -inline -const SourceLinkRule &LinkSet::linkRule(const ElementType *e, size_t i) const -{ - return *linkRules_[e->index()][i]; -} - -inline -size_t LinkSet::nImpliedLinkRules() const -{ - return impliedSourceLinkRules_.size(); -} - -inline -const ResultElementSpec &LinkSet::impliedLinkRule(size_t i) const -{ - return impliedSourceLinkRules_[i]; -} - -inline -const Ptr &ComplexLpd::resultDtd() -{ - return resultDtd_; -} - -inline -ConstPtr ComplexLpd::resultDtd() const -{ - return resultDtd_; -} - -inline -LinkSet *ComplexLpd::initialLinkSet() -{ - return &initialLinkSet_; -} - -inline -const LinkSet *ComplexLpd::initialLinkSet() const -{ - return &initialLinkSet_; -} - -inline -const LinkSet *ComplexLpd::emptyLinkSet() const -{ - return &emptyLinkSet_; -} - -inline -const LinkSet *ComplexLpd::lookupLinkSet(const StringC &name) const -{ - return linkSetTable_.lookup(name); -} - -inline -LinkSet *ComplexLpd::lookupLinkSet(const StringC &name) -{ - return linkSetTable_.lookup(name); -} - -inline -LinkSet *ComplexLpd::insertLinkSet(LinkSet *e) -{ - return linkSetTable_.insert(e); -} - -inline -size_t ComplexLpd::nAttributeDefinitionList() const -{ - return nAttributeDefinitionList_; -} - -inline -size_t ComplexLpd::allocAttributeDefinitionListIndex() -{ - return nAttributeDefinitionList_++; -} - -inline -ComplexLpd::ConstLinkSetIter ComplexLpd::linkSetIter() const -{ - // Avoid use of typedef to work around MSVC 2.0 bug. - return ConstNamedTableIter(linkSetTable_); -} - -inline -const ConstPtr & -ComplexLpd::attributeDef(const ElementType *e) const -{ - return linkAttributeDefs_[e->index()]; -} - -inline -void ComplexLpd::setAttributeDef(const ElementType *e, - const ConstPtr &attdef) -{ - linkAttributeDefs_[e->index()] = attdef; -} - -inline -Boolean ComplexLpd::hadIdLinkSet() const -{ - return hadIdLinkSet_; -} - -inline -void ComplexLpd::setHadIdLinkSet() -{ - hadIdLinkSet_ = 1; -} - -inline -const IdLinkRuleGroup *ComplexLpd::lookupIdLink(const StringC &id) const -{ - return idLinkTable_.lookup(id); -} - -inline -size_t IdLinkRuleGroup::nLinkRules() const -{ - return linkRules_.size(); -} - -inline -const IdLinkRule &IdLinkRuleGroup::linkRule(size_t i) const -{ - return linkRules_[i]; -} - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* not Lpd_INCLUDED */ diff --git a/cde/programs/nsgmls/LpdEntityRef.h b/cde/programs/nsgmls/LpdEntityRef.h deleted file mode 100644 index c760edc73..000000000 --- a/cde/programs/nsgmls/LpdEntityRef.h +++ /dev/null @@ -1,69 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: LpdEntityRef.h /main/1 1996/07/29 16:56:34 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#ifndef LpdEntityRef_INCLUDED -#define LpdEntityRef_INCLUDED 1 - -#include "Entity.h" -#include "Boolean.h" -#include "Ptr.h" - -// Information about a reference to an entity that -// used a definition in an LPD. - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -struct LpdEntityRef { - ConstPtr entity; - PackedBoolean lookedAtDefault; - PackedBoolean foundInPass1Dtd; - static inline const LpdEntityRef &key(const LpdEntityRef &r) { return r; } - static inline unsigned long hash(const LpdEntityRef &r) { - return Hash::hash(r.entity->name()); - } -}; - -inline -Boolean operator==(const LpdEntityRef &r1, const LpdEntityRef &r2) -{ - return (r1.entity == r2.entity - && r1.foundInPass1Dtd == r2.foundInPass1Dtd - && r1.lookedAtDefault == r2.lookedAtDefault); -} - -inline -Boolean operator!=(const LpdEntityRef &r1, const LpdEntityRef &r2) -{ - return !(r1 == r2); -} - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* not LpdEntityRef_INCLUDED */ diff --git a/cde/programs/nsgmls/Makefile.am b/cde/programs/nsgmls/Makefile.am deleted file mode 100644 index fc23c2f12..000000000 --- a/cde/programs/nsgmls/Makefile.am +++ /dev/null @@ -1,142 +0,0 @@ -CLEANFILES = $(GENERATED_SRCS) - -bin_PROGRAMS = nsgmls - -if LINUX -nsgmls_CXXFLAGS = -DSP_VOLATILE=volatile -DSP_CONST=const -DSP_ANSI_CLASS_INST \ - -DSP_HAVE_LOCALE -DSP_MULTI_BYTE -DSP_MANUAL_INST \ - -fno-implicit-templates -endif - -if BSD -nsgmls_CXXFLAGS = -DSP_VOLATILE=volatile -DSP_CONST=const -DSP_ANSI_CLASS_INST \ - -DSP_HAVE_LOCALE -DSP_MULTI_BYTE -DSP_MANUAL_INST -endif - -if SOLARIS -nsgmls_CXXFLAGS = -DSP_VOLATILE= -DSP_CONST= -DSP_HAVE_LOCALE \ - -DSP_MULTI_BYTE -DSP_ANSI_CLASS_INST -endif - -if HPUX -nsgmls_CXXFLAGS = +a1 -z +T -DSP_VOLATILE= -DSP_CONST= -DSP_HAVE_LOCALE \ - -DSP_MULTI_BYTE -DSP_ANSI_CLASS_INST -I/opt/CC/include/CC -endif - -if AIX -nsgmls_CXXFLAGS = -DSP_VOLATILE=volatile -DSP_CONST=const \ - -DSP_HAVE_LOCALE -DSP_MULTI_BYTE -DSP_MANUAL_INST -endif - -SUFFIXES: .m4 -.m4.C: - rm -f $@ - $(M4) instmac.m4 $< >$@ - -GENERATED_SRCS = app_inst.C \ - arc_inst.C \ - entmgr_inst.C \ - nsgmls_inst.C \ - parser_inst.C \ - xentmgr_inst.C - -nsgmls_SOURCES = Allocator.C \ - ArcEngine.C \ - Attribute.C \ - CharsetDecl.C \ - CharsetInfo.C \ - CharsetRegistry.C \ - CmdLineApp.C \ - CodingSystem.C \ - ConsoleOutput.C \ - ContentState.C \ - ContentToken.C \ - DescriptorManager.C \ - Dtd.C \ - EUCJPCodingSystem.C \ - ElementType.C \ - Entity.C \ - EntityApp.C \ - EntityCatalog.C \ - EntityDecl.C \ - EntityManager.C \ - ErrnoMessageArg.C \ - ErrorCountEventHandler.C \ - Event.C \ - EventGenerator.C \ - ExtendEntityManager.C \ - ExternalId.C \ - Fixed2CodingSystem.C \ - GenericEventHandler.C \ - Group.C \ - Hash.C \ - IListBase.C \ - ISO8859InputCodingSystem.C \ - Id.C \ - IdentityCodingSystem.C \ - InputSource.C \ - InternalInputSource.C \ - Link.C \ - LinkProcess.C \ - LiteralStorage.C \ - Location.C \ - Lpd.C \ - Markup.C \ - Message.C \ - MessageArg.C \ - MessageEventHandler.C \ - MessageReporter.C \ - MessageTable.C \ - ModeInfo.C \ - Notation.C \ - NumericCharRefOrigin.C \ - OffsetOrderedList.C \ - OpenElement.C \ - OutputCharStream.C \ - OutputState.C \ - Parser.C \ - Param.C \ - ParserApp.C \ - ParserEventGeneratorKit.C \ - ParserOptions.C \ - ParserState.C \ - Partition.C \ - PosixStorage.C \ - RastEventHandler.C \ - Recognizer.C \ - RewindStorageObject.C \ - SGMLApplication.C \ - SJISCodingSystem.C \ - SOEntityCatalog.C \ - Sd.C \ - SdText.C \ - SearchResultMessageArg.C \ - SgmlParser.C \ - SgmlsEventHandler.C \ - ShortReferenceMap.C \ - StdioStorage.C \ - StorageManager.C \ - StringSet.C \ - StringVectorMessageArg.C \ - Syntax.C \ - Text.C \ - TokenMessageArg.C \ - TranslateInputCodingSystem.C \ - TrieBuilder.C \ - TypeId.C \ - URLStorage.C \ - UTF8CodingSystem.C \ - Undo.C \ - UnicodeCodingSystem.C \ - UnivCharsetDesc.C \ - assert.C \ - nsgmls.C \ - parseAttribute.C \ - parseCommon.C \ - parseDecl.C \ - parseInstance.C \ - parseMode.C \ - parseParam.C \ - parseSd.C \ - splib.C \ - $(GENERATED_SRCS) diff --git a/cde/programs/nsgmls/Markup.C b/cde/programs/nsgmls/Markup.C deleted file mode 100644 index 7ad3c601f..000000000 --- a/cde/programs/nsgmls/Markup.C +++ /dev/null @@ -1,438 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: Markup.C /main/1 1996/07/29 16:56:39 cde-hp $ */ -// Copyright (c) 1995 James Clark -// See the file COPYING for copying permission. - -#ifdef __GNUG__ -#pragma implementation -#endif - -#include "splib.h" -#include "Markup.h" -#include "InputSource.h" -#include "Location.h" -#include "macros.h" -#include "Entity.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -MarkupItem::MarkupItem() -: type(Markup::delimiter), index(0) -{ -} - -MarkupItem::~MarkupItem() -{ - switch (type) { - case Markup::entityStart: - delete origin; - break; - case Markup::literal: - delete text; - break; - case Markup::sdLiteral: - delete sdText; - break; - } -} - -MarkupItem::MarkupItem(const MarkupItem &item) -: type(item.type), index(item.index) -{ - switch (item.type) { - case Markup::entityStart: - origin = new ConstPtr(*item.origin); - break; - case Markup::literal: - text = new Text(*item.text); - break; - case Markup::sdLiteral: - sdText = new SdText(*item.sdText); - break; - case Markup::delimiter: - break; - default: - nChars = item.nChars; - break; - } -} - -void MarkupItem::operator=(const MarkupItem &item) -{ - switch (type) { - case Markup::entityStart: - if (item.type == Markup::entityStart) { - *origin = *item.origin; - return; - } - delete origin; - break; - case Markup::literal: - if (item.type == Markup::literal) { - *text = *item.text; - return; - } - delete text; - break; - case Markup::sdLiteral: - if (item.type == Markup::sdLiteral) { - *sdText = *item.sdText; - return; - } - delete sdText; - break; - } - type = item.type; - index = item.index; - switch (item.type) { - case Markup::entityStart: - origin = new ConstPtr(*item.origin); - break; - case Markup::literal: - text = new Text(*item.text); - break; - case Markup::sdLiteral: - sdText = new SdText(*item.sdText); - break; - case Markup::delimiter: - break; - default: - nChars = item.nChars; - break; - } -} - -Markup::Markup() -{ -} - -void Markup::resize(size_t n) -{ - size_t chopChars = 0; - for (size_t i = n; i < items_.size(); i++) - switch (items_[i].type) { - case Markup::reservedName: - case Markup::sdReservedName: - case Markup::name: - case Markup::nameToken: - case Markup::number: - case Markup::attributeValue: - case Markup::s: - case Markup::comment: - case Markup::shortref: - chopChars += items_[i].nChars; - break; - } - items_.resize(n); - chars_.resize(chars_.size() - chopChars); -} - -void Markup::addDelim(Syntax::DelimGeneral d) -{ - items_.resize(items_.size() + 1); - MarkupItem &item = items_.back(); - item.type = Markup::delimiter; - item.index = d; -} - -void Markup::addReservedName(Syntax::ReservedName rn, const InputSource *in) -{ - items_.resize(items_.size() + 1); - MarkupItem &item = items_.back(); - size_t length = in->currentTokenLength(); - item.nChars = length; - item.type = Markup::reservedName; - item.index = rn; - chars_.append(in->currentTokenStart(), length); -} - -void Markup::addReservedName(Syntax::ReservedName rn, const StringC &str) -{ - items_.resize(items_.size() + 1); - MarkupItem &item = items_.back(); - item.nChars = str.size(); - item.type = Markup::reservedName; - item.index = rn; - chars_.append(str.data(), str.size()); -} - -void Markup::addSdReservedName(Sd::ReservedName rn, const InputSource *in) -{ - items_.resize(items_.size() + 1); - MarkupItem &item = items_.back(); - size_t length = in->currentTokenLength(); - item.nChars = length; - item.type = Markup::sdReservedName; - item.index = rn; - chars_.append(in->currentTokenStart(), length); -} - -void Markup::addSdReservedName(Sd::ReservedName rn, - const Char *str, size_t length) -{ - items_.resize(items_.size() + 1); - MarkupItem &item = items_.back(); - item.nChars = length; - item.type = Markup::sdReservedName; - item.index = rn; - chars_.append(str, length); -} - -void Markup::addS(Char c) -{ - if (items_.size() > 0) { - MarkupItem &item = items_.back(); - if (item.type == Markup::s) { - item.nChars += 1; - chars_ += c; - return; - } - } - items_.resize(items_.size() + 1); - MarkupItem &item = items_.back(); - item.type = Markup::s; - item.nChars = 1; - chars_ += c; -} - -void Markup::addS(const InputSource *in) -{ - items_.resize(items_.size() + 1); - MarkupItem &item = items_.back(); - size_t length = in->currentTokenLength(); - item.nChars = length; - item.type = Markup::s; - chars_.append(in->currentTokenStart(), length); -} - -void Markup::addCommentStart() -{ - items_.resize(items_.size() + 1); - MarkupItem &item = items_.back(); - item.type = Markup::comment; - item.nChars = 0; -} - -void Markup::addRefEndRe() -{ - items_.resize(items_.size() + 1); - MarkupItem &item = items_.back(); - item.type = Markup::refEndRe; -} - -void Markup::addCommentChar(Char c) -{ - items_.back().nChars += 1; - chars_ += c; -} - -void Markup::addName(const InputSource *in) -{ - items_.resize(items_.size() + 1); - MarkupItem &item = items_.back(); - size_t length = in->currentTokenLength(); - item.nChars = length; - item.type = Markup::name; - chars_.append(in->currentTokenStart(), length); -} - -void Markup::addName(const Char *str, size_t length) -{ - items_.resize(items_.size() + 1); - MarkupItem &item = items_.back(); - item.nChars = length; - item.type = Markup::name; - chars_.append(str, length); -} - -void Markup::addNumber(const InputSource *in) -{ - items_.resize(items_.size() + 1); - MarkupItem &item = items_.back(); - size_t length = in->currentTokenLength(); - item.nChars = length; - item.type = Markup::number; - chars_.append(in->currentTokenStart(), length); -} - -void Markup::addNameToken(const InputSource *in) -{ - items_.resize(items_.size() + 1); - MarkupItem &item = items_.back(); - size_t length = in->currentTokenLength(); - item.nChars = length; - item.type = Markup::nameToken; - chars_.append(in->currentTokenStart(), length); -} - -void Markup::addAttributeValue(const InputSource *in) -{ - items_.resize(items_.size() + 1); - MarkupItem &item = items_.back(); - size_t length = in->currentTokenLength(); - item.nChars = length; - item.type = Markup::attributeValue; - chars_.append(in->currentTokenStart(), length); -} - -void Markup::addShortref(const InputSource *in) -{ - items_.resize(items_.size() + 1); - MarkupItem &item = items_.back(); - size_t length = in->currentTokenLength(); - item.nChars = length; - item.type = Markup::shortref; - chars_.append(in->currentTokenStart(), length); -} - -void Markup::addEntityStart(const Ptr &origin) -{ - items_.resize(items_.size() + 1); - MarkupItem &item = items_.back(); - item.type = Markup::entityStart; - item.origin = new ConstPtr(origin.pointer()); -} - -void Markup::addEntityEnd() -{ - items_.resize(items_.size() + 1); - items_.back().type = Markup::entityEnd; -} - -void Markup::addLiteral(const Text &text) -{ - items_.resize(items_.size() + 1); - MarkupItem &item = items_.back(); - item.type = Markup::literal; - item.text = new Text(text); -} - -void Markup::addSdLiteral(const SdText &sdText) -{ - items_.resize(items_.size() + 1); - MarkupItem &item = items_.back(); - item.type = Markup::sdLiteral; - item.sdText = new SdText(sdText); -} - -void Markup::changeToAttributeValue(size_t i) -{ - ASSERT(items_[i].type == Markup::name); - items_[i].type = Markup::attributeValue; -} - -void Markup::swap(Markup &to) -{ - chars_.swap(to.chars_); - items_.swap(to.items_); -} - -MarkupIter::MarkupIter(const Markup &m) -: chars_(m.chars_.data()), - items_(m.items_.begin()), - nItems_(m.items_.size()), - index_(0), - charIndex_(0) -{ -} - -void MarkupIter::advance(Location &loc, - const ConstPtr &syntax) -{ - switch (items_[index_].type) { - case Markup::delimiter: - loc += syntax->delimGeneral(delimGeneral()).size(); - break; - case Markup::refEndRe: - loc += 1; - break; - case Markup::reservedName: - case Markup::sdReservedName: - case Markup::name: - case Markup::nameToken: - case Markup::number: - case Markup::attributeValue: - case Markup::s: - case Markup::shortref: - loc += items_[index_].nChars; - charIndex_ += items_[index_].nChars; - break; - case Markup::comment: - loc += items_[index_].nChars + (2 * syntax->delimGeneral(Syntax::dCOM).size()); - charIndex_ += items_[index_].nChars; - break; - case Markup::entityStart: - loc = Location(*items_[index_].origin, 0); - break; - case Markup::entityEnd: - { - ConstPtr origin(loc.origin()); - loc = origin->parent(); - loc += origin->refLength(); - } - break; - case Markup::literal: - { - const Text &text = *items_[index_].text; - text.endDelimLocation(loc); - Boolean lita; - text.delimType(lita); - loc - += syntax->delimGeneral(lita ? Syntax::dLITA : Syntax::dLIT).size(); - } - break; - case Markup::sdLiteral: - { - const SdText &text = *items_[index_].sdText; - loc = text.endDelimLocation(); - loc += 1; - } - break; - } - index_++; -} - -void MarkupIter::advance() -{ - switch (items_[index_].type) { - case Markup::reservedName: - case Markup::sdReservedName: - case Markup::name: - case Markup::nameToken: - case Markup::number: - case Markup::attributeValue: - case Markup::s: - case Markup::comment: - case Markup::shortref: - charIndex_ += items_[index_].nChars; - break; - } - index_++; -} - -#ifdef SP_NAMESPACE -} -#endif diff --git a/cde/programs/nsgmls/Markup.h b/cde/programs/nsgmls/Markup.h deleted file mode 100644 index b2f14dde8..000000000 --- a/cde/programs/nsgmls/Markup.h +++ /dev/null @@ -1,225 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: Markup.h /main/1 1996/07/29 16:56:43 cde-hp $ */ -// Copyright (c) 1995 James Clark -// See the file COPYING for copying permission. - -#ifndef Markup_INCLUDED -#define Markup_INCLUDED 1 - -#ifdef __GNUG__ -#pragma interface -#endif - -#include "StringC.h" -#include "Syntax.h" -#include "Sd.h" -#include "Vector.h" -#include "Text.h" -#include "SdText.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -class EntityOrigin; - -struct SP_API MarkupItem { - MarkupItem(); - MarkupItem(const MarkupItem &); - ~MarkupItem(); - void operator=(const MarkupItem &); - unsigned char type; - unsigned char index; - union { - size_t nChars; - ConstPtr *origin; // type == entityStart - Text *text; // type == literal - SdText *sdText; // type == sdLiteral - }; -}; - -class InputSource; - -class SP_API Markup { -public: - enum Type { - reservedName, - sdReservedName, - name, - nameToken, - attributeValue, - number, - comment, - s, - shortref, - delimiter, - refEndRe, - entityStart, - entityEnd, - literal, - sdLiteral - }; - Markup(); - size_t size() const; - void clear(); - void resize(size_t); - void addDelim(Syntax::DelimGeneral); - void addReservedName(Syntax::ReservedName, const InputSource *); - void addReservedName(Syntax::ReservedName, const StringC &); - void addSdReservedName(Sd::ReservedName, const InputSource *); - void addSdReservedName(Sd::ReservedName, const Char *, size_t); - void addS(Char); - void addS(const InputSource *); - void addRefEndRe(); - void addShortref(const InputSource *); - void addCommentStart(); - void addCommentChar(Char); - void addName(const InputSource *); - void addName(const Char *, size_t); - void addNameToken(const InputSource *); - void addNumber(const InputSource *); - void addAttributeValue(const InputSource *); - void addEntityStart(const Ptr &); - void addEntityEnd(); - void addLiteral(const Text &); - void addSdLiteral(const SdText &); - void changeToAttributeValue(size_t index); - void swap(Markup &); -private: - StringC chars_; - Vector items_; - friend class MarkupIter; -}; - -class Location; - -class SP_API MarkupIter { -public: - MarkupIter(const Markup &); - Markup::Type type() const; - Boolean valid() const; - void advance(); - // This updates a Location. - void advance(Location &, const ConstPtr &); - size_t index() const; - const Char *charsPointer() const; - size_t charsLength() const; - const Text &text() const; - const EntityOrigin *entityOrigin() const; // valid for type == entityStart - const SdText &sdText() const; - Syntax::DelimGeneral delimGeneral() const; - Syntax::ReservedName reservedName() const; - Sd::ReservedName sdReservedName() const; -private: - const Char *chars_; - Vector::const_iterator items_; - size_t nItems_; - size_t index_; - size_t charIndex_; -}; - -inline -void Markup::clear() -{ - chars_.resize(0); - items_.resize(0); -} - -inline -size_t Markup::size() const -{ - return items_.size(); -} - -inline -Boolean MarkupIter::valid() const -{ - return index_ < nItems_; -} - -inline -size_t MarkupIter::index() const -{ - return index_; -} - -inline -Markup::Type MarkupIter::type() const -{ - return Markup::Type(items_[index_].type); -} - -inline -const EntityOrigin *MarkupIter::entityOrigin() const -{ - return (*items_[index_].origin)->asEntityOrigin(); -} - -inline -const Char *MarkupIter::charsPointer() const -{ - return chars_ + charIndex_; -} - -inline -size_t MarkupIter::charsLength() const -{ - return items_[index_].nChars; -} - -inline -const Text &MarkupIter::text() const -{ - return *items_[index_].text; -} - -inline -const SdText &MarkupIter::sdText() const -{ - return *items_[index_].sdText; -} - -inline -Syntax::DelimGeneral MarkupIter::delimGeneral() const -{ - return Syntax::DelimGeneral(items_[index_].index); -} - -inline -Syntax::ReservedName MarkupIter::reservedName() const -{ - return Syntax::ReservedName(items_[index_].index); -} - -inline -Sd::ReservedName MarkupIter::sdReservedName() const -{ - return Sd::ReservedName(items_[index_].index); -} - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* not Markup_INCLUDED */ diff --git a/cde/programs/nsgmls/MarkupScan.h b/cde/programs/nsgmls/MarkupScan.h deleted file mode 100644 index 5b6f7135b..000000000 --- a/cde/programs/nsgmls/MarkupScan.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: MarkupScan.h /main/1 1996/07/29 16:56:48 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#ifndef MarkupScan_INCLUDED -#define MarkupScan_INCLUDED 1 - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -struct MarkupScan { - enum Type { - normal, - in, - out, - suppress - }; -}; - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* not MarkupScan_INCLUDED */ diff --git a/cde/programs/nsgmls/Message.C b/cde/programs/nsgmls/Message.C deleted file mode 100644 index 0c124f78b..000000000 --- a/cde/programs/nsgmls/Message.C +++ /dev/null @@ -1,346 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: Message.C /main/1 1996/07/29 16:56:53 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#ifdef __GNUG__ -#pragma implementation -#endif - -#include "splib.h" -#include "Message.h" -#include "MessageArg.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -MessageFragment::MessageFragment(unsigned module, unsigned number, const char * -#ifndef SP_NO_MESSAGE_TEXT - text -#endif - ) -: module_(module), -#ifndef SP_NO_MESSAGE_TEXT - text_(text), -#endif - number_(number), - spare_(0) -{ -} - -MessageType::MessageType(Severity severity, unsigned module, unsigned number, - const char *text, const char * -#ifndef SP_NO_MESSAGE_TEXT - auxText -#endif - ) -: -#ifndef SP_NO_MESSAGE_TEXT - auxText_(auxText), -#endif - MessageFragment(module, number, text) -{ - spare_ = severity; -} - -MessageType0::MessageType0(Severity severity, unsigned module, unsigned number, - const char *text) -: MessageType(severity, module, number, text) -{ -} - -MessageType1::MessageType1(Severity severity, unsigned module, unsigned number, - const char *text) -: MessageType(severity, module, number, text) -{ -} - -MessageType2::MessageType2(Severity severity, unsigned module, unsigned number, - const char *text) -: MessageType(severity, module, number, text) -{ -} - -MessageType3::MessageType3(Severity severity, unsigned module, unsigned number, - const char *text) -: MessageType(severity, module, number, text) -{ -} - -MessageType4::MessageType4(Severity severity, unsigned module, unsigned number, - const char *text) -: MessageType(severity, module, number, text) -{ -} - -MessageType5::MessageType5(Severity severity, unsigned module, unsigned number, - const char *text) -: MessageType(severity, module, number, text) -{ -} - -MessageType6::MessageType6(Severity severity, unsigned module, unsigned number, - const char *text) -: MessageType(severity, module, number, text) -{ -} - -MessageType0L::MessageType0L(Severity severity, unsigned module, unsigned number, - const char *text, const char *auxText) -: MessageType(severity, module, number, text, auxText) -{ -} - -MessageType1L::MessageType1L(Severity severity, unsigned module, unsigned number, - const char *text, const char *auxText) -: MessageType(severity, module, number, text, auxText) -{ -} - -OpenElementInfo::OpenElementInfo() -: included(0), matchIndex(0) -{ -} - -Message::Message() -: type(NULL) -{ -} - -Message::Message(int nArgs) -: args(nArgs), type(NULL) -{ -} - -void Message::swap(Message &to) -{ - const MessageType *tem = type; - type = to.type; - to.type = tem; - to.loc.swap(loc); - to.auxLoc.swap(auxLoc); - args.swap(to.args); - openElementInfo.swap(to.openElementInfo); -} - -Messenger::Messenger() -: haveNextLocation_(0) -{ -} - -Messenger::~Messenger() -{ -} - -void Messenger::dispatchMessage(Message &msg) -{ - const Message &tem = msg; - dispatchMessage(tem); -} - -void Messenger::message(const MessageType0 &type) -{ - Message msg(0); - doInitMessage(msg); - msg.type = &type; - dispatchMessage(msg); -} - -void Messenger::message(const MessageType1 &type, const MessageArg &arg0) -{ - Message msg(1); - doInitMessage(msg); - msg.args[0] = arg0.copy(); - msg.type = &type; - dispatchMessage(msg); -} - -void Messenger::message(const MessageType2 &type, - const MessageArg &arg0, - const MessageArg &arg1) -{ - Message msg(2); - doInitMessage(msg); - msg.args[0] = arg0.copy(); - msg.args[1] = arg1.copy(); - msg.type = &type; - dispatchMessage(msg); -} - -void Messenger::message(const MessageType3 &type, - const MessageArg &arg0, - const MessageArg &arg1, - const MessageArg &arg2) -{ - Message msg(3); - doInitMessage(msg); - msg.args[0] = arg0.copy(); - msg.args[1] = arg1.copy(); - msg.args[2] = arg2.copy(); - msg.type = &type; - dispatchMessage(msg); -} - -void Messenger::message(const MessageType4 &type, - const MessageArg &arg0, - const MessageArg &arg1, - const MessageArg &arg2, - const MessageArg &arg3) -{ - Message msg(4); - doInitMessage(msg); - msg.args[0] = arg0.copy(); - msg.args[1] = arg1.copy(); - msg.args[2] = arg2.copy(); - msg.args[3] = arg3.copy(); - msg.type = &type; - dispatchMessage(msg); -} - -void Messenger::message(const MessageType5 &type, - const MessageArg &arg0, - const MessageArg &arg1, - const MessageArg &arg2, - const MessageArg &arg3, - const MessageArg &arg4) -{ - Message msg(5); - doInitMessage(msg); - msg.args[0] = arg0.copy(); - msg.args[1] = arg1.copy(); - msg.args[2] = arg2.copy(); - msg.args[3] = arg3.copy(); - msg.args[4] = arg4.copy(); - msg.type = &type; - dispatchMessage(msg); -} - -void Messenger::message(const MessageType6 &type, - const MessageArg &arg0, - const MessageArg &arg1, - const MessageArg &arg2, - const MessageArg &arg3, - const MessageArg &arg4, - const MessageArg &arg5) -{ - Message msg(6); - doInitMessage(msg); - msg.args[0] = arg0.copy(); - msg.args[1] = arg1.copy(); - msg.args[2] = arg2.copy(); - msg.args[3] = arg3.copy(); - msg.args[4] = arg4.copy(); - msg.args[5] = arg5.copy(); - msg.type = &type; - dispatchMessage(msg); -} - -void Messenger::message(const MessageType0L &type, const Location &loc) -{ - Message msg(0); - doInitMessage(msg); - msg.type = &type; - msg.auxLoc = loc; - dispatchMessage(msg); -} - -void Messenger::message(const MessageType1L &type, const MessageArg &arg0, - const Location &loc) -{ - Message msg(1); - doInitMessage(msg); - msg.args[0] = arg0.copy(); - msg.type = &type; - msg.auxLoc = loc; - dispatchMessage(msg); -} - - -void Messenger::setNextLocation(const Location &loc) -{ - haveNextLocation_ = 1; - nextLocation_ = loc; -} - -void Messenger::initMessage(Message &) -{ -} - -void Messenger::doInitMessage(Message &msg) -{ - initMessage(msg); - if (haveNextLocation_) { - msg.loc = nextLocation_; - haveNextLocation_ = 0; - } -} - -ForwardingMessenger::ForwardingMessenger(Messenger &to) -: to_(&to) -{ -} - -void ForwardingMessenger::dispatchMessage(Message &msg) -{ - to_->dispatchMessage(msg); -} - -void ForwardingMessenger::dispatchMessage(const Message &msg) -{ - to_->dispatchMessage(msg); -} - -void ForwardingMessenger::initMessage(Message &msg) -{ - to_->initMessage(msg); -} - -ParentLocationMessenger::ParentLocationMessenger(Messenger &mgr) -: ForwardingMessenger(mgr) -{ -} - -void ParentLocationMessenger::initMessage(Message &msg) -{ - ForwardingMessenger::initMessage(msg); - if (!msg.loc.origin().isNull()) - msg.loc = msg.loc.origin()->parent(); -} - -NullMessenger::NullMessenger() -{ -} - -void NullMessenger::dispatchMessage(Message &) -{ -} - -void NullMessenger::dispatchMessage(const Message &) -{ -} - -#ifdef SP_NAMESPACE -} -#endif diff --git a/cde/programs/nsgmls/Message.h b/cde/programs/nsgmls/Message.h deleted file mode 100644 index 796e6c3c1..000000000 --- a/cde/programs/nsgmls/Message.h +++ /dev/null @@ -1,280 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: Message.h /main/1 1996/07/29 16:56:58 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#ifndef Message_INCLUDED -#define Message_INCLUDED 1 - -#ifdef __GNUG__ -#pragma interface -#endif - -#include -#include "Location.h" -#include "Vector.h" -#include "CopyOwner.h" -#include "Boolean.h" -#include "StringC.h" -#include "MessageArg.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -class SP_API MessageFragment { -public: - enum { - libModule = 0, - appModule = 1 - }; - MessageFragment(unsigned module, unsigned number, const char *text = 0); - unsigned module() const; - unsigned number() const; - const char *text() const; -private: - unsigned short number_; - unsigned char module_; -protected: - unsigned char spare_; -private: -#ifndef SP_NO_MESSAGE_TEXT - const char *text_; -#endif -}; - -class SP_API MessageType : public MessageFragment { -public: - enum Severity { - info, - warning, - quantityError, - idrefError, - error - }; - MessageType(Severity, unsigned module, unsigned number, - const char *text = 0, const char *auxText = 0); - Severity severity() const; - MessageFragment auxFragment() const; - Boolean isError() const; -private: -#ifndef SP_NO_MESSAGE_TEXT - const char *auxText_; -#endif -}; - - -class SP_API MessageType0 : public MessageType { -public: - MessageType0(Severity, unsigned module, unsigned number, const char *text = 0); -}; - -class SP_API MessageType1 : public MessageType { -public: - MessageType1(Severity, unsigned module, unsigned number, const char *text = 0); -}; - -class SP_API MessageType2 : public MessageType { -public: - MessageType2(Severity, unsigned module, unsigned number, const char *text = 0); -}; - -class SP_API MessageType3 : public MessageType { -public: - MessageType3(Severity, unsigned module, unsigned number, const char *text = 0); -}; - -class SP_API MessageType4 : public MessageType { -public: - MessageType4(Severity, unsigned module, unsigned number, const char *text = 0); -}; - -class SP_API MessageType5 : public MessageType { -public: - MessageType5(Severity, unsigned module, unsigned number, const char *text = 0); -}; - -class SP_API MessageType6 : public MessageType { -public: - MessageType6(Severity, unsigned module, unsigned number, const char *text = 0); -}; - -class SP_API MessageType0L : public MessageType { -public: - MessageType0L(Severity, unsigned module, unsigned number, const char *text = 0, - const char *auxText = 0); -}; - -class SP_API MessageType1L : public MessageType { -public: - MessageType1L(Severity, unsigned module, unsigned number, const char *text = 0, - const char *auxText = 0); -}; - -class SP_API OpenElementInfo { -public: - OpenElementInfo(); - PackedBoolean included; - StringC gi; - StringC matchType; - unsigned matchIndex; -}; - -class SP_API Message { -public: - Message(); - Message(int nArgs); - const MessageType *type; - Location loc; - Location auxLoc; - Vector > args; - Vector openElementInfo; - void swap(Message &); - Boolean isError() const; -}; - -class SP_API Messenger { -public: - Messenger(); - virtual ~Messenger(); - void message(const MessageType0 &); - void message(const MessageType1 &, const MessageArg &); - void message(const MessageType2 &, - const MessageArg &, - const MessageArg &); - void message(const MessageType3 &, - const MessageArg &, - const MessageArg &, - const MessageArg &); - void message(const MessageType4 &, - const MessageArg &, - const MessageArg &, - const MessageArg &, - const MessageArg &); - void message(const MessageType5 &, - const MessageArg &, - const MessageArg &, - const MessageArg &, - const MessageArg &, - const MessageArg &); - void message(const MessageType6 &, - const MessageArg &, - const MessageArg &, - const MessageArg &, - const MessageArg &, - const MessageArg &, - const MessageArg &); - void message(const MessageType0L &, const Location &); - void message(const MessageType1L &, const MessageArg &, const Location &); - void setNextLocation(const Location &); - virtual void initMessage(Message &); - virtual void dispatchMessage(const Message &) = 0; - virtual void dispatchMessage(Message &); -private: - void doInitMessage(Message &); - Boolean haveNextLocation_; - Location nextLocation_; -}; - -class SP_API ForwardingMessenger : public Messenger { -public: - ForwardingMessenger(Messenger &); - void dispatchMessage(const Message &); - void dispatchMessage(Message &); - void initMessage(Message &); -private: - Messenger *to_; -}; - -class SP_API ParentLocationMessenger : public ForwardingMessenger { -public: - ParentLocationMessenger(Messenger &); - void initMessage(Message &); -}; - -class SP_API NullMessenger : public Messenger { -public: - NullMessenger(); - void dispatchMessage(const Message &); - void dispatchMessage(Message &); -}; - -inline -unsigned MessageFragment::module() const -{ - return module_; -} - -inline -unsigned MessageFragment::number() const -{ - return number_; -} - -inline -const char *MessageFragment::text() const -{ -#ifdef SP_NO_MESSAGE_TEXT - return 0; -#else - return text_; -#endif -} - -inline -MessageType::Severity MessageType::severity() const -{ - return Severity(spare_); -} - -inline -MessageFragment MessageType::auxFragment() const -{ - return MessageFragment(module(), - number() + 1, -#ifdef SP_NO_MESSAGE_TEXT - 0 -#else - auxText_ -#endif - ); -} - -inline -Boolean MessageType::isError() const -{ - return severity() != info && severity() != warning; -} - -inline -Boolean Message::isError() const -{ - return type->isError(); -} - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* not Message_INCLUDED */ diff --git a/cde/programs/nsgmls/MessageArg.C b/cde/programs/nsgmls/MessageArg.C deleted file mode 100644 index 35b190f81..000000000 --- a/cde/programs/nsgmls/MessageArg.C +++ /dev/null @@ -1,105 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: MessageArg.C /main/1 1996/07/29 16:57:04 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#ifdef __GNUG__ -#pragma implementation -#endif -#include "splib.h" -#include "MessageArg.h" -#include "MessageBuilder.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -MessageArg::MessageArg() -{ -} - -MessageArg::~MessageArg() -{ -} - -StringMessageArg::StringMessageArg(const StringC &s) -: s_(s) -{ -} - -MessageArg *StringMessageArg::copy() const -{ - return new StringMessageArg(*this); -} - -void StringMessageArg::append(MessageBuilder &builder) const -{ - builder.appendChars(s_.data(), s_.size()); -} - -NumberMessageArg::NumberMessageArg(unsigned long n) -: n_(n) -{ -} - -MessageArg *NumberMessageArg::copy() const -{ - return new NumberMessageArg(*this); -} - -void NumberMessageArg::append(MessageBuilder &builder) const -{ - builder.appendNumber(n_); -} - - -OrdinalMessageArg::OrdinalMessageArg(unsigned long n) -: n_(n) -{ -} - -MessageArg *OrdinalMessageArg::copy() const -{ - return new OrdinalMessageArg(*this); -} - -void OrdinalMessageArg::append(MessageBuilder &builder) const -{ - builder.appendOrdinal(n_); -} - -RTTI_DEF0(OtherMessageArg) - -OtherMessageArg::OtherMessageArg() -{ -} - -void OtherMessageArg::append(MessageBuilder &builder) const -{ - builder.appendOther(this); -} - -#ifdef SP_NAMESPACE -} -#endif diff --git a/cde/programs/nsgmls/MessageArg.h b/cde/programs/nsgmls/MessageArg.h deleted file mode 100644 index bb800f0bd..000000000 --- a/cde/programs/nsgmls/MessageArg.h +++ /dev/null @@ -1,88 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: MessageArg.h /main/1 1996/07/29 16:57:11 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#ifndef MessageArg_INCLUDED -#define MessageArg_INCLUDED 1 -#ifdef __GNUG__ -#pragma interface -#endif - -#include "StringC.h" -#include "rtti.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -class MessageBuilder; - -class SP_API MessageArg { -public: - MessageArg(); - virtual ~MessageArg(); - virtual MessageArg *copy() const = 0; - virtual void append(MessageBuilder &) const = 0; -}; - -class SP_API StringMessageArg : public MessageArg { -public: - StringMessageArg(const StringC &); - MessageArg *copy() const; - void append(MessageBuilder &) const; -private: - StringC s_; -}; - -class SP_API NumberMessageArg : public MessageArg { -public: - NumberMessageArg(unsigned long); - MessageArg *copy() const; - void append(MessageBuilder &) const; -private: - unsigned long n_; -}; - -class SP_API OrdinalMessageArg : public MessageArg { -public: - OrdinalMessageArg(unsigned long); - MessageArg *copy() const; - void append(MessageBuilder &) const; -private: - unsigned long n_; -}; - -class SP_API OtherMessageArg : public MessageArg { - RTTI_CLASS -public: - OtherMessageArg(); - void append(MessageBuilder &) const; -}; - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* not MessageArg_INCLUDED */ diff --git a/cde/programs/nsgmls/MessageBuilder.h b/cde/programs/nsgmls/MessageBuilder.h deleted file mode 100644 index 2ddfd8d76..000000000 --- a/cde/programs/nsgmls/MessageBuilder.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: MessageBuilder.h /main/1 1996/07/29 16:57:19 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#ifndef MessageBuilder_INCLUDED -#define MessageBuilder_INCLUDED 1 - -#include -#include "types.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -class OtherMessageArg; -class MessageFragment; - -class SP_API MessageBuilder { -public: - virtual void appendNumber(unsigned long) = 0; - virtual void appendOrdinal(unsigned long) = 0; - virtual void appendChars(const Char *, size_t) = 0; - virtual void appendOther(const OtherMessageArg *) = 0; - virtual void appendFragment(const MessageFragment &) = 0; -}; - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* not MessageBuilder_INCLUDED */ diff --git a/cde/programs/nsgmls/MessageEventHandler.C b/cde/programs/nsgmls/MessageEventHandler.C deleted file mode 100644 index e9ae66dd7..000000000 --- a/cde/programs/nsgmls/MessageEventHandler.C +++ /dev/null @@ -1,73 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: MessageEventHandler.C /main/1 1996/07/29 16:57:23 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#include "splib.h" -#include "MessageEventHandler.h" -#include "SgmlParser.h" -#include "ParserOptions.h" -#ifdef __GNUG__ -#include "Entity.h" -#endif - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -MessageEventHandler::MessageEventHandler(Messenger *messenger, - const SgmlParser *parser) -: messenger_(messenger), parser_(parser) -{ -} - -void MessageEventHandler::subdocEntity(SubdocEntityEvent *event) -{ - const SubdocEntity *entity = event->entity(); - if (entity && parser_) { - SgmlParser::Params params; - params.subdocReferenced = 1; - params.subdocInheritActiveLinkTypes = 1; - params.origin = event->entityOrigin()->copy(); - params.parent = parser_; - params.sysid = entity->externalId().effectiveSystemId(); - params.entityType = SgmlParser::Params::subdoc; - SgmlParser parser(params); - const SgmlParser *oldParser = parser_; - parser_ = &parser; - parser.parseAll(*this); - parser_ = oldParser; - } - delete event; -} - -void MessageEventHandler::message(MessageEvent *event) -{ - messenger_->dispatchMessage(event->message()); - ErrorCountEventHandler::message(event); -} - -#ifdef SP_NAMESPACE -} -#endif diff --git a/cde/programs/nsgmls/MessageEventHandler.h b/cde/programs/nsgmls/MessageEventHandler.h deleted file mode 100644 index 21deefeda..000000000 --- a/cde/programs/nsgmls/MessageEventHandler.h +++ /dev/null @@ -1,62 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: MessageEventHandler.h /main/1 1996/07/29 16:57:27 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#ifndef MessageEventHandler_INCLUDED -#define MessageEventHandler_INCLUDED 1 - -#include "Event.h" -#include "ErrorCountEventHandler.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -class OutputCharStream; -class SgmlParser; - -class SP_API MessageEventHandler : public ErrorCountEventHandler { -public: - // if parser is non-null then subdocs will be parsed automatically - MessageEventHandler(Messenger *messenger, const SgmlParser *parser = 0); - void message(MessageEvent *); - void subdocEntity(SubdocEntityEvent *); - Messenger *messenger() const; -private: - Messenger *messenger_; - const SgmlParser *parser_; -}; - -inline -Messenger *MessageEventHandler::messenger() const -{ - return messenger_; -} - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* not MessageEventHandler_INCLUDED */ diff --git a/cde/programs/nsgmls/MessageReporter.C b/cde/programs/nsgmls/MessageReporter.C deleted file mode 100644 index 452ca6842..000000000 --- a/cde/programs/nsgmls/MessageReporter.C +++ /dev/null @@ -1,390 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: MessageReporter.C /main/1 1996/07/29 16:57:32 cde-hp $ */ -// Copyright (c) 1994, 1995 James Clark -// See the file COPYING for copying permission. - -#ifdef __GNUG__ -#pragma implementation -#endif - -#include "splib.h" -#include "MessageReporter.h" -#include "ExtendEntityManager.h" -#include "StorageManager.h" -#include "macros.h" -#include "rtti.h" -#include "MessageArg.h" -#include "ErrnoMessageArg.h" -#include "SearchResultMessageArg.h" -#include "MessageReporterMessages.h" - -#include -#include - -#ifdef DECLARE_STRERROR -extern "C" { - char *strerror(int); -} -#endif - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -const OutputCharStream::Newline nl = OutputCharStream::newline; - -MessageReporter::MessageReporter(OutputCharStream *os) -: os_(os), options_(0) -{ -} - -MessageReporter::~MessageReporter() -{ - delete os_; -} - -void MessageReporter::setMessageStream(OutputCharStream *os) -{ - if (os != os_) { - delete os_; - os_ = os; - } -} - -void MessageReporter::addOption(Option option) -{ - options_ |= option; -} - -void MessageReporter::dispatchMessage(Message &message) -{ - dispatchMessage((const Message &) message); -} - -void MessageReporter::dispatchMessage(const Message &message) -{ - Offset off; - const ExternalInfo *externalInfo = locationHeader(message.loc, off); - if (programName_.size()) - os() << programName_ << ':'; - if (externalInfo) { - printLocation(externalInfo, off); - os() << ':'; - } - if (options_ & messageNumbers) - os() << (unsigned long)message.type->module() << "." - << (unsigned long)message.type->number() << ":"; - switch (message.type->severity()) { - case MessageType::info: - appendFragment(MessageReporterMessages::infoTag); - break; - case MessageType::warning: - appendFragment(MessageReporterMessages::warningTag); - break; - case MessageType::quantityError: - appendFragment(MessageReporterMessages::quantityErrorTag); - break; - case MessageType::idrefError: - appendFragment(MessageReporterMessages::idrefErrorTag); - break; - case MessageType::error: - appendFragment(MessageReporterMessages::errorTag); - break; - default: - CANNOT_HAPPEN(); - } - os() << ": "; - formatMessage(*message.type, message.args); - os() << nl; - if (!message.auxLoc.origin().isNull()) { - Offset off; - const ExternalInfo *externalInfo = locationHeader(message.auxLoc, off); - if (programName_.size()) - os() << programName_ << ':'; - if (externalInfo) { - printLocation(externalInfo, off); - os() << ": "; - } - formatMessage(message.type->auxFragment(), message.args); - os() << nl; - } - if ((options_ & openElements) && message.openElementInfo.size() > 0) { - if (programName_.size()) - os() << programName_ << ':'; - if (externalInfo) { - printLocation(externalInfo, off); - os() << ": "; - } - appendFragment(MessageReporterMessages::openElements); - os() << ':'; - unsigned nOpenElements = message.openElementInfo.size(); - for (unsigned i = 0;; i++) { - if (i > 0 - && (i == nOpenElements || message.openElementInfo[i].included)) { - // describe last match in previous open element - const OpenElementInfo &prevInfo = message.openElementInfo[i - 1]; - if (prevInfo.matchType.size() != 0) { - os() << " (" << prevInfo.matchType; - if (prevInfo.matchIndex != 0) - os() << '[' << (unsigned long)prevInfo.matchIndex << ']'; - os() << ')'; - } - } - if (i == nOpenElements) - break; - const OpenElementInfo &e = message.openElementInfo[i]; - os() << ' ' << e.gi; - if (i > 0 && !e.included) { - unsigned long n = message.openElementInfo[i - 1].matchIndex; - if (n != 0) - os() << '[' << n << ']'; - } - } - os() << nl; - } - os().flush(); -} - -void MessageReporter::formatMessage(const MessageFragment &frag, - const Vector > &args) -{ - StringC text; - if (!getMessageText(frag, text)) { - appendFragment(MessageReporterMessages::invalidMessage); - return; - } - size_t i = 0; - while (i < text.size()) { - if (text[i] == '%') { - i++; - if (i >= text.size()) - break; - if (text[i] >= '1' && text[i] <= '9') { - if (unsigned(text[i] - '1') < args.size()) - args[text[i] - '1']->append(*this); - } - else - os().put(text[i]); - i++; - } - else { - os().put(text[i]); - i++; - } - } -} - -const ExternalInfo *MessageReporter::locationHeader(const Location &loc, - Offset &off) -{ - const Origin *origin = loc.origin().pointer(); - Index index = loc.index(); - if (!(options_ & openEntities)) { - while (origin) { - const InputSourceOrigin *inputSourceOrigin = origin->asInputSourceOrigin(); - if (inputSourceOrigin) { - const ExternalInfo *externalInfo = inputSourceOrigin->externalInfo(); - if (externalInfo) { - off = inputSourceOrigin->startOffset(index); - return externalInfo; - } - } - const Location &loc = origin->parent(); - index = loc.index() + origin->refLength(); - origin = loc.origin().pointer(); - } - } - else { - Boolean doneHeader = 0; - while (origin) { - const InputSourceOrigin *inputSourceOrigin = origin->asInputSourceOrigin(); - if (inputSourceOrigin) { - if (!doneHeader) { - Offset parentOff; - Location parentLoc = inputSourceOrigin->parent(); - parentLoc += inputSourceOrigin->refLength(); - const ExternalInfo *parentInfo = locationHeader(parentLoc, parentOff); - if (parentInfo) { - StringC text; - if (getMessageText(inputSourceOrigin->entityName() - ? MessageReporterMessages::inNamedEntity - : MessageReporterMessages::inUnnamedEntity, - text)) { - for (size_t i = 0; i < text.size(); i++) { - if (text[i] == '%') { - if (i + 1 < text.size()) { - i++; - if (text[i] == '1') - os() << *inputSourceOrigin->entityName(); - else if (text[i] == '2') - printLocation(parentInfo, parentOff); - else if (text[i] >= '3' && text[i] <= '9') - ; - else - os().put(text[i]); - } - } - else - os().put(text[i]); - } - os() << nl; - } - } - doneHeader = 1; - } - off = inputSourceOrigin->startOffset(index); - const ExternalInfo *externalInfo = inputSourceOrigin->externalInfo(); - if (externalInfo) - return externalInfo; - Location loc; - if (!inputSourceOrigin->defLocation(off, loc)) - break; - index = loc.index(); - origin = loc.origin().pointer(); - } - else { - const Location &loc = origin->parent(); - index = loc.index() + origin->refLength(); - origin = loc.origin().pointer(); - } - } - } - return 0; -} - -void MessageReporter::printLocation(const ExternalInfo *externalInfo, - Offset off) -{ - if (!externalInfo) { - appendFragment(MessageReporterMessages::invalidLocation); - return; - } - StorageObjectLocation soLoc; - if (!ExtendEntityManager::externalize(externalInfo, off, soLoc)) { - appendFragment(MessageReporterMessages::invalidLocation); - return; - } - if (strcmp(soLoc.storageObjectSpec->storageManager->type(), "OSFILE") != 0) - os() << '<' << soLoc.storageObjectSpec->storageManager->type() << '>'; - os() << soLoc.storageObjectSpec->id; - if (soLoc.lineNumber == (unsigned long)-1) { - os() << ": "; - appendFragment(MessageReporterMessages::offset); - os() << soLoc.storageObjectOffset; - } - else { - os() << ':' << soLoc.lineNumber; - if (soLoc.columnNumber != 0 && soLoc.columnNumber != (unsigned long)-1) - os() << ':' << soLoc.columnNumber - 1; - } -#if 0 - if (soLoc.byteIndex != (unsigned long)-1) - os() << ':' << soLoc.byteIndex; -#endif -} - -void MessageReporter::appendNumber(unsigned long n) -{ - os() << n; -} - -void MessageReporter::appendOrdinal(unsigned long n) -{ - os() << n; - switch (n % 10) { - case 1: - appendFragment(MessageReporterMessages::ordinal1); - break; - case 2: - appendFragment(MessageReporterMessages::ordinal2); - break; - case 3: - appendFragment(MessageReporterMessages::ordinal3); - break; - default: - appendFragment(MessageReporterMessages::ordinaln); - break; - } -} - -void MessageReporter::appendChars(const Char *p, size_t n) -{ - os().put('"').write(p, n).put('"'); -} - -void MessageReporter::appendOther(const OtherMessageArg *p) -{ - const ErrnoMessageArg *ea = DYNAMIC_CAST_CONST_PTR(ErrnoMessageArg, p); - - if (ea) { - os() << strerror(ea->errnum()); - return; - } - - const SearchResultMessageArg *sr - = DYNAMIC_CAST_CONST_PTR(SearchResultMessageArg, p); - if (sr) { - for (size_t i = 0; i < sr->nTried(); i++) { - if (i > 0) - os() << ", "; - const StringC &f = sr->filename(i); - appendChars(f.data(), f.size()); - switch (sr->errnum(i)) { - default: - os() << " ("; - os() << strerror(sr->errnum(i)); - os() << ")"; -#ifdef ENOENT - case ENOENT: -#endif - break; - } - } - return; - } - appendFragment(MessageReporterMessages::invalidArgumentType); -} - -void MessageReporter::appendFragment(const MessageFragment &frag) -{ - StringC text; - if (getMessageText(frag, text)) - os() << text; -} - -Boolean MessageReporter::getMessageText(const MessageFragment &frag, - StringC &str) -{ - const char *p = frag.text(); - if (!p) - return 0; - str.resize(0); - for (; *p; p++) - str += Char((unsigned char)*p); - return 1; -} - -#ifdef SP_NAMESPACE -} -#endif diff --git a/cde/programs/nsgmls/MessageReporter.h b/cde/programs/nsgmls/MessageReporter.h deleted file mode 100644 index 343fd65e7..000000000 --- a/cde/programs/nsgmls/MessageReporter.h +++ /dev/null @@ -1,107 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: MessageReporter.h /main/1 1996/07/29 16:57:36 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#ifndef MessageReporter_INCLUDED -#define MessageReporter_INCLUDED 1 - -#ifdef __GNUG__ -#pragma interface -#endif - -#include "types.h" -#include "MessageBuilder.h" -#include "Boolean.h" -#include "OutputCharStream.h" -#include "Message.h" -#include "Location.h" -#include "StringC.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -class SP_API MessageReporter : private MessageBuilder, public Messenger { -public: - enum Option { - openElements = 01, - openEntities = 02, - messageNumbers = 04 - }; - // The OutputCharStream will be deleted by the MessageReporter - MessageReporter(OutputCharStream *); - ~MessageReporter(); - void setMessageStream(OutputCharStream *); - OutputCharStream *releaseMessageStream(); - void dispatchMessage(const Message &); - void dispatchMessage(Message &); - virtual Boolean getMessageText(const MessageFragment &, StringC &); - void addOption(Option); - void setProgramName(const StringC &); - void formatMessage(const MessageFragment &, - const Vector > &args); -private: - MessageReporter(const MessageReporter &); // undefined - void operator=(const MessageReporter &); // undefined - - void appendNumber(unsigned long); - void appendOrdinal(unsigned long); - void appendChars(const Char *, size_t); - void appendOther(const OtherMessageArg *); - void appendFragment(const MessageFragment &); - const ExternalInfo *locationHeader(const Location &loc, Offset &off); - void printLocation(const ExternalInfo *info, Offset off); - OutputCharStream &os(); - - OutputCharStream *os_; - unsigned options_; - StringC programName_; -}; - -inline -OutputCharStream &MessageReporter::os() -{ - return *os_; -} - -inline -void MessageReporter::setProgramName(const StringC &programName) -{ - programName_ = programName; -} - -inline -OutputCharStream *MessageReporter::releaseMessageStream() -{ - OutputCharStream *tem = os_; - os_ = 0; - return tem; -} - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* not MessageReporter_INCLUDED */ diff --git a/cde/programs/nsgmls/MessageReporterMessages.h b/cde/programs/nsgmls/MessageReporterMessages.h deleted file mode 100644 index 7c9a25944..000000000 --- a/cde/programs/nsgmls/MessageReporterMessages.h +++ /dev/null @@ -1,243 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: MessageReporterMessages.h /main/1 1996/07/29 16:57:40 cde-hp $ */ -// This file was automatically generated from MessageReporterMessages.msg by msggen.pl. -#include "Message.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -struct MessageReporterMessages { - // 5000 - static const MessageFragment infoTag; - // 5001 - static const MessageFragment warningTag; - // 5002 - static const MessageFragment quantityErrorTag; - // 5003 - static const MessageFragment idrefErrorTag; - // 5004 - static const MessageFragment errorTag; - // 5005 - static const MessageFragment openElements; - // 5006 - static const MessageFragment inNamedEntity; - // 5007 - static const MessageFragment inUnnamedEntity; - // 5008 - static const MessageFragment invalidLocation; - // 5009 - static const MessageFragment offset; - // 5010 - static const MessageFragment ordinal1; - // 5011 - static const MessageFragment ordinal2; - // 5012 - static const MessageFragment ordinal3; - // 5013 - static const MessageFragment ordinaln; - // 5014 - static const MessageFragment invalidArgumentType; - // 5015 - static const MessageFragment invalidMessage; -}; -const MessageFragment MessageReporterMessages::infoTag( -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -5000 -#ifndef SP_NO_MESSAGE_TEXT -,"I" -#endif -); -const MessageFragment MessageReporterMessages::warningTag( -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -5001 -#ifndef SP_NO_MESSAGE_TEXT -,"W" -#endif -); -const MessageFragment MessageReporterMessages::quantityErrorTag( -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -5002 -#ifndef SP_NO_MESSAGE_TEXT -,"Q" -#endif -); -const MessageFragment MessageReporterMessages::idrefErrorTag( -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -5003 -#ifndef SP_NO_MESSAGE_TEXT -,"X" -#endif -); -const MessageFragment MessageReporterMessages::errorTag( -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -5004 -#ifndef SP_NO_MESSAGE_TEXT -,"E" -#endif -); -const MessageFragment MessageReporterMessages::openElements( -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -5005 -#ifndef SP_NO_MESSAGE_TEXT -,"open elements" -#endif -); -const MessageFragment MessageReporterMessages::inNamedEntity( -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -5006 -#ifndef SP_NO_MESSAGE_TEXT -,"In entity %1 included from %2" -#endif -); -const MessageFragment MessageReporterMessages::inUnnamedEntity( -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -5007 -#ifndef SP_NO_MESSAGE_TEXT -,"In entity included from %2" -#endif -); -const MessageFragment MessageReporterMessages::invalidLocation( -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -5008 -#ifndef SP_NO_MESSAGE_TEXT -,"(invalid location)" -#endif -); -const MessageFragment MessageReporterMessages::offset( -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -5009 -#ifndef SP_NO_MESSAGE_TEXT -,"offset " -#endif -); -const MessageFragment MessageReporterMessages::ordinal1( -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -5010 -#ifndef SP_NO_MESSAGE_TEXT -,"st" -#endif -); -const MessageFragment MessageReporterMessages::ordinal2( -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -5011 -#ifndef SP_NO_MESSAGE_TEXT -,"nd" -#endif -); -const MessageFragment MessageReporterMessages::ordinal3( -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -5012 -#ifndef SP_NO_MESSAGE_TEXT -,"rd" -#endif -); -const MessageFragment MessageReporterMessages::ordinaln( -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -5013 -#ifndef SP_NO_MESSAGE_TEXT -,"th" -#endif -); -const MessageFragment MessageReporterMessages::invalidArgumentType( -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -5014 -#ifndef SP_NO_MESSAGE_TEXT -,"(invalid argument type)" -#endif -); -const MessageFragment MessageReporterMessages::invalidMessage( -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -5015 -#ifndef SP_NO_MESSAGE_TEXT -,"(invalid message)" -#endif -); -#ifdef SP_NAMESPACE -} -#endif diff --git a/cde/programs/nsgmls/MessageTable.C b/cde/programs/nsgmls/MessageTable.C deleted file mode 100644 index e6fe25cfb..000000000 --- a/cde/programs/nsgmls/MessageTable.C +++ /dev/null @@ -1,201 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: MessageTable.C /main/1 1996/07/29 16:57:45 cde-hp $ */ -// Copyright (c) 1996 James Clark -// See the file COPYING for copying permission. - -#ifdef __GNUG__ -#pragma implementation -#endif - -#include "splib.h" -#include "MessageTable.h" - -#ifdef SP_NO_MESSAGE_TEXT - -// Windows only - -#define STRICT -#include "windows.h" -static HINSTANCE dllInstanceHandle = NULL; - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -class WinMessageTable : public MessageTable { -public: - Boolean getText(const MessageFragment &, - String &) const; - -}; - -Boolean WinMessageTable::getText(const MessageFragment &frag, - String &str) const -{ - static const int bufSize = 4096; - SP_TCHAR buf[bufSize]; - int len = LoadString(frag.module() == MessageFragment::libModule - ? dllInstanceHandle - : 0, - frag.number(), - buf, - bufSize); - if (len == 0) { - // The resource might be empty. - if (GetLastError() != 0) - return 0; - else { - str.resize(0); - return 1; - } - } - str.assign(buf, len); - return 1; -} - -const MessageTable *MessageTable::instance() -{ - if (!instance_) - instance_ = new WinMessageTable; - return instance_; -} - -#ifdef SP_NAMESPACE -} -#endif - -#ifdef SP_USE_DLL -extern "C" -BOOL WINAPI DllMain(HINSTANCE inst, ULONG reason, LPVOID) -{ - if (reason == DLL_PROCESS_ATTACH) - dllInstanceHandle = inst; - return TRUE; -} -#endif - -#else /* not SP_NO_MESSAGE_TEXT */ - -#ifdef SP_HAVE_GETTEXT -extern "C" { -extern char *dgettext(const char *, const char *); -extern char *gettext(const char *); -extern char *textdomain(const char *); -extern char *bindtextdomain(const char *, const char *); -} - -#include - -#ifndef MESSAGE_DOMAIN -#define MESSAGE_DOMAIN "sp" -#endif - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -class GettextMessageTable : public MessageTable { -public: - GettextMessageTable(); - Boolean getText(const MessageFragment &, String &) const; - -}; - -GettextMessageTable::GettextMessageTable() -{ - const char *dir = getenv("TEXTDOMAINDIR"); - if (dir) - bindtextdomain(MESSAGE_DOMAIN, dir); -} - -Boolean GettextMessageTable::getText(const MessageFragment &frag, - String &str) const -{ - const char *s = frag.text(); - if (!s) - return 0; - s = dgettext(MESSAGE_DOMAIN, s); - if (!s) - return 0; - str.assign(s, strlen(s)); - return 1; -} - -const MessageTable *MessageTable::instance() -{ - if (!instance_) - instance_ = new GettextMessageTable; - return instance_; -} - -#ifdef SP_NAMESPACE -} -#endif - -#else /* not SP_HAVE_GETTEXT */ - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -class DefaultMessageTable : public MessageTable { -public: - Boolean getText(const MessageFragment &, String &) const; -}; - -Boolean DefaultMessageTable::getText(const MessageFragment &frag, - String &str) const -{ - if (!frag.text()) - return 0; - str.resize(0); - for (const char *s = frag.text(); *s; s++) - str += SP_TCHAR((unsigned char)*s); - return 1; -} - -const MessageTable *MessageTable::instance() -{ - if (!instance_) - instance_ = new DefaultMessageTable; - return instance_; -} - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* not SP_HAVE_GETTEXT */ - -#endif /* not SP_NO_MESSAGE_TEXT */ - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -MessageTable *MessageTable::instance_ = 0; - -#ifdef SP_NAMESPACE -} -#endif diff --git a/cde/programs/nsgmls/MessageTable.h b/cde/programs/nsgmls/MessageTable.h deleted file mode 100644 index 3f9f34283..000000000 --- a/cde/programs/nsgmls/MessageTable.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: MessageTable.h /main/1 1996/07/29 16:57:49 cde-hp $ */ -// Copyright (c) 1996 James Clark -// See the file COPYING for copying permission. - -#ifndef MessageTable_INCLUDED -#define MessageTable_INCLUDED 1 - -#ifdef __GNUG__ -#pragma interface -#endif - -#include "Message.h" -#include "Boolean.h" -#include "StringC.h" -#include "sptchar.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -class SP_API MessageTable { -public: - static const MessageTable *instance(); - virtual Boolean getText(const MessageFragment &, - String &) const = 0; -private: - static MessageTable *instance_; -}; - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* not MessageTable_INCLUDED */ diff --git a/cde/programs/nsgmls/Mode.h b/cde/programs/nsgmls/Mode.h deleted file mode 100644 index 58613403c..000000000 --- a/cde/programs/nsgmls/Mode.h +++ /dev/null @@ -1,92 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: Mode.h /main/1 1996/07/29 16:57:54 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#ifndef Mode_INCLUDED -#define Mode_INCLUDED 1 - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -enum Mode { - grpMode, // group - alitMode, // attribute value literals starting with LIT - alitaMode, // attribute value literals starting with LITA - aliteMode, // attribute value literals inside entity - talitMode, // tokenized attribute value literal - talitaMode, - taliteMode, - mdMode, // markup declaration - mdMinusMode, // markup declaration, also recognize minus - mdPeroMode, // markup declaration, also recognize pero - comMode, // comment - sdcomMode, // comment in an SGML declaration - piMode, // processing instruction - refMode, // reference - imsMode, // ignored marked section - cmsMode, // cdata marked section - rcmsMode, // rcdata marked section - // These modes are needed only for the prologue. - proMode, // prologue - dsMode, // declaration subset not in marked section - // nor in entity - dsiMode, // declaration subset in marked section or - // in entity - plitMode, // parameter literal starting with LIT - plitaMode, // paramater literal starting with LITA - pliteMode, // parameter literal inside entity - sdplitMode, // parameter literal starting with LIT - // in an SGML declaration - sdplitaMode, // parameter literal starting with LIT - // in an SGML declaration - grpsufMode, // group suffix - mlitMode, // minimum literal starting with LIT - mlitaMode, // minimum literal starting with LITA - asMode, // data/link/result attribute specification - slitMode, // system id literal starting with LIT - slitaMode, // system id literal starting with LITA - // These modes are needed only for the instance. - cconMode, // CDATA content - rcconMode, // RCDATA content - cconnetMode, // CDATA content, recognize NET - rcconnetMode, // RCDATA content, recognize NET - rcconeMode, // RCDATA content inside entity - tagMode, // start- or end-tag - econMode, // element content - mconMode, // mixed content - econnetMode, // element content, recognize NET - mconnetMode // mixed content, recognize NET - }; - -const int nModes = mconnetMode + 1; - -const int minShortrefMode = econMode; - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* not Mode_INCLUDED */ diff --git a/cde/programs/nsgmls/ModeInfo.C b/cde/programs/nsgmls/ModeInfo.C deleted file mode 100644 index 34c047d05..000000000 --- a/cde/programs/nsgmls/ModeInfo.C +++ /dev/null @@ -1,307 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: ModeInfo.C /main/1 1996/07/29 16:57:59 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#ifdef __GNUG__ -#pragma implementation -#endif -#include "splib.h" -#include -#include -#include "macros.h" -#include "types.h" -#include "Syntax.h" -#include "token.h" -#include "Sd.h" -#include "Mode.h" -#include "ModeInfo.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -const unsigned REQUIRE_SHORTTAG = 1; -const unsigned REQUIRE_CONCUR = 2; -const unsigned REQUIRE_LINK_OR_CONCUR = 4; -const unsigned REQUIRE_FLAGS = 7; - -#define ULONG_BIT (CHAR_BIT * sizeof(unsigned long)) - -struct PackedTokenInfo { - Token token; // token to be returned - unsigned flags; - unsigned char contents[2]; // components of the delimiter or d-i-c - unsigned char modes[25]; // list of modes in which it is recognized, - // terminated by EOM - // a bit vector computed from modes (lo to hi) - unsigned long modeBits[(nModes + ULONG_BIT - 1)/ULONG_BIT]; - void computeModeBits(); - Boolean inMode(Mode mode) const; -}; - -const unsigned char SET = Syntax::nDelimGeneral; -const unsigned char FUNCTION = SET + Syntax::nSet; -const unsigned char NOTHING = UCHAR_MAX; - -const unsigned char EOM = 255; // end of modes - -static PackedTokenInfo tokenTable[] = { - // Delimiters and delimiters in context - { tokenAnd, 0, { Syntax::dAND, NOTHING }, { grpMode, EOM }}, - { tokenCom, 0, { Syntax::dCOM, NOTHING }, - { mdMode, mdMinusMode, mdPeroMode, comMode, sdcomMode, EOM }}, - { tokenCroDigit, 0, { Syntax::dCRO, SET + Syntax::digit }, - { econMode, mconMode, rcconMode, econnetMode, mconnetMode, rcconnetMode, - rcconeMode, plitMode, plitaMode, pliteMode, sdplitMode, sdplitaMode, - alitMode, alitaMode, aliteMode, - talitMode, talitaMode, taliteMode, rcmsMode, EOM }}, - { tokenCroNameStart, 0, { Syntax::dCRO, SET + Syntax::nameStart }, - { econMode, mconMode, rcconMode, econnetMode, mconnetMode, rcconnetMode, - rcconeMode, plitMode, plitaMode, pliteMode, sdplitMode, sdplitaMode, - alitMode, alitaMode, aliteMode, - talitMode, talitaMode, taliteMode, rcmsMode, EOM }}, - { tokenDsc, 0, { Syntax::dDSC, NOTHING }, - { /* mdMode, */ asMode, dsMode, EOM }}, - { tokenDso, 0, { Syntax::dDSO, NOTHING }, { mdMode, EOM }}, - { tokenDtgc, 0, { Syntax::dDTGC, NOTHING }, { grpMode, EOM }}, - { tokenDtgo, 0, { Syntax::dDTGO, NOTHING }, { grpMode, EOM }}, - { tokenEroNameStart, 0, { Syntax::dERO, SET + Syntax::nameStart }, - { econMode, mconMode, rcconMode, econnetMode, mconnetMode, rcconnetMode, - rcconeMode, alitMode, alitaMode, aliteMode, talitMode, talitaMode, - taliteMode, rcmsMode, EOM }}, - { tokenEroGrpo, REQUIRE_LINK_OR_CONCUR, { Syntax::dERO, Syntax::dGRPO }, - { econMode, mconMode, rcconMode, econnetMode, mconnetMode, rcconnetMode, - rcconeMode, alitMode, alitaMode, aliteMode, talitMode, talitaMode, - taliteMode, rcmsMode, EOM }}, - { tokenEtago, 0, { Syntax::dETAGO, NOTHING }, { tagMode, EOM }}, - { tokenEtagoNameStart, 0, { Syntax::dETAGO, SET + Syntax::nameStart }, - { econMode, mconMode, cconMode, rcconMode, - econnetMode, mconnetMode, cconnetMode, rcconnetMode, EOM }}, - { tokenEtagoTagc, REQUIRE_SHORTTAG, { Syntax::dETAGO, Syntax::dTAGC }, - { econMode, mconMode, cconMode, rcconMode, - econnetMode, mconnetMode, cconnetMode, rcconnetMode, EOM }}, - { tokenEtagoGrpo, REQUIRE_CONCUR, { Syntax::dETAGO, Syntax::dGRPO }, - { econMode, mconMode, cconMode, rcconMode, - econnetMode, mconnetMode, cconnetMode, rcconnetMode, EOM }}, - { tokenGrpc, 0, { Syntax::dGRPC, NOTHING }, { grpMode, EOM }}, - { tokenGrpo, 0, { Syntax::dGRPO, NOTHING }, - { mdMode, mdMinusMode, grpMode, EOM }}, - { tokenLit, 0, { Syntax::dLIT, NOTHING }, - { alitMode, talitMode, plitMode, sdplitMode, mlitMode, slitMode, - asMode, tagMode, mdMode, grpMode, EOM }}, - { tokenLita, 0, { Syntax::dLITA, NOTHING }, - { alitaMode, talitaMode, plitaMode, sdplitaMode, mlitaMode, slitaMode, - asMode, tagMode, mdMode, grpMode, EOM }}, - { tokenMdc, 0, { Syntax::dMDC, NOTHING }, { mdMode, EOM }}, - { tokenMdoNameStart, 0, { Syntax::dMDO, SET + Syntax::nameStart }, - { econMode, mconMode, econnetMode, mconnetMode, - proMode, dsMode, dsiMode, EOM }}, - { tokenMdoMdc, 0, { Syntax::dMDO, Syntax::dMDC }, - { econMode, mconMode, econnetMode, mconnetMode, - proMode, dsMode, dsiMode, EOM }}, - { tokenMdoCom, 0, { Syntax::dMDO, Syntax::dCOM }, - { econMode, mconMode, econnetMode, mconnetMode, - proMode, dsMode, dsiMode, EOM }}, - { tokenMdoDso, 0, { Syntax::dMDO, Syntax::dDSO }, - { econMode, mconMode, econnetMode, mconnetMode, - dsMode, dsiMode, imsMode, EOM }}, - { tokenMinus, 0, { Syntax::dMINUS, NOTHING }, { mdMinusMode, EOM }}, - { tokenMinusGrpo, 0, { Syntax::dMINUS, Syntax::dGRPO }, { mdMode, EOM }}, - { tokenMscMdc, 0, { Syntax::dMSC, Syntax::dMDC}, - { imsMode, cmsMode, rcmsMode, - econMode, mconMode, econnetMode, mconnetMode, dsMode, dsiMode, EOM }}, - { tokenNet, 0, { Syntax::dNET, NOTHING }, - { econnetMode, mconnetMode, cconnetMode, rcconnetMode, tagMode, EOM }}, - { tokenOpt, 0, { Syntax::dOPT, NOTHING }, { grpMode, grpsufMode, EOM }}, - { tokenOr, 0, { Syntax::dOR, NOTHING }, { grpMode, EOM }}, - { tokenPero, 0, { Syntax::dPERO, NOTHING }, { mdPeroMode, EOM }}, - { tokenPeroNameStart, 0, { Syntax::dPERO, SET + Syntax::nameStart }, { - mdMode, mdMinusMode, mdPeroMode, dsMode, dsiMode, grpMode, - plitMode, plitaMode, pliteMode, sdplitMode, sdplitaMode, EOM }}, - { tokenPeroGrpo, REQUIRE_LINK_OR_CONCUR, { Syntax::dPERO, Syntax::dGRPO }, - { mdMode, mdMinusMode, mdPeroMode, dsMode, dsiMode, grpMode, - plitMode, plitaMode, pliteMode, sdplitMode, sdplitaMode, EOM }}, - { tokenPic, 0, { Syntax::dPIC, NOTHING }, { piMode, EOM }}, - { tokenPio, 0, { Syntax::dPIO, NOTHING }, - { econMode, mconMode, econnetMode, mconnetMode, proMode, - dsMode, dsiMode, EOM }}, - { tokenPlus, 0, { Syntax::dPLUS, NOTHING }, { grpMode, grpsufMode, EOM }}, - { tokenPlusGrpo, 0, { Syntax::dPLUS, Syntax::dGRPO }, { mdMode, EOM }}, - { tokenRefc, 0, { Syntax::dREFC, NOTHING }, { refMode, EOM }}, - { tokenRep, 0, { Syntax::dREP, NOTHING }, { grpMode, grpsufMode, EOM }}, - { tokenRni, 0, { Syntax::dRNI, NOTHING }, - { grpMode, mdMode, mdPeroMode, EOM }}, - { tokenSeq, 0, { Syntax::dSEQ, NOTHING }, { grpMode, EOM }}, - { tokenStago, 0, { Syntax::dSTAGO, NOTHING }, { tagMode, EOM }}, - { tokenStagoNameStart, 0, { Syntax::dSTAGO, SET + Syntax::nameStart }, - { econMode, mconMode, econnetMode, mconnetMode, EOM }}, - { tokenStagoTagc, REQUIRE_SHORTTAG, { Syntax::dSTAGO, Syntax::dTAGC }, - { econMode, mconMode, econnetMode, mconnetMode, EOM }}, - { tokenStagoGrpo, REQUIRE_CONCUR, { Syntax::dSTAGO, Syntax::dGRPO }, - { econMode, mconMode, econnetMode, mconnetMode, EOM }}, - { tokenTagc, 0, { Syntax::dTAGC, NOTHING }, { tagMode, EOM }}, - { tokenVi, 0, { Syntax::dVI, NOTHING }, { tagMode, asMode, EOM }}, - // Other tokens - { tokenRe, 0, { FUNCTION + Syntax::fRE, NOTHING }, - { mconMode, cconMode, rcconMode, - mconnetMode, cconnetMode, rcconnetMode, - rcconeMode, cmsMode, rcmsMode, refMode, - mlitMode, mlitaMode, alitMode, alitaMode, aliteMode, - talitMode, talitaMode, taliteMode, - EOM }}, - { tokenRs, 0, { FUNCTION + Syntax::fRS, NOTHING }, - { mconMode, cconMode, rcconMode, - mconnetMode, cconnetMode, rcconnetMode, - rcconeMode, cmsMode, rcmsMode, - mlitMode, mlitaMode, alitMode, alitaMode, aliteMode, - talitMode, talitaMode, taliteMode, - EOM }}, - { tokenSpace, 0, { FUNCTION + Syntax::fSPACE, NOTHING }, - { mlitMode, mlitaMode, talitMode, talitaMode, taliteMode, EOM }}, - { tokenSepchar, 0, { SET + Syntax::sepchar, NOTHING }, - { alitMode, alitaMode, aliteMode, - talitMode, talitaMode, taliteMode, EOM }}, - { tokenS, 0, { SET + Syntax::s, NOTHING }, - { econMode, econnetMode, grpMode, mdMode, mdMinusMode, mdPeroMode, - proMode, dsMode, dsiMode, asMode, tagMode, EOM }}, - { tokenNameStart, 0, { SET + Syntax::nameStart, NOTHING }, - { grpMode, mdMode, mdMinusMode, mdPeroMode, - asMode, tagMode, EOM }}, - { tokenDigit, 0, { SET + Syntax::digit, NOTHING }, - { grpMode, mdMode, mdMinusMode, asMode, tagMode, EOM }}, - { tokenLcUcNmchar, 0, { SET + Syntax::nmchar, NOTHING }, - { grpMode, mdMode, asMode, tagMode, EOM }}, - { tokenIgnoredChar, 0, { SET + Syntax::sgmlChar, NOTHING }, - { imsMode, EOM }}, - { tokenChar, 0, { SET + Syntax::sgmlChar, NOTHING }, - // Note that character data is recognized in element content, - // and will cause #PCDATA to begin. - { alitMode, alitaMode, aliteMode, - talitMode, talitaMode, taliteMode, - comMode, piMode, - cmsMode, rcmsMode, - plitMode, plitaMode, pliteMode, - slitMode, slitaMode, - econMode, mconMode, cconMode, rcconMode, - econnetMode, mconnetMode, cconnetMode, rcconnetMode, rcconeMode, EOM }}, - { tokenChar, 0, { SET + Syntax::minimumData, NOTHING }, - { mlitMode, mlitaMode, EOM }}, - { tokenChar, 0, { SET + Syntax::significant, NOTHING }, - { sdplitMode, sdplitaMode, sdcomMode, EOM }}, -}; - -inline Boolean PackedTokenInfo::inMode(Mode mode) const -{ - return ((modeBits[unsigned(mode) / ULONG_BIT] - & ((unsigned long)1 << (unsigned(mode) % ULONG_BIT))) - != 0); -} - -void PackedTokenInfo::computeModeBits() -{ - for (unsigned char *p = modes; *p != EOM; p++) - modeBits[*p / ULONG_BIT] |= (unsigned long)1 << (*p % ULONG_BIT); -} - -struct TokenTableIniter { - TokenTableIniter(); -}; - -static TokenTableIniter tokenTableIniter; - -TokenTableIniter::TokenTableIniter() -{ - for (size_t i = 0; i < SIZEOF(tokenTable); i++) - tokenTable[i].computeModeBits(); -} - -ModeInfo::ModeInfo(Mode mode, const Sd &sd) -: mode_(mode), p_(tokenTable), count_(SIZEOF(tokenTable)), - missingRequirements_(REQUIRE_FLAGS) -{ - if (sd.shorttag()) - missingRequirements_ &= ~REQUIRE_SHORTTAG; - if (sd.concur()) - missingRequirements_ &= ~(REQUIRE_CONCUR|REQUIRE_LINK_OR_CONCUR); - if (sd.link()) - missingRequirements_ &= ~REQUIRE_LINK_OR_CONCUR; -} - -Boolean ModeInfo::nextToken(TokenInfo *t) -{ - for (; count_ > 0; --count_, ++p_) - if (p_->inMode(mode_) && (p_->flags & missingRequirements_) == 0) { - t->token = p_->token; - t->priority = Priority::delim; - const unsigned char *contents = p_->contents; - --count_; - ++p_; - unsigned char c = contents[0]; - if (c < SET) - t->delim1 = Syntax::DelimGeneral(c); - else if (c < SET + Syntax::nSet) { - t->set = Syntax::Set(c - SET); - t->type = TokenInfo::setType; - switch (t->set) { - case Syntax::sepchar: - case Syntax::s: - case Syntax::blank: - t->priority = Priority::function; - break; - default: - t->priority = Priority::data; - break; - } - return 1; - } - else { - t->function = Syntax::StandardFunction(c - FUNCTION); - t->priority = Priority::function; - t->type = TokenInfo::functionType; - return 1; - } - c = contents[1]; - if (c == NOTHING) { - t->type = TokenInfo::delimType; - return 1; - } - if (c < SET) { - t->delim2 = Syntax::DelimGeneral(c); - t->type = TokenInfo::delimDelimType; - return 1; - } - if (c < SET + Syntax::nSet) { - t->set = Syntax::Set(c - SET); - t->type = TokenInfo::delimSetType; - return 1; - } - abort(); - } - return 0; -} - -#ifdef SP_NAMESPACE -} -#endif diff --git a/cde/programs/nsgmls/ModeInfo.h b/cde/programs/nsgmls/ModeInfo.h deleted file mode 100644 index 9ba4f5d58..000000000 --- a/cde/programs/nsgmls/ModeInfo.h +++ /dev/null @@ -1,86 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: ModeInfo.h /main/1 1996/07/29 16:58:04 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#ifndef ModeInfo_INCLUDED -#define ModeInfo_INCLUDED 1 -#ifdef __GNUG__ -#pragma interface -#endif - -#include -#include "Boolean.h" -#include "Syntax.h" -#include "Mode.h" -#include "Priority.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -struct TokenInfo { - enum Type { - delimType, - setType, - functionType, - delimDelimType, - delimSetType - }; - Type type; - Priority::Type priority; - Token token; - Syntax::DelimGeneral delim1; - union { - Syntax::DelimGeneral delim2; - Syntax::Set set; - Syntax::StandardFunction function; - }; -}; - -class Sd; -struct PackedTokenInfo; - -class ModeInfo { -public: - ModeInfo(Mode mode, const Sd &sd); - Boolean nextToken(TokenInfo *); - Boolean includesShortref() const; -private: - Mode mode_; - const PackedTokenInfo *p_; // points to next - size_t count_; - unsigned missingRequirements_; -}; - -inline Boolean ModeInfo::includesShortref() const -{ - return mode_ >= minShortrefMode; -} - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* not ModeInfo_INCLUDED */ diff --git a/cde/programs/nsgmls/NCVector.C b/cde/programs/nsgmls/NCVector.C deleted file mode 100644 index ae185f82f..000000000 --- a/cde/programs/nsgmls/NCVector.C +++ /dev/null @@ -1,185 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: NCVector.C /main/1 1996/07/29 16:58:08 cde-hp $ */ -// Copyright (c) 1994, 1996 James Clark -// See the file COPYING for copying permission. - -#ifndef NCVector_DEF_INCLUDED -#define NCVector_DEF_INCLUDED 1 - -#include -#include - -#ifdef SP_QUAL_TEMPLATE_DTOR_BROKEN -#define DTOR(T) ~T -#else -#define DTOR(T) T::~T -#endif - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -template -NCVector::~NCVector() -{ - if (ptr_) { - erase(ptr_, ptr_ + size_); - ::operator delete((void *)ptr_); - } -} - -#if 0 - -template -NCVector::NCVector(const NCVector &v) -: ptr_(0), size_(0), alloc_(0) -{ - insert(ptr_ + size_, v.ptr_, v.ptr_ + v.size_); -} - -template -NCVector::NCVector(size_t n, const T &t) -: ptr_(0), size_(0), alloc_(0) -{ - insert(ptr_ + size_, n, t); -} - -template -NCVector &NCVector::operator=(const NCVector &v) -{ - if (&v != this) { - size_t n = v.size_; - if (n > size_) { - n = size_; - insert(ptr_ + size_, v.ptr_ + size_, v.ptr_ + v.size_); - } - else if (n < size_) - erase(ptr_ + n, ptr_ + size_); - while (n-- > 0) - ptr_[n] = v.ptr_[n]; - } - return *this; -} - -template -void NCVector::assign(size_t n, const T &t) -{ - size_t sz = n; - if (n > size_) { - sz = size_; - insert(ptr_ + size_, n - size_, t); - } - else if (n < size_) - erase(ptr_ + n, ptr_ + size_); - while (sz-- > 0) - ptr_[sz] = t; -} - -template -void NCVector::insert(const T *p, size_t n, const T &t) -{ - size_t i = p - ptr_; - reserve(size_ + n); - if (i != size_) - memmove(ptr_ + i + n, ptr_ + i, (size_ - i)*sizeof(T)); - size_ += n; - for (T *pp = ptr_ + i; n-- > 0; pp++) - (void)new (pp) T(t); -} - -template -void NCVector::insert(const T *p, const T *q1, const T *q2) -{ - size_t i = p - ptr_; - size_t n = q2 - q1; - reserve(size_ + n); - if (i != size_) - memmove(ptr_ + i + n, ptr_ + i, (size_ - i)*sizeof(T)); - size_ += n; - for (T *pp = ptr_ + i; q1 != q2; q1++, pp++) - (void)new (pp) T(*q1); -} - -#endif - -template -void NCVector::swap(NCVector &v) -{ - { - T *tem = ptr_; - ptr_ = v.ptr_; - v.ptr_ = tem; - } - { - size_t tem = size_; - size_ = v.size_; - v.size_ = tem; - } - { - size_t tem = alloc_; - alloc_ = v.alloc_; - v.alloc_ = tem; - } -} - -template -void NCVector::append(size_t n) -{ - reserve(size_ + n); - while (n-- > 0) - (void)new (ptr_ + size_++) T; -} - -template -T *NCVector::erase(const T *p1, const T *p2) -{ - // typedef T X; - for (const T *p = p1; p != p2; p++) - /* ((X *)p)->~X(); */ - p->~T(); - if (p2 != ptr_ + size_) - memmove((T *)p1, p2, ((const T *)(ptr_ + size_) - p2)*sizeof(T)); - size_ -= p2 - p1; - return (T *)p1; -} - -template -void NCVector::reserve1(size_t size) -{ - alloc_ *= 2; - if (size > alloc_) - alloc_ += size; - void *p = ::operator new(alloc_*sizeof(T)); - if (ptr_) { - memcpy(p, ptr_, size_*sizeof(T)); - ::operator delete((void *)ptr_); - } - ptr_ = (T *)p; -} - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* not NCVector_DEF_INCLUDED */ diff --git a/cde/programs/nsgmls/NCVector.h b/cde/programs/nsgmls/NCVector.h deleted file mode 100644 index 29f5a8152..000000000 --- a/cde/programs/nsgmls/NCVector.h +++ /dev/null @@ -1,84 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: NCVector.h /main/1 1996/07/29 16:58:13 cde-hp $ */ -// Copyright (c) 1994, 1996 James Clark -// See the file COPYING for copying permission. - -#ifndef NCVector_INCLUDED -#define NCVector_INCLUDED 1 - -#include -#include "xnew.h" - -// This offers a subset of the interface offered by the standard C++ -// vector class as defined in the Jan 96 WP. -// Code in SP currently assumes that size_type is size_t. - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -template -class NCVector { -public: - typedef size_t size_type; - typedef T *iterator; - typedef const T *const_iterator; - NCVector() : ptr_(0), size_(0), alloc_(0) { } - NCVector(size_t n) : ptr_(0), size_(0), alloc_(0) { append(n); } - ~NCVector(); - void resize(size_t n) { - if (n < size_) - erase(ptr_ + n, ptr_ + size_); - else if (n > size_) - append(n - size_); - } - void swap(NCVector &); - void clear() { erase(ptr_, ptr_ + size_); } - size_t size() const { return size_; } - T &operator[](size_t i) { return ptr_[i]; } - const T &operator[](size_t i) const { return ptr_[i]; } - iterator begin() { return ptr_; } - const_iterator begin() const { return ptr_; } - T &back() { return ptr_[size_ - 1]; } - const T &back() const { return ptr_[size_ - 1]; } - void reserve(size_t n) { if (n > alloc_) reserve1(n); } - iterator erase(const_iterator, const_iterator); -private: - void append(size_t); - void reserve1(size_t); - - size_t size_; - T *ptr_; - size_t alloc_; // allocated size -}; - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* not NCVector_INCLUDED */ - -#ifdef SP_DEFINE_TEMPLATES -#include "NCVector.C" -#endif diff --git a/cde/programs/nsgmls/NameToken.h b/cde/programs/nsgmls/NameToken.h deleted file mode 100644 index 9c8d5d94f..000000000 --- a/cde/programs/nsgmls/NameToken.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: NameToken.h /main/1 1996/07/29 16:58:18 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#ifndef NameToken_INCLUDED -#define NameToken_INCLUDED 1 - -#include "Location.h" -#include "StringC.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -struct NameToken { - StringC name; - StringC origName; - Location loc; -}; - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* not NameToken_INCLUDED */ diff --git a/cde/programs/nsgmls/Named.h b/cde/programs/nsgmls/Named.h deleted file mode 100644 index 3da5bb09b..000000000 --- a/cde/programs/nsgmls/Named.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: Named.h /main/1 1996/07/29 16:58:23 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#ifndef Named_INCLUDED -#define Named_INCLUDED 1 - -#include "StringC.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -#ifndef SP_API -#define SP_API /* as nothing */ -#endif - -class SP_API Named { -public: - Named(const StringC &name) : name_(name) { } - virtual ~Named() { } - const StringC &name() const { return name_; } - const StringC *namePointer() const { return &name_; } - void setName(const StringC &name) { name_ = name; } - void swap(Named &to) { name_.swap(to.name_); } -private: - StringC name_; -}; - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* not Named_INCLUDED */ diff --git a/cde/programs/nsgmls/NamedResource.h b/cde/programs/nsgmls/NamedResource.h deleted file mode 100644 index 8a2b65732..000000000 --- a/cde/programs/nsgmls/NamedResource.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: NamedResource.h /main/1 1996/07/29 16:58:28 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#ifndef NamedResource_INCLUDED -#define NamedResource_INCLUDED 1 - -#include "Named.h" -#include "Resource.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -class SP_API NamedResource : public Named, public Resource { -public: - NamedResource(const StringC &str) : Named(str) { } -}; - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* not NamedResource_INCLUDED */ diff --git a/cde/programs/nsgmls/NamedResourceTable.h b/cde/programs/nsgmls/NamedResourceTable.h deleted file mode 100644 index 4262a4185..000000000 --- a/cde/programs/nsgmls/NamedResourceTable.h +++ /dev/null @@ -1,117 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: NamedResourceTable.h /main/1 1996/07/29 16:58:33 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#ifndef NamedResourceTable_INCLUDED -#define NamedResourceTable_INCLUDED 1 - -#include "NamedResource.h" -#include "PointerTable.h" -#include "StringC.h" -#include "Hash.h" -#include "Ptr.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -struct NamedResourceKeyFunction { - static inline - const StringC &key(const NamedResource &p) { - return p.name(); - } -}; - -template class NamedResourceTableIter; -template class ConstNamedResourceTableIter; - -template -class NamedResourceTable { -#ifdef __lucid - struct X { - Ptr _X; // work around lcc bug - }; -#endif -public: - NamedResourceTable() { } - Ptr insert(const Ptr &p, Boolean replace = 0) { - return (T *)table_.insert((NamedResource *)p.pointer(), replace).pointer(); - } - Ptr lookup(const StringC &str) const { - return (T *)table_.lookup(str).pointer(); - } - ConstPtr lookupConst(const StringC &str) const { - return (T *)table_.lookup(str).pointer(); - } - const T *lookupTemp(const StringC &str) const { - return (const T *)table_.lookup(str).pointer(); - } - Ptr remove(const StringC &str) { - return (T *)table_.remove(str).pointer(); - } - size_t count() const { return table_.count(); } - void clear() { table_.clear(); } - void swap(NamedResourceTable &to) { table_.swap(to.table_); } -private: - PointerTable, StringC, Hash, - NamedResourceKeyFunction> table_; - friend class NamedResourceTableIter; - friend class ConstNamedResourceTableIter; -}; - -template -class NamedResourceTableIter { -public: - NamedResourceTableIter(const NamedResourceTable &table) - : iter_(table.table_) { } - Ptr next() { - return (T *)iter_.next().pointer(); - } -private: - PointerTableIter, StringC, Hash, - NamedResourceKeyFunction> iter_; -}; - -template -class ConstNamedResourceTableIter { -public: - ConstNamedResourceTableIter(const NamedResourceTable &table) - : iter_(table.table_) { } - ConstPtr next() { - return (T *)iter_.next().pointer(); - } - const T *nextTemp() { - return (const T *)iter_.next().pointer(); - } -private: - PointerTableIter, StringC, Hash, - NamedResourceKeyFunction> iter_; -}; - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* not NamedResourceTable_INCLUDED */ diff --git a/cde/programs/nsgmls/NamedTable.h b/cde/programs/nsgmls/NamedTable.h deleted file mode 100644 index 16871ee64..000000000 --- a/cde/programs/nsgmls/NamedTable.h +++ /dev/null @@ -1,88 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: NamedTable.h /main/2 1996/08/13 10:09:04 mgreess $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#ifndef NamedTable_INCLUDED -#define NamedTable_INCLUDED 1 - -#include "Hash.h" -#include "StringC.h" -#include "Named.h" -#include "OwnerTable.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -class NamedTableKeyFunction { -public: - static inline const StringC &key(const Named &obj) { return obj.name(); } -}; - -template class NamedTableIter; -template class ConstNamedTableIter; - -template -class NamedTable { -public: - NamedTable() { } - T *insert(T *p) { return (T *)table_.insert(p); } - T *lookup(const StringC &str) const { return (T *)table_.lookup(str); } - T *remove(const StringC &str) { return (T *)table_.remove(str); } - size_t count() const { return table_.count(); } - void clear() { table_.clear(); } - void swap(NamedTable &to) { table_.swap(to.table_); } -private: - NamedTable(const NamedTable &) {} - void operator=(const NamedTable &) {} - OwnerTable - table_; - friend class NamedTableIter; - friend class ConstNamedTableIter; -}; - -template -class NamedTableIter { -public: - NamedTableIter(const NamedTable &table) : iter_(table.table_) { } - T *next() { return (T *)iter_.next(); } -private: - OwnerTableIter iter_; -}; - -template -class ConstNamedTableIter { -public: - ConstNamedTableIter(const NamedTable &table) : iter_(table.table_) { } - const T *next() { return (T *)iter_.next(); } -private: - OwnerTableIter iter_; -}; - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* not NamedTable_INCLUDED */ diff --git a/cde/programs/nsgmls/Notation.C b/cde/programs/nsgmls/Notation.C deleted file mode 100644 index 983e35ae0..000000000 --- a/cde/programs/nsgmls/Notation.C +++ /dev/null @@ -1,84 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: Notation.C /main/1 1996/07/29 16:58:43 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#ifdef __GNUG__ -#pragma implementation -#endif -#include "splib.h" -#include "Notation.h" -#include "ParserState.h" -#include "Sd.h" -#include "Syntax.h" -#include "MessageArg.h" -#include "ParserMessages.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -Notation::Notation(const StringC &name, - const ConstPtr > &dtdName, - Boolean dtdIsBase) -: EntityDecl(name, notation, ndata, Location()), defined_(0) -{ - setDeclIn(dtdName, dtdIsBase); -} - -void Notation::setExternalId(const ExternalId &id, const Location &defLocation) -{ - externalId_ = id; - defined_ = 1; - setDefLocation(defLocation); -} - -void Notation::generateSystemId(ParserState &parser) -{ - StringC str; - if (parser.entityCatalog().lookup(*this, - parser.syntax(), - parser.sd().docCharset(), - parser.messenger(), - str)) - externalId_.setEffectiveSystem(str); - else if (parser.options().warnNotationSystemId) - parser.message(ParserMessages::cannotGenerateSystemIdNotation, - StringMessageArg(name())); -} - -const StringC *Notation::systemIdPointer() const -{ - return externalId_.systemIdString(); -} - -const StringC *Notation::publicIdPointer() const -{ - return externalId_.publicIdString(); -} - - -#ifdef SP_NAMESPACE -} -#endif diff --git a/cde/programs/nsgmls/Notation.h b/cde/programs/nsgmls/Notation.h deleted file mode 100644 index 4cfb0b3e4..000000000 --- a/cde/programs/nsgmls/Notation.h +++ /dev/null @@ -1,84 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: Notation.h /main/1 1996/07/29 16:58:47 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#ifndef Notation_INCLUDED -#define Notation_INCLUDED 1 -#ifdef __GNUG__ -#pragma interface -#endif - -#include "Owner.h" -#include "StringC.h" -#include "NamedResource.h" -#include "types.h" -#include "Ptr.h" -#include "ExternalId.h" -#include "Boolean.h" -#include "Attributed.h" -#include "StringResource.h" -#include "EntityDecl.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -class ParserState; - -class SP_API Notation : public EntityDecl, public Attributed { -public: - Notation(const StringC &, - const ConstPtr > &dtdName, - Boolean dtdIsBase); - void setExternalId(const ExternalId &, const Location &); - const ExternalId &externalId() const; - Boolean defined() const; - void generateSystemId(ParserState &); - const StringC *systemIdPointer() const; - const StringC *publicIdPointer() const; -private: - Notation(const Notation &); // undefined - void operator=(const Notation &); // undefined - PackedBoolean defined_; - ExternalId externalId_; -}; - -inline -const ExternalId &Notation::externalId() const -{ - return externalId_; -} - -inline -Boolean Notation::defined() const -{ - return defined_; -} - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* not Notation_INCLUDED */ diff --git a/cde/programs/nsgmls/NsgmlsMessages.h b/cde/programs/nsgmls/NsgmlsMessages.h deleted file mode 100644 index cabb5a781..000000000 --- a/cde/programs/nsgmls/NsgmlsMessages.h +++ /dev/null @@ -1,77 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: NsgmlsMessages.h /main/1 1996/07/29 16:58:51 cde-hp $ */ -// This file was automatically generated from NsgmlsMessages.msg by msggen.pl. -#include "Message.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -struct NsgmlsMessages { - // 0 - static const MessageType2 cannotOpenOutputError; - // 1 - static const MessageType2 closeOutputError; - // 2 - static const MessageType1 unknownOutputOption; -}; -const MessageType2 NsgmlsMessages::cannotOpenOutputError( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -0 -#ifndef SP_NO_MESSAGE_TEXT -,"cannot open output file %1 (%2)" -#endif -); -const MessageType2 NsgmlsMessages::closeOutputError( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -1 -#ifndef SP_NO_MESSAGE_TEXT -,"error closing output file %1 (%2)" -#endif -); -const MessageType1 NsgmlsMessages::unknownOutputOption( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -2 -#ifndef SP_NO_MESSAGE_TEXT -,"unknown output option %1" -#endif -); -#ifdef SP_NAMESPACE -} -#endif diff --git a/cde/programs/nsgmls/NumericCharRefOrigin.C b/cde/programs/nsgmls/NumericCharRefOrigin.C deleted file mode 100644 index f74659362..000000000 --- a/cde/programs/nsgmls/NumericCharRefOrigin.C +++ /dev/null @@ -1,65 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: NumericCharRefOrigin.C /main/1 1996/07/29 16:58:56 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#ifdef __GNUG__ -#pragma implementation -#endif -#include "splib.h" -#include "NumericCharRefOrigin.h" -#include "Markup.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -NumericCharRefOrigin::NumericCharRefOrigin(const Location &start, - Index refLength, - Owner &markup) -: start_(start), refLength_(refLength) -{ - markup.swap(markup_); -} - -const Location &NumericCharRefOrigin::parent() const -{ - return start_; -} - -Index NumericCharRefOrigin::refLength() const -{ - return refLength_; -} - -Boolean NumericCharRefOrigin::isNumericCharRef(const Markup *&markup) const -{ - markup = markup_.pointer(); - return 1; -} - - -#ifdef SP_NAMESPACE -} -#endif diff --git a/cde/programs/nsgmls/NumericCharRefOrigin.h b/cde/programs/nsgmls/NumericCharRefOrigin.h deleted file mode 100644 index 6d533697c..000000000 --- a/cde/programs/nsgmls/NumericCharRefOrigin.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: NumericCharRefOrigin.h /main/1 1996/07/29 16:59:01 cde-hp $ */ -#ifndef NumericCharRefOrigin_INCLUDED -#define NumericCharRefOrigin_INCLUDED 1 - -#ifdef __GNUG__ -#pragma interface -#endif - -#include "Location.h" -#include "Markup.h" -#include "Owner.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -class NumericCharRefOrigin : public Origin { -public: - NumericCharRefOrigin(const Location &start, Index endIndex, - Owner &markup); - const Location &parent() const; - Index refLength() const; - Boolean isNumericCharRef(const Markup *&) const; -private: - NumericCharRefOrigin(const NumericCharRefOrigin &); // undefined - void operator=(const NumericCharRefOrigin &); // undefined - Location start_; - Index refLength_; - Owner markup_; -}; - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* not NumericCharRefOrigin_INCLUDED */ diff --git a/cde/programs/nsgmls/OffsetOrderedList.C b/cde/programs/nsgmls/OffsetOrderedList.C deleted file mode 100644 index 19051482e..000000000 --- a/cde/programs/nsgmls/OffsetOrderedList.C +++ /dev/null @@ -1,152 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: OffsetOrderedList.C /main/1 1996/07/29 16:59:05 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#include "splib.h" -#include "OffsetOrderedList.h" -#include "macros.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -OffsetOrderedList::OffsetOrderedList() -: blockUsed_(OffsetOrderedListBlock::size) -{ -} - -void OffsetOrderedList::append(Offset offset) -{ - // At any position in the list there's a current offset. - // The offset is initially zero. - // A byte of 255 says add 255 to the current offset. - // A byte B < 255, says that there's an item in the list whose - // offset is the current offset + B, and that B + 1 should be - // added to the current offset. - Offset curOffset = blocks_.size() > 0 ? blocks_.back()->offset : 0; - ASSERT(offset >= curOffset); - Offset count = offset - curOffset; - while (count >= 255) { - addByte(255); - count -= 255; - } - addByte(count); -} - -void OffsetOrderedList::addByte(unsigned char b) -{ - if (blockUsed_ >= OffsetOrderedListBlock::size) { - blocks_.resize(blocks_.size() + 1); - Owner &last = blocks_.back(); - last = new OffsetOrderedListBlock; - if (blocks_.size() == 1) { - last->nextIndex = 0; - last->offset = 0; - } - else { - OffsetOrderedListBlock &lastButOne = *blocks_[blocks_.size() - 2]; - last->nextIndex = lastButOne.nextIndex; - last->offset = lastButOne.offset; - } - blockUsed_ = 0; - } - blocks_.back()->bytes[blockUsed_++] = b; - if (b == 255) - blocks_.back()->offset += 255; - else { - blocks_.back()->offset += b + 1; - blocks_.back()->nextIndex += 1; - } -} - -// Find the last offset <= off. - -Boolean OffsetOrderedList::findPreceding(Offset off, - size_t &foundIndex, - Offset &foundOffset) const -{ - // Invariant: - // blocks with index < i have offset <= off - // blocks with index >= lim have offset > off - size_t i = 0; - size_t lim = blocks_.size(); - // Most commonly we'll want to know the about positions near the end, - // so optimize this case. - if (lim > 0 && blocks_[lim - 1]->offset <= off) - i = lim; - else if (lim > 1 && blocks_[lim - 2]->offset <= off) - i = lim - 1; - else { - // Do a binary search. - while (i < lim) { - size_t mid = i + (lim - i)/2; - if (blocks_[mid]->offset > off) - lim = mid; - else - i = mid + 1; - } - } - if (i == blocks_.size()) { - if (i == 0) - return 0; - foundIndex = blocks_.back()->nextIndex - 1; - foundOffset = blocks_.back()->offset - 1; - return 1; - } - // Note that an item with offset X can only occur in a block with offset > X - // i is now the first block with offset > off - Offset curOff = blocks_[i]->offset; - size_t curIndex = blocks_[i]->nextIndex; - const unsigned char *bytes = blocks_[i]->bytes; - int j = (i == blocks_.size() - 1 - ? blockUsed_ - : int(OffsetOrderedListBlock::size)); - for (;;) { - j--; - if (bytes[j] != 255) { - curIndex -= 1; - curOff -= 1; - if (curOff <= off) - break; - } - curOff -= bytes[j]; - if (j == 0) { - if (i == 0) - return 0; - i--; - j = OffsetOrderedListBlock::size; - curOff = blocks_[i]->offset; - curIndex = blocks_[i]->nextIndex; - bytes = blocks_[i]->bytes; - } - } - foundIndex = curIndex; - foundOffset = curOff; - return 1; -} - -#ifdef SP_NAMESPACE -} -#endif diff --git a/cde/programs/nsgmls/OffsetOrderedList.h b/cde/programs/nsgmls/OffsetOrderedList.h deleted file mode 100644 index 2984b91ae..000000000 --- a/cde/programs/nsgmls/OffsetOrderedList.h +++ /dev/null @@ -1,76 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: OffsetOrderedList.h /main/1 1996/07/29 16:59:10 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#ifndef OffsetOrderedList_INCLUDED -#define OffsetOrderedList_INCLUDED 1 - -#include "types.h" -#include "Owner.h" -#include "NCVector.h" -#include "Boolean.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -struct OffsetOrderedListBlock { - Offset offset; // next Offset - size_t nextIndex; // index of first item in next block - enum { size = 200 }; - unsigned char bytes[size]; -}; - -// This is an ordered list of Offsets with no duplicates. - -class OffsetOrderedList { -public: - OffsetOrderedList(); - // off must be > the last offset added. - void append(Offset off); - // Find the last offset in the list <= off. - Boolean findPreceding(Offset off, size_t &foundIndex, Offset &foundOffset) - const; - size_t size() const; -private: - OffsetOrderedList(const OffsetOrderedList &); // undefined - void operator=(const OffsetOrderedList &); // undefined - void addByte(unsigned char b); - // bytes used in current block - int blockUsed_; - NCVector > blocks_; -}; - -inline -size_t OffsetOrderedList::size() const -{ - return blocks_.size() == 0 ? 0 : blocks_.back()->nextIndex; -} - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* not OffsetOrderedList_INCLUDED */ diff --git a/cde/programs/nsgmls/OpenElement.C b/cde/programs/nsgmls/OpenElement.C deleted file mode 100644 index 5861a9663..000000000 --- a/cde/programs/nsgmls/OpenElement.C +++ /dev/null @@ -1,54 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: OpenElement.C /main/1 1996/07/29 16:59:15 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#ifdef __GNUG__ -#pragma implementation -#endif -#include "splib.h" -#include "OpenElement.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -OpenElement::OpenElement(const ElementType *type, - Boolean net, - Boolean included, - const ShortReferenceMap *map, - const Location &startLocation) -: elementType_(type), - netEnabling_(net), - included_(included), - matchState_(type->definition()->compiledModelGroup()), - map_(map), - startLocation_(startLocation), - declaredContent_(type->definition()->declaredContent()) -{ -} - -#ifdef SP_NAMESPACE -} -#endif diff --git a/cde/programs/nsgmls/OpenElement.h b/cde/programs/nsgmls/OpenElement.h deleted file mode 100644 index 36b19573d..000000000 --- a/cde/programs/nsgmls/OpenElement.h +++ /dev/null @@ -1,217 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: OpenElement.h /main/1 1996/07/29 16:59:20 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#ifndef OpenElement_INCLUDED -#define OpenElement_INCLUDED 1 -#ifdef __GNUG__ -#pragma interface -#endif - -#include "Boolean.h" -#include "ContentToken.h" -#include "ElementType.h" -#include "Link.h" -#include "Mode.h" -#include "Allocator.h" -#include "Location.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -class SP_API OpenElement : public Link { -public: - void *operator new(size_t sz, Allocator &alloc) { return alloc.alloc(sz); } - void *operator new(size_t sz) { return Allocator::allocSimple(sz); } - void operator delete(void *p) { Allocator::free(p); } - OpenElement(const ElementType *, Boolean net, Boolean included, - const ShortReferenceMap *currentMap, - const Location &startLocation); - Boolean isFinished() const; - Boolean tryTransition(const ElementType *); - const LeafContentToken *invalidExclusion(const ElementType *) const; - // This doesn't handle declared content of EMPTY. - // If this situation can arise must use declaredEmpty(). - Boolean tryTransitionPcdata(); - const LeafContentToken *impliedStartTag() const; - void doRequiredTransition(); - const ElementType *type() const; - Boolean netEnabling() const; - Boolean included() const; - const MatchState &matchState() const; - void setMatchState(const MatchState &); - Mode mode(Boolean netEnabled) const; - const ShortReferenceMap *map() const; - void setMap(const ShortReferenceMap *); - Boolean requiresSpecialParse() const; - const Location &startLocation() const; - const LeafContentToken *currentPosition() const; - Boolean declaredEmpty() const; - void setConref(); -private: - OpenElement(const OpenElement &); // undefined - void operator=(const OpenElement &); // undefined - const ElementType *elementType_; - PackedBoolean netEnabling_; // start-tag was net-enabling - PackedBoolean included_; - MatchState matchState_; - ElementDefinition::DeclaredContent declaredContent_; - const ShortReferenceMap *map_; - Location startLocation_; -}; - -inline -const ElementType *OpenElement::type() const -{ - return elementType_; -} - -inline -Boolean OpenElement::netEnabling() const -{ - return netEnabling_; -} - -inline -Boolean OpenElement::included() const -{ - return included_; -} - -inline -const MatchState &OpenElement::matchState() const -{ - return matchState_; -} - -inline -void OpenElement::setMatchState(const MatchState &state) -{ - matchState_ = state; -} - -inline -Boolean OpenElement::isFinished() const -{ - return (declaredContent_ != ElementDefinition::modelGroup - || matchState_.isFinished()); -} - -inline -Boolean OpenElement::tryTransition(const ElementType *e) -{ - return (declaredContent_ == ElementDefinition::modelGroup - ? matchState_.tryTransition(e) - : (declaredContent_ == ElementDefinition::any)); -} - -inline -Boolean OpenElement::tryTransitionPcdata() -{ - return (declaredContent_ == ElementDefinition::modelGroup - ? matchState_.tryTransitionPcdata() - : 1); // CDATA, RCDATA, ANY all ok -} - -inline -const LeafContentToken *OpenElement::invalidExclusion(const ElementType *e) - const -{ - return (declaredContent_ == ElementDefinition::modelGroup - ? matchState_.invalidExclusion(e) - : 0); -} - -inline -void OpenElement::doRequiredTransition() -{ - matchState_.doRequiredTransition(); -} - -inline -const LeafContentToken *OpenElement::impliedStartTag() const -{ - return (declaredContent_ == ElementDefinition::modelGroup - ? matchState_.impliedStartTag() - : 0); -} - -inline -const ShortReferenceMap *OpenElement::map() const -{ - return map_; -} - -inline -void OpenElement::setMap(const ShortReferenceMap *map) -{ - map_ = map; -} - -inline -Boolean OpenElement::requiresSpecialParse() const -{ - return (declaredContent_ == ElementDefinition::cdata - || declaredContent_ == ElementDefinition::rcdata); -} - -inline -Mode OpenElement::mode(Boolean netEnabled) const -{ - return elementType_->definition()->mode(netEnabled); -} - -inline -const Location &OpenElement::startLocation() const -{ - return startLocation_; -} - -inline -const LeafContentToken *OpenElement::currentPosition() const -{ - return (declaredContent_ == ElementDefinition::modelGroup - ? matchState_.currentPosition() - : 0); -} - -inline -Boolean OpenElement::declaredEmpty() const -{ - return declaredContent_ == ElementDefinition::empty; -} - -inline -void OpenElement::setConref() -{ - declaredContent_ = ElementDefinition::empty; -} - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* not OpenElement_INCLUDED */ diff --git a/cde/programs/nsgmls/Options.C b/cde/programs/nsgmls/Options.C deleted file mode 100644 index 162f106f5..000000000 --- a/cde/programs/nsgmls/Options.C +++ /dev/null @@ -1,145 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: Options.C /main/1 1996/07/29 16:59:26 cde-hp $ */ -// Derived from comp.sources.unix/volume3/att_getopt. - -#ifndef Options_DEF_INCLUDED -#define Options_DEF_INCLUDED 1 - -#ifndef OPTION_CHAR -#define OPTION_CHAR T('-') -#endif - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -template -Options::Options(int argc, T *const *argv, const T *opts) -: argc_(argc), argv_(argv), opts_(opts), ind_(1), sp_(1) -{ -} - -template -const T *Options::search(T c) const -{ - for (const T *s = opts_; *s; s++) - if (*s == c) - return s; - return 0; -} - -template -bool Options::get(T &c) -{ - const T *cp; - if (sp_ == 1) { - if (ind_ >= argc_) - return false; - if (( -#ifdef OTHER_OPTION_CHAR - argv_[ind_][0] != OTHER_OPTION_CHAR && -#endif - argv_[ind_][0] != OPTION_CHAR) || argv_[ind_][1] == 0) { -#ifdef REORDER_ARGS - int i; - for (i = ind_; i < argc_; i++) - if (( -#ifdef OTHER_OPTION_CHAR - argv_[i][0] == OTHER_OPTION_CHAR || -#endif - argv_[i][0] == OPTION_CHAR) && argv_[i][1] != 0) - break; - if (i < argc_) { - c = argv_[i][1]; - if (c != T(':') && c != OPTION_CHAR - && (cp = search(c)) != 0 - && cp[1] == T(':') && argv_[i][2] == 0 && i < argc_ - 1) { - int j; - T *temp1 = argv_[i]; - T *temp2 = argv_[i + 1]; - for (j = i - 1; j >= ind_; j--) - argv_[j+2] = argv_[j]; - argv_[ind_] = temp1; - argv_[ind_ + 1] = temp2; - } - else { - int j; - T *temp = argv_[i]; - for (j = i - 1; j >= ind_; j--) - argv_[j+1] = argv_[j]; - argv_[ind_] = temp; - } - } - else -#endif - return false; - } - if ((argv_[ind_][0] == OPTION_CHAR && argv_[ind_][1] == OPTION_CHAR - && argv_[ind_][2] == 0) -#ifdef OTHER_OPTION_CHAR - || (argv_[ind_][0] == OTHER_OPTION_CHAR - && argv_[ind_][1] == OTHER_OPTION_CHAR - && argv_[ind_][2] == 0) -#endif - ) { - ind_++; - return false; - } - } - opt_ = c = argv_[ind_][sp_]; - if (c == T(':') || (cp = search(c)) == 0) { - if (argv_[ind_][++sp_] == 0) { - ind_++; - sp_ = 1; - } - c = T('?'); - return true; - } - if (*++cp == T(':')) { - if (argv_[ind_][sp_ + 1] != 0) - arg_ = &argv_[ind_++][sp_ + 1]; - else if (++ind_ >= argc_) { - sp_ = 1; - c = (*opts_ == T(':') ? T(':') : T('?')); - return true; - } - else - arg_ = argv_[ind_++]; - sp_ = 1; - } - else { - if (argv_[ind_][++sp_] == 0) { - sp_ = 1; - ind_++; - } - arg_ = 0; - } - return true; -} - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* not Options_DEF_INCLUDED */ diff --git a/cde/programs/nsgmls/Options.h b/cde/programs/nsgmls/Options.h deleted file mode 100644 index c8389cac4..000000000 --- a/cde/programs/nsgmls/Options.h +++ /dev/null @@ -1,67 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: Options.h /main/1 1996/07/29 16:59:30 cde-hp $ */ -// Copyright (c) 1996 James Clark -// See the file COPYING for copying permission. - -#ifndef Options_INCLUDED -#define Options_INCLUDED 1 - -#include "Boolean.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -// This is a mildly C++ified version of getopt(). -// It never prints any message. - -template -class Options { -public: - Options(int argc, T *const *, const T *); - // Returns false if there are no more options. - bool get(T &); - T *arg() const { return arg_; } // optarg - T opt() const { return opt_; } // optopt - int ind() const { return ind_; } // optind -private: - const T *search(T) const; - const T *opts_; - T *const *argv_; - int argc_; - int ind_; - T opt_; - T *arg_; - int sp_; -}; - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* not Options_INCLUDED */ - -#ifdef SP_DEFINE_TEMPLATES -#include "Options.C" -#endif diff --git a/cde/programs/nsgmls/OutputCharStream.C b/cde/programs/nsgmls/OutputCharStream.C deleted file mode 100644 index ed5c97d6f..000000000 --- a/cde/programs/nsgmls/OutputCharStream.C +++ /dev/null @@ -1,277 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: OutputCharStream.C /main/1 1996/07/29 16:59:34 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#include "splib.h" -#include "OutputCharStream.h" -#include "CodingSystem.h" -#include "macros.h" -#if defined(__linux__) || defined(CSRG_BASED) || defined(sun) -#include -#else -#include -#endif -#include - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -OutputCharStream::OutputCharStream() -: ptr_(0), end_(0), escaper_(0) -{ -} - -OutputCharStream::~OutputCharStream() -{ -} - -OutputCharStream &OutputCharStream::write(const Char *s, size_t n) -{ - for (;;) { - size_t spare = end_ - ptr_; - if (n <= spare) { - memcpy(ptr_, s, n*sizeof(Char)); - ptr_ += n; - break; - } - if (spare > 0) { - memcpy(ptr_, s, spare*sizeof(Char)); - ptr_ += spare; - s += spare; - n -= spare; - } - n--; - flushBuf(*s++); - } - return *this; -} - -OutputCharStream &OutputCharStream::operator<<(const char *s) -{ - while (*s) - put(*s++); - return *this; -} - -// FIXME Avoid stdio - -OutputCharStream &OutputCharStream::operator<<(unsigned long n) -{ - char buf[sizeof(unsigned long)*3 + 1]; - sprintf(buf, "%lu", n); - return *this << buf; -} - -OutputCharStream &OutputCharStream::operator<<(int n) -{ - char buf[sizeof(int)*3 + 2]; - sprintf(buf, "%d", n); - return *this << buf; -} - - -IosOutputCharStream::IosOutputCharStream() -: buf_(0), byteStream_(0), encoder_(NULL) -{ -} - -IosOutputCharStream::IosOutputCharStream(streambuf *byteStream, - const OutputCodingSystem *codingSystem) -: buf_(0), - byteStream_(byteStream), - ownedEncoder_(codingSystem->makeEncoder()) -{ - encoder_ = ownedEncoder_.pointer(); - encoder_->setUnencodableHandler(this); - allocBuf(codingSystem->fixedBytesPerChar()); - encoder_->startFile(byteStream_); -} - -IosOutputCharStream::IosOutputCharStream(streambuf *byteStream, - Encoder *encoder) -: buf_(0), - byteStream_(byteStream), - encoder_(encoder) -{ - allocBuf(0); -} - -IosOutputCharStream::~IosOutputCharStream() -{ - if (byteStream_) - flush(); - delete [] buf_; -} - -void IosOutputCharStream::open(streambuf *byteStream, - const OutputCodingSystem *codingSystem) -{ - if (byteStream_) - flush(); - byteStream_ = byteStream; - ownedEncoder_ = codingSystem->makeEncoder(); - encoder_ = ownedEncoder_.pointer(); - encoder_->setUnencodableHandler(this); - delete [] buf_; - buf_ = 0; - ptr_ = end_ = buf_; - allocBuf(codingSystem->fixedBytesPerChar()); - encoder_->startFile(byteStream_); -} - -void IosOutputCharStream::flush() -{ - if (ptr_ > buf_) { - encoder_->output(buf_, ptr_ - buf_, byteStream_); - ptr_ = buf_; - } -#if defined(__linux__) || defined(CSRG_BASED) || defined(sun) - byteStream_->pubsync(); -#else - byteStream_->sync(); -#endif -} - -void IosOutputCharStream::flushBuf(Char c) -{ - ASSERT(buf_ != 0); - encoder_->output(buf_, ptr_ - buf_, byteStream_); - ptr_ = buf_; - *ptr_++ = c; -} - -void IosOutputCharStream::allocBuf(int bytesPerChar) -{ - const int blockSize = 1024; - size_t bufSize = bytesPerChar ? blockSize/bytesPerChar : blockSize; - ptr_ = buf_ = new Char[bufSize]; - end_ = buf_ + bufSize; -} - -void IosOutputCharStream::handleUnencodable(Char c, streambuf *) -{ - IosOutputCharStream tem(byteStream_, encoder_); - escape(tem, c); -} - -StrOutputCharStream::StrOutputCharStream() -: buf_(0), bufSize_(0) -{ - sync(0); -} - -StrOutputCharStream::~StrOutputCharStream() -{ - delete [] buf_; -} - -void StrOutputCharStream::extractString(StringC &str) -{ - str.assign(buf_, ptr_ - buf_); - sync(0); -} - -void StrOutputCharStream::flushBuf(Char c) -{ - size_t used = ptr_ - buf_; - size_t oldSize = bufSize_; - bufSize_ = oldSize ? 2*oldSize : 10; - Char *oldBuf = buf_; - buf_ = new Char[bufSize_]; - if (oldSize) { - memcpy(buf_, oldBuf, oldSize * sizeof(Char)); - delete [] oldBuf; - } - sync(used); - *ptr_++ = c; -} - -void StrOutputCharStream::flush() -{ -} - -void StrOutputCharStream::sync(size_t length) -{ - ptr_ = buf_ + length; - end_ = buf_ + bufSize_; -} - -RecordOutputCharStream::RecordOutputCharStream(OutputCharStream *os) -: os_(os) -{ - ptr_ = buf_; - end_ = buf_ + bufSize_; -} - -RecordOutputCharStream::~RecordOutputCharStream() -{ - outputBuf(); - delete os_; -} - -void RecordOutputCharStream::flush() -{ - outputBuf(); - os_->flush(); -} - -void RecordOutputCharStream::flushBuf(Char c) -{ - outputBuf(); - *ptr_++ = c; -} - -void RecordOutputCharStream::outputBuf() -{ - Char *start = buf_; - Char *p = start; - while (p < ptr_) { - switch (*p) { - case '\r': // translate RE to newline - if (start < p) - os_->write(start, p - start); - start = ++p; - *os_ << newline; - break; - case '\n': // ignore RS - if (start < p) - os_->write(start, p - start); - start = ++p; - break; - default: - ++p; - break; - } - } - if (start < p) - os_->write(start, p - start); - ptr_ = buf_; - end_ = buf_ + bufSize_; -} - -#ifdef SP_NAMESPACE -} -#endif diff --git a/cde/programs/nsgmls/OutputCharStream.h b/cde/programs/nsgmls/OutputCharStream.h deleted file mode 100644 index f1c9bd3e3..000000000 --- a/cde/programs/nsgmls/OutputCharStream.h +++ /dev/null @@ -1,177 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: OutputCharStream.h /main/1 1996/07/29 16:59:39 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#ifndef OutputCharStream_INCLUDED -#define OutputCharStream_INCLUDED 1 - -#include "types.h" -#include -#include "StringC.h" -#include "Owner.h" -#include "CodingSystem.h" - -#if defined(__linux__) || defined(CSRG_BASED) || defined(sun) -#include -using namespace std; -#else -class streambuf; -#endif - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -class SP_API OutputCharStream { -public: - enum Newline { newline }; - typedef void (*Escaper)(OutputCharStream &, Char); - OutputCharStream(); - virtual ~OutputCharStream(); - OutputCharStream &put(Char); - OutputCharStream &write(const Char *, size_t); - virtual void flush() = 0; - void setEscaper(Escaper); - - OutputCharStream &operator<<(char); - OutputCharStream &operator<<(const char *); - OutputCharStream &operator<<(const StringC &); - OutputCharStream &operator<<(unsigned long); - OutputCharStream &operator<<(int); - OutputCharStream &operator<<(Newline); -private: - OutputCharStream(const OutputCharStream &); // undefined - void operator=(const OutputCharStream &); // undefined - - virtual void flushBuf(Char) = 0; - Escaper escaper_; -protected: - void escape(OutputCharStream &, Char c); - Char *ptr_; - Char *end_; -}; - -class SP_API IosOutputCharStream : public OutputCharStream, - private Encoder::Handler { -public: - IosOutputCharStream(); - // the streambuf will not be deleted - IosOutputCharStream(streambuf *, const OutputCodingSystem *); - ~IosOutputCharStream(); - void open(streambuf *, const OutputCodingSystem *); - void flush(); -private: - IosOutputCharStream(const IosOutputCharStream &); // undefined - void operator=(const IosOutputCharStream &); // undefined - IosOutputCharStream(streambuf *, Encoder *); - void allocBuf(int bytesPerChar); - void flushBuf(Char); - void handleUnencodable(Char c, streambuf *); - Char *buf_; - streambuf *byteStream_; - Encoder *encoder_; - Owner ownedEncoder_; -}; - -class SP_API StrOutputCharStream : public OutputCharStream { -public: - StrOutputCharStream(); - ~StrOutputCharStream(); - void extractString(StringC &); - void flush(); -private: - void flushBuf(Char); - void sync(size_t); - StrOutputCharStream(const StrOutputCharStream &); // undefined - void operator=(const StrOutputCharStream &); // undefined - Char *buf_; - size_t bufSize_; -}; - -class SP_API RecordOutputCharStream : public OutputCharStream { -public: - RecordOutputCharStream(OutputCharStream *); - ~RecordOutputCharStream(); - void flush(); -private: - RecordOutputCharStream(const RecordOutputCharStream &); // undefined - void operator=(const RecordOutputCharStream &); // undefined - void flushBuf(Char); - void outputBuf(); - - OutputCharStream *os_; - enum { bufSize_ = 1024 }; - Char buf_[bufSize_]; -}; - -inline -OutputCharStream &OutputCharStream::put(Char c) -{ - if (ptr_ < end_) - *ptr_++ = c; - else - flushBuf(c); - return *this; -} - -inline -OutputCharStream &OutputCharStream::operator<<(char c) -{ - return put(Char(c)); -} - -inline -OutputCharStream &OutputCharStream::operator<<(Newline) -{ -#ifdef SP_HAVE_SETMODE - put(Char('\r')); -#endif - return put(Char('\n')); -} - -inline -OutputCharStream &OutputCharStream::operator<<(const StringC &str) -{ - return write(str.data(), str.size()); -} - -inline -void OutputCharStream::setEscaper(Escaper f) -{ - escaper_ = f; -} - -inline -void OutputCharStream::escape(OutputCharStream &s, Char c) -{ - if (escaper_) - (*escaper_)(s, c); -} - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* not OutputCharStream_INCLUDED */ diff --git a/cde/programs/nsgmls/OutputState.C b/cde/programs/nsgmls/OutputState.C deleted file mode 100644 index 80e81b681..000000000 --- a/cde/programs/nsgmls/OutputState.C +++ /dev/null @@ -1,155 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: OutputState.C /main/1 1996/07/29 16:59:44 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#ifdef __GNUG__ -#pragma implementation -#endif -#include "splib.h" -#include "OutputState.h" -#include "Event.h" -#include "Allocator.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -OutputState::OutputState() -: re_(0) -{ - init(); -} - -void OutputState::init() -{ - nextSerial_ = 0; - stack_.clear(); - stack_.insert(new OutputStateLevel); -} - -OutputStateLevel::OutputStateLevel() -: state(OutputState::afterStartTag), reSerial(0) -{ -} - -void OutputState::handleRe(EventHandler &handler, Allocator &alloc, - const EventsWanted &eventsWanted, Char re, - const Location &location) -{ - re_ = re; - if (eventsWanted.wantInstanceMarkup()) - handler.reOrigin(new (alloc) ReOriginEvent(re_, location, nextSerial_)); - switch (top().state) { - case afterStartTag: - // it's the first RE in the element - if (eventsWanted.wantInstanceMarkup()) - handler.ignoredRe(new (alloc) IgnoredReEvent(re_, location, nextSerial_++)); - top().state = afterRsOrRe; - break; - case afterRsOrRe: - case afterData: - top().state = pendingAfterRsOrRe; - top().reLocation = location; - top().reSerial = nextSerial_++; - break; - case pendingAfterRsOrRe: - // We now know that the pending RE won't be ignored as the last RE. - handler.data(new (alloc) ReEvent(&re_, top().reLocation, top().reSerial)); - top().state = pendingAfterRsOrRe; - top().reLocation = location; - top().reSerial = nextSerial_++; - break; - case pendingAfterMarkup: - // We've had only markup since the last RS or RE, so this - // RE is ignored. Note that it's this RE that's ignored, not - // the pending one. - if (eventsWanted.wantInstanceMarkup()) - handler.ignoredRe(new (alloc) IgnoredReEvent(re_, location, nextSerial_++)); - top().state = pendingAfterRsOrRe; - break; - } -} - -void OutputState::noteRs(EventHandler &, Allocator &, const EventsWanted &) -{ - if (top().hasPendingRe()) - top().state = pendingAfterRsOrRe; - else - top().state = afterRsOrRe; -} - -void OutputState::noteMarkup(EventHandler &, Allocator &, const EventsWanted &) -{ - switch (top().state) { - case afterRsOrRe: - top().state = afterStartTag; - break; - case pendingAfterRsOrRe: - top().state = pendingAfterMarkup; - break; - default: - break; // avoid warning - } -} - -void OutputState::noteData(EventHandler &handler, Allocator &alloc, - const EventsWanted &) -{ - if (top().hasPendingRe()) - handler.data(new (alloc) ReEvent(&re_, top().reLocation, top().reSerial)); - top().state = afterData; -} - -void OutputState::noteStartElement(Boolean included, - EventHandler &handler, Allocator &alloc, - const EventsWanted &) -{ - if (included) - stack_.insert(new OutputStateLevel); - else { - if (top().hasPendingRe()) - handler.data(new (alloc) ReEvent(&re_, top().reLocation, top().reSerial)); - top().state = afterStartTag; - } -} - -void OutputState::noteEndElement(Boolean included, EventHandler &handler, - Allocator &alloc, - const EventsWanted &eventsWanted) -{ - if (eventsWanted.wantInstanceMarkup() && top().hasPendingRe()) - handler.ignoredRe(new (alloc) IgnoredReEvent(re_, top().reLocation, - top().reSerial)); - if (included) { - delete stack_.get(); - noteMarkup(handler, alloc, eventsWanted); - } - else - top().state = afterData; -} - -#ifdef SP_NAMESPACE -} -#endif diff --git a/cde/programs/nsgmls/OutputState.h b/cde/programs/nsgmls/OutputState.h deleted file mode 100644 index 41d621ba6..000000000 --- a/cde/programs/nsgmls/OutputState.h +++ /dev/null @@ -1,101 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: OutputState.h /main/1 1996/07/29 16:59:49 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#ifndef OutputState_INCLUDED -#define OutputState_INCLUDED 1 -#ifdef __GNUG__ -#pragma interface -#endif - -#include "Location.h" -#include "IList.h" -#include "Link.h" -#include "Boolean.h" -#include "types.h" -#include "EventsWanted.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -struct OutputStateLevel : public Link { - OutputStateLevel(); - Boolean hasPendingRe() const; - char state; // should be OutputState::State - unsigned long reSerial; - Location reLocation; -}; - -class EventHandler; -class Allocator; - -class OutputState { -public: - OutputState(); - void init(); - void handleRe(EventHandler &, Allocator &, const EventsWanted &, - Char, const Location &); - void noteRs(EventHandler &, Allocator &, const EventsWanted &); - void noteMarkup(EventHandler &, Allocator &, const EventsWanted &); - void noteData(EventHandler &, Allocator &, const EventsWanted &); - void noteStartElement(Boolean included, - EventHandler &, Allocator &, const EventsWanted &); - void noteEndElement(Boolean included, - EventHandler &, Allocator &, const EventsWanted &); -private: - OutputState(const OutputState &); // undefined - void operator=(const OutputState &); // undefined - enum State { - afterStartTag, - afterRsOrRe, - afterData, - pendingAfterRsOrRe, - pendingAfterMarkup - }; - IList stack_; - OutputStateLevel &top(); - Char re_; - unsigned long nextSerial_; - friend struct OutputStateLevel; -}; - -inline -Boolean OutputStateLevel::hasPendingRe() const -{ - return int(state) >= int(OutputState::pendingAfterRsOrRe); -} - -inline -OutputStateLevel &OutputState::top() -{ - return *stack_.head(); -} - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* not OutputState_INCLUDED */ diff --git a/cde/programs/nsgmls/Owner.C b/cde/programs/nsgmls/Owner.C deleted file mode 100644 index ec71c0c3c..000000000 --- a/cde/programs/nsgmls/Owner.C +++ /dev/null @@ -1,51 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: Owner.C /main/1 1996/07/29 16:59:54 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#ifndef Owner_DEF_INCLUDED -#define Owner_DEF_INCLUDED 1 - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -template -Owner::~Owner() -{ - if (p_) - delete p_; -} - -template -void Owner::del() -{ - delete p_; -} - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* not Owner_DEF_INCLUDED */ diff --git a/cde/programs/nsgmls/Owner.h b/cde/programs/nsgmls/Owner.h deleted file mode 100644 index 90705fc73..000000000 --- a/cde/programs/nsgmls/Owner.h +++ /dev/null @@ -1,83 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: Owner.h /main/3 1996/08/13 14:30:51 mgreess $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#ifndef Owner_INCLUDED -#define Owner_INCLUDED 1 - -// A pointer that owns the object pointed to. -// T must be of class type. -// This is coded so that T need not yet have been defined. - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -template -class Owner { -public: - Owner() : p_(0) { } - Owner(T *p) : p_(p) { } - ~Owner(); - void operator=(T *p) { - if (p_) del(); - p_ = p; - } - operator int() const { return p_ != 0; } - T *pointer() const { return p_; } - T *operator->() const { return p_; } - T &operator*() const { return *p_; } - void swap(Owner &x) { - T *tem = p_; - p_ = x.p_; - x.p_ = tem; - } - T *extract() { - T *tem = p_; - p_ = 0; - return tem; - } - void clear() { - if (p_) { - del(); - p_ = 0; - } - } -private: - Owner(const Owner &) {} - void operator=(const Owner &) {} - void del(); - T *p_; -}; - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* not Owner_INCLUDED */ - -#ifdef SP_DEFINE_TEMPLATES -#include "Owner.C" -#endif diff --git a/cde/programs/nsgmls/OwnerTable.C b/cde/programs/nsgmls/OwnerTable.C deleted file mode 100644 index 7500d3fa0..000000000 --- a/cde/programs/nsgmls/OwnerTable.C +++ /dev/null @@ -1,65 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: OwnerTable.C /main/1 1996/07/29 17:00:02 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#ifndef OwnerTable_DEF_INCLUDED -#define OwnerTable_DEF_INCLUDED 1 - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -template -OwnerTable::~OwnerTable() -{ - for (size_t i = 0; i < this->vec_.size(); i++) - delete this->vec_[i]; -} - -template -void OwnerTable::clear() -{ - for (size_t i = 0; i < this->vec_.size(); i++) - delete this->vec_[i]; - PointerTable::clear(); -} - -template -void -CopyOwnerTable::operator=(const CopyOwnerTable &t) -{ - this->clear(); - //PointerTable::operator=(t); - // FIXME This isn't exception safe. - for (size_t i = 0; i < this->vec_.size(); i++) - if (this->vec_[i]) - this->vec_[i] = this->vec_[i]->copy(); -} - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* not OwnerTable_DEF_INCLUDED */ diff --git a/cde/programs/nsgmls/OwnerTable.h b/cde/programs/nsgmls/OwnerTable.h deleted file mode 100644 index 384102876..000000000 --- a/cde/programs/nsgmls/OwnerTable.h +++ /dev/null @@ -1,73 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: OwnerTable.h /main/2 1996/08/13 10:09:13 mgreess $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#ifndef OwnerTable_INCLUDED -#define OwnerTable_INCLUDED 1 - -#include "PointerTable.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -template -class OwnerTable : public PointerTable { -public: - OwnerTable() { } - ~OwnerTable(); - void clear(); - void swap(OwnerTable &x) { - PointerTable::swap(x); - } -private: - OwnerTable(const OwnerTable &) {} - void operator=(const OwnerTable &) {} -}; - -template -class OwnerTableIter : public PointerTableIter { -public: - OwnerTableIter(const OwnerTable &table) - : PointerTableIter(table) { } -}; - -template -class CopyOwnerTable : public OwnerTable { -public: - CopyOwnerTable() { } - CopyOwnerTable(const CopyOwnerTable &tab) { *this = tab; } - void operator=(const CopyOwnerTable &tab); -}; - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* not OwnerTable_INCLUDED */ - -#ifdef SP_DEFINE_TEMPLATES -#include "OwnerTable.C" -#endif diff --git a/cde/programs/nsgmls/Param.C b/cde/programs/nsgmls/Param.C deleted file mode 100644 index f0e9b59ee..000000000 --- a/cde/programs/nsgmls/Param.C +++ /dev/null @@ -1,269 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: Param.C /main/1 1996/07/29 17:00:13 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#ifdef __GNUG__ -#pragma implementation -#endif -#include "splib.h" -#include "Param.h" -#include "MessageBuilder.h" -#include "macros.h" -#include "ParserMessages.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -AllowedParams::AllowedParams(Param::Type p1, - Param::Type p2, - Param::Type p3, - Param::Type p4, - Param::Type p5, - Param::Type p6, - Param::Type p7, - Param::Type p8, - Param::Type p9, - Param::Type p10) -{ - init(); - allow(p1); - allow(p2); - allow(p3); - allow(p4); - allow(p5); - allow(p6); - allow(p7); - allow(p8); - allow(p9); - allow(p10); -} - -AllowedParams::AllowedParams(const Param::Type *v, int n) -{ - init(); - for (int i = 0; i < n; i++) - allow(v[i]); -} - -void AllowedParams::init() -{ - for (int i = 0; i < Syntax::nNames; i++) - reservedNames_[i] = 0; - mainMode_ = mdMode; - mdc_ = 0; - rni_ = 0; - dso_ = 0; - inclusions_ = 0; - exclusions_ = 0; - extraDelimiter_ = Param::invalid; - group_ = Param::invalid; - nameStart_ = Param::invalid; - digit_ = Param::invalid; - nmchar_ = Param::invalid; - literal_ = Param::invalid; -} - - -void AllowedParams::allow(Param::Type p) -{ - switch (p) { - case Param::invalid: - break; - case Param::dso: - dso_ = 1; - break; - case Param::mdc: - mdc_ = 1; - break; - case Param::minus: - ASSERT(mainMode_ == mdMode); - mainMode_ = mdMinusMode; - extraDelimiter_ = p; - break; - case Param::pero: - ASSERT(mainMode_ == mdMode); - mainMode_ = mdPeroMode; - extraDelimiter_ = p; - break; - case Param::inclusions: - inclusions_ = 1; - break; - case Param::exclusions: - exclusions_ = 1; - break; - case Param::nameGroup: - case Param::nameTokenGroup: - case Param::modelGroup: - ASSERT(group_ == Param::invalid); - group_ = p; - break; - case Param::number: - ASSERT(digit_ == Param::invalid); - digit_ = p; - break; - case Param::minimumLiteral: - case Param::tokenizedAttributeValueLiteral: - case Param::attributeValueLiteral: - case Param::systemIdentifier: - case Param::paramLiteral: - ASSERT(literal_ == Param::invalid); - literal_ = p; - break; - case Param::name: - case Param::entityName: - case Param::paramEntityName: - ASSERT(nameStart_ == Param::invalid); - nameStart_ = p; - break; - case Param::attributeValue: - ASSERT(nameStart_ == Param::invalid); - nameStart_ = p; - ASSERT(digit_ == Param::invalid); - digit_ = p; - ASSERT(nmchar_ == Param::invalid); - nmchar_ = p; - break; - default: - if (p < Param::indicatedReservedName) { - ASSERT(nameStart_ == Param::invalid - || nameStart_ == Param::reservedName); - ASSERT(rni_ == 0); - nameStart_ = Param::reservedName; - reservedNames_[p - Param::reservedName] = 1; - } - else { - ASSERT(nameStart_ != Param::reservedName); - rni_ = 1; - reservedNames_[p - Param::indicatedReservedName] = 1; - } - break; - } -} - -AllowedParamsMessageArg::AllowedParamsMessageArg( - const AllowedParams &allow, - const ConstPtr &syntax) -: allow_(allow), - syntax_(syntax) -{ -} - -MessageArg *AllowedParamsMessageArg::copy() const -{ - return new AllowedParamsMessageArg(*this); -} - -void AllowedParamsMessageArg::append(MessageBuilder &builder) const -{ - Syntax::DelimGeneral delims[3]; - int nDelims = 0; - if (allow_.mdc()) - delims[nDelims++] = Syntax::dMDC; - if (allow_.dso()) - delims[nDelims++] = Syntax::dDSO; - switch (allow_.mainMode()) { - case mdMinusMode: - delims[nDelims++] = Syntax::dMINUS; - break; - case mdPeroMode: - delims[nDelims++] = Syntax::dPERO; - break; - default: - break; - } - Boolean first = 1; - int i; - for (i = 0; i < nDelims; i++) { - if (!first) - builder.appendFragment(ParserMessages::listSep); - else - first = 0; - const StringC &delim = syntax_->delimGeneral(delims[i]); - builder.appendFragment(ParserMessages::delimStart); - builder.appendChars(delim.data(), delim.size()); - builder.appendFragment(ParserMessages::delimEnd); - } - const MessageFragment *fragment[5]; - int nFragments = 0; - if (allow_.inclusions()) - fragment[nFragments++] = &ParserMessages::inclusions; - if (allow_.exclusions()) - fragment[nFragments++] = &ParserMessages::exclusions; - switch (allow_.literal()) { - case Param::minimumLiteral: - fragment[nFragments++] = &ParserMessages::minimumLiteral; - break; - case Param::attributeValueLiteral: - case Param::tokenizedAttributeValueLiteral: - fragment[nFragments++] = &ParserMessages::attributeValueLiteral; - break; - case Param::systemIdentifier: - fragment[nFragments++] = &ParserMessages::systemIdentifier; - break; - case Param::paramLiteral: - fragment[nFragments++] = &ParserMessages::parameterLiteral; - break; - } - switch (allow_.nameStart()) { - case Param::name: - case Param::entityName: - case Param::paramEntityName: - fragment[nFragments++] = &ParserMessages::name; - break; - case Param::attributeValue: - fragment[nFragments++] = &ParserMessages::attributeValue; - break; - } - if (allow_.digit() == Param::number) - fragment[nFragments++] = &ParserMessages::number; - - for (i = 0; i < nFragments; i++) { - if (!first) - builder.appendFragment(ParserMessages::listSep); - else - first = 0; - builder.appendFragment(*fragment[i]); - } - if (allow_.rni() || allow_.nameStart() == Param::reservedName) { - for (int i = 0; i < Syntax::nNames; i++) { - if (allow_.reservedName(Syntax::ReservedName(i))) { - if (!first) - builder.appendFragment(ParserMessages::listSep); - else - first = 0; - StringC str; - if (allow_.rni()) - str = syntax_->delimGeneral(Syntax::dRNI); - str += syntax_->reservedName(Syntax::ReservedName(i)); - builder.appendChars(str.data(), str.size()); - } - } - } -} - -#ifdef SP_NAMESPACE -} -#endif diff --git a/cde/programs/nsgmls/Param.h b/cde/programs/nsgmls/Param.h deleted file mode 100644 index 53ff2fb32..000000000 --- a/cde/programs/nsgmls/Param.h +++ /dev/null @@ -1,236 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: Param.h /main/1 1996/07/29 17:00:19 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#ifndef Param_INCLUDED -#define Param_INCLUDED 1 -#ifdef __GNUG__ -#pragma interface -#endif - -#include "Boolean.h" -#include "ContentToken.h" -#include "StringC.h" -#include "Location.h" -#include "MessageArg.h" -#include "Mode.h" -#include "NameToken.h" -#include "Owner.h" -#include "Ptr.h" -#include "Syntax.h" -#include "Text.h" -#include "Vector.h" - -// This describes a markup declaration parameter. - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -class ElementType; - -class Param { -public: - Param() : type(invalid), lita(false) { } - typedef unsigned char Type; - enum { - invalid, - dso, - mdc, - minus, - pero, - inclusions, - exclusions, - nameGroup, - nameTokenGroup, - modelGroup, - number, - minimumLiteral, - attributeValueLiteral, - tokenizedAttributeValueLiteral, - systemIdentifier, - paramLiteral, - name, - entityName, - paramEntityName, - attributeValue, - reservedName, // Syntax::ReservedName is added to this - // this is a reserved name preceded by the RNI delimiter - indicatedReservedName = reservedName + Syntax::nNames - }; - enum { nTypes = indicatedReservedName + Syntax::nNames }; - Type type; - Location startLocation; - Text literalText; - Boolean lita; - Owner modelGroupPtr; - Vector nameTokenVector; - StringC token; // name nameToken; with substitution - Vector elementVector; -private: - Param(const Param &); // undefined - void operator=(const Param &); // undefined -}; - -class AllowedParams { -public: - AllowedParams(Param::Type, - Param::Type = Param::invalid, - Param::Type = Param::invalid, - Param::Type = Param::invalid, - Param::Type = Param::invalid, - Param::Type = Param::invalid, - Param::Type = Param::invalid, - Param::Type = Param::invalid, - Param::Type = Param::invalid, - Param::Type = Param::invalid); - AllowedParams(const Param::Type *types, int nTypes); - Mode mainMode() const; - Boolean mdc() const; - Boolean rni() const; - Boolean dso() const; - Boolean inclusions() const; - Boolean exclusions() const; - Boolean reservedName(Syntax::ReservedName) const; - Param::Type group() const; - Param::Type nameStart() const; - Param::Type digit() const; - Param::Type nmchar() const; - Param::Type literal() const; -private: - void init(); - void allow(Param::Type); - PackedBoolean mdc_; - PackedBoolean rni_; - PackedBoolean dso_; - PackedBoolean inclusions_; - PackedBoolean exclusions_; - // invalid, minus, pero - Param::Type extraDelimiter_; - // invalid, nameGroup, nameTokenGroup, modelGroup - Param::Type group_; - // invalid, reservedName, name, entityName, paramEntityName, attributeValue - Param::Type nameStart_; - // invalid, number, attributeValue - Param::Type digit_; - // invalid, attributeValue - Param::Type nmchar_; // LCNMCHAR or UCNMCHAR - // invalid, minimumLiteral, systemIdentifier, paramLiteral, - // (tokenized)attributeValueLiteral - Param::Type literal_; - PackedBoolean reservedNames_[Syntax::nNames]; - Mode mainMode_; // mdMode mdMinusMode mdPeroMode -}; - -class MessageBuilder; - -class AllowedParamsMessageArg : public MessageArg { -public: - AllowedParamsMessageArg(const AllowedParams &allow, - const ConstPtr &syntax); - MessageArg *copy() const; - void append(MessageBuilder &) const; -private: - AllowedParams allow_; - ConstPtr syntax_; -}; - -inline -Mode AllowedParams::mainMode() const -{ - return mainMode_; -} - -inline -Boolean AllowedParams::mdc() const -{ - return mdc_; -} - -inline -Boolean AllowedParams::rni() const -{ - return rni_; -} - -inline -Boolean AllowedParams::dso() const -{ - return dso_; -} - -inline -Boolean AllowedParams::inclusions() const -{ - return inclusions_; -} - -inline -Boolean AllowedParams::exclusions() const -{ - return exclusions_; -} - -inline -Boolean AllowedParams::reservedName(Syntax::ReservedName i) const -{ - return reservedNames_[i]; -} - -inline -Param::Type AllowedParams::group() const -{ - return group_; -} - -inline -Param::Type AllowedParams::nameStart() const -{ - return nameStart_; -} - -inline -Param::Type AllowedParams::digit() const -{ - return digit_; -} - -inline -Param::Type AllowedParams::nmchar() const -{ - return nmchar_; -} - -inline -Param::Type AllowedParams::literal() const -{ - return literal_; -} - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* not Param_INCLUDED */ diff --git a/cde/programs/nsgmls/Parser.C b/cde/programs/nsgmls/Parser.C deleted file mode 100644 index 6cb718827..000000000 --- a/cde/programs/nsgmls/Parser.C +++ /dev/null @@ -1,219 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: Parser.C /main/1 1996/07/29 17:00:24 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#ifdef __GNUG__ -#pragma implementation -#endif - -#include "splib.h" -#include "Parser.h" -#include "ParserMessages.h" -#include "constant.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -Parser::Parser(const SgmlParser::Params ¶ms) -: ParserState(params.parent - ? params.parent->parser_->entityManagerPtr() - : params.entityManager, - params.options - ? *params.options - : params.parent->parser_->options(), - paramsSubdocLevel(params), - params.entityType == SgmlParser::Params::dtd - ? declSubsetPhase - : contentPhase) -{ - Parser *parent = 0; - if (params.parent) - parent = params.parent->parser_; - if (params.entityType == SgmlParser::Params::document) { - Sd *sd = new Sd(); - const ParserOptions &opt = *params.options; - sd->setDocCharsetDesc(*params.initialCharset); - sd->setBooleanFeature(Sd::fDATATAG, opt.datatag); - sd->setBooleanFeature(Sd::fOMITTAG, opt.omittag); - sd->setBooleanFeature(Sd::fRANK, opt.rank); - sd->setBooleanFeature(Sd::fSHORTTAG, opt.shorttag); - sd->setNumberFeature(Sd::fSIMPLE, opt.linkSimple); - sd->setBooleanFeature(Sd::fIMPLICIT, opt.linkImplicit); - sd->setNumberFeature(Sd::fEXPLICIT, opt.linkExplicit); - sd->setNumberFeature(Sd::fCONCUR, opt.concur); - sd->setNumberFeature(Sd::fSUBDOC, opt.subdoc); - sd->setBooleanFeature(Sd::fFORMAL, opt.formal); - PublicId publicId; - CharsetDecl docCharsetDecl; - docCharsetDecl.addSection(publicId); - docCharsetDecl.addRange(0, charMax > 99999999 ? 99999999 : charMax + 1, 0); - sd->setDocCharsetDecl(docCharsetDecl); - setSd(sd); - } - else if (params.sd.isNull()) { - setSd(parent->sdPointer()); - setSyntaxes(parent->prologSyntaxPointer(), - parent->instanceSyntaxPointer()); - } - else { - setSd(params.sd); - setSyntaxes(params.prologSyntax, params.instanceSyntax); - } - - // Make catalog - StringC sysid(params.sysid); - ConstPtr catalog - = entityManager().makeCatalog(sysid, - sd().docCharset(), - messenger()); - if (!catalog.isNull()) - setEntityCatalog(catalog); - else if (parent) - setEntityCatalog(parent->entityCatalogPtr()); - else { - allDone(); - return; - } - - // Set up the input stack. - if (sysid.size() == 0) { - allDone(); - return; - } - Ptr origin; - if (params.origin.isNull()) - origin = new InputSourceOrigin; - else - origin = params.origin; - pushInput(entityManager().open(sysid, - sd().docCharset(), - origin.pointer(), - 1, - messenger())); - if (inputLevel() == 0) { - allDone(); - return; - } - switch (params.entityType) { - case SgmlParser::Params::document: - setPhase(initPhase); - break; - case SgmlParser::Params::subdoc: - if (params.subdocInheritActiveLinkTypes && parent) - inheritActiveLinkTypes(*parent); - if (subdocLevel() == sd().subdoc() + 1) - message(ParserMessages::subdocLevel, NumberMessageArg(sd().subdoc())); - setPhase(prologPhase); - compilePrologModes(); - break; - case SgmlParser::Params::dtd: - compilePrologModes(); - startDtd(params.doctypeName); - setPhase(declSubsetPhase); - break; - } -} - -void Parser::giveUp() -{ - if (subdocLevel() > 0) // FIXME might be subdoc if level == 0 - message(ParserMessages::subdocGiveUp); - else - message(ParserMessages::giveUp); - allDone(); -} - -unsigned Parser::paramsSubdocLevel(const SgmlParser::Params ¶ms) -{ - if (!params.parent) - return 0; - unsigned n = params.parent->parser_->subdocLevel(); - if (params.subdocReferenced) - return n + 1; - else - return n; -} - -Event *Parser::nextEvent() -{ - while (eventQueueEmpty()) { - switch (phase()) { - case noPhase: - return 0; - case initPhase: - doInit(); - break; - case prologPhase: - doProlog(); - break; - case declSubsetPhase: - doDeclSubset(); - break; - case instanceStartPhase: - doInstanceStart(); - break; - case contentPhase: - doContent(); - break; - } - } - return eventQueueGet(); -} - -void Parser::parseAll(EventHandler &handler, - SP_CONST SP_VOLATILE sig_atomic_t *cancelPtr) -{ - while (!eventQueueEmpty()) - eventQueueGet()->handle(handler); - // FIXME catch exceptions and reset handler. - setHandler(&handler, cancelPtr); - for (;;) { - switch (phase()) { - case noPhase: - unsetHandler(); - return; - case initPhase: - doInit(); - break; - case prologPhase: - doProlog(); - break; - case declSubsetPhase: - doDeclSubset(); - break; - case instanceStartPhase: - doInstanceStart(); - break; - case contentPhase: - doContent(); - break; - } - } -} - -#ifdef SP_NAMESPACE -} -#endif diff --git a/cde/programs/nsgmls/Parser.h b/cde/programs/nsgmls/Parser.h deleted file mode 100644 index 52ff00073..000000000 --- a/cde/programs/nsgmls/Parser.h +++ /dev/null @@ -1,409 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: Parser.h /main/1 1996/07/29 17:00:29 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#ifndef Parser_INCLUDED -#define Parser_INCLUDED 1 - -#ifdef __GNUG__ -#pragma interface -#endif - -#include "types.h" -#include "Attribute.h" -#include "Attributed.h" -#include "Boolean.h" -#include "StringC.h" -#include "ElementType.h" -#include "Entity.h" -#include "Event.h" -#include "IList.h" -#include "ISet.h" -#include "Location.h" -#include "Owner.h" -#include "ParserState.h" -#include "Ptr.h" -#include "SgmlParser.h" -#include "StringOf.h" -#include "Undo.h" -#include "Vector.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -class AllowedParams; -class Param; -class ExternalId; -class PublicId; -class GroupToken; -class AllowedGroupTokens; -struct GroupConnector; -class AllowedGroupConnectors; -class AllowedSdParams; -class Text; -class AttributeList; -class AttributeDefinition; -class AttributeDefinitionList; -class UnivCharsetDesc; -class CharsetInfo; -class CharsetDecl; -class DeclaredValue; -struct SdBuilder; -struct SdParam; -class Syntax; -class ElementDefinition; -class CharSwitcher; -struct StandardSyntaxSpec; -class Undo; -class Decl; - -class Parser : private ParserState { -public: - Parser(const SgmlParser::Params &); - Event *nextEvent(); - void parseAll(EventHandler &, SP_CONST SP_VOLATILE sig_atomic_t *cancelPtr); - using ParserState::sdPointer; - using ParserState::instanceSyntaxPointer; - using ParserState::prologSyntaxPointer; - using ParserState::activateLinkType; - using ParserState::allLinkTypesActivated; - using ParserState::entityManager; - using ParserState::entityCatalog; - using ParserState::baseDtd; - using ParserState::options; -private: - Parser(const Parser &); // undefined - void operator=(const Parser &); // undefined - Boolean setStandardSyntax(Syntax &syn, const StandardSyntaxSpec &, - const CharsetInfo &docCharset, - CharSwitcher &); - Boolean addRefDelimShortref(Syntax &syntax, - const CharsetInfo &syntaxCharset, - const CharsetInfo &docCharset, - CharSwitcher &switcher); - Boolean setRefDelimGeneral(Syntax &syntax, - const CharsetInfo &syntaxCharset, - const CharsetInfo &docCharset, - CharSwitcher &switcher); - void setRefNames(Syntax &syntax, const CharsetInfo &docCharset); - - void giveUp(); - void compileSdModes(); - void compilePrologModes(); - void compileInstanceModes(); - void addNeededShortrefs(Dtd &, const Syntax &); - Boolean shortrefCanPreemptDelim(const StringC &sr, - const StringC &d, - Boolean dIsSr, - const Syntax &); - void compileModes(const Mode *modes, int n, const Dtd *); - void compileNormalMap(); - - void doInit(); - void doProlog(); - void doDeclSubset(); - void doInstanceStart(); - void doContent(); - void extendNameToken(size_t, const MessageType1 &); - void extendNumber(size_t, const MessageType1 &); - void extendData(); - void extendS(); - void extendContentS(); - void declSubsetRecover(unsigned startLevel); - void prologRecover(); - void skipDeclaration(unsigned startLevel); - Boolean parseElementDecl(); - Boolean parseAttlistDecl(); - Boolean parseNotationDecl(); - Boolean parseEntityDecl(); - Boolean parseShortrefDecl(); - Boolean parseUsemapDecl(); - Boolean parseUselinkDecl(); - Boolean parseDoctypeDeclStart(); - Boolean parseDoctypeDeclEnd(Boolean fake = 0); - Boolean parseMarkedSectionDeclStart(); - void handleMarkedSectionEnd(); - Boolean parseCommentDecl(); - void emptyCommentDecl(); - Boolean parseExternalId(const AllowedParams &, - const AllowedParams &, - unsigned, - Param &, - ExternalId &); - Boolean parseParam(const AllowedParams &, unsigned, Param &); - Boolean parseMinimumLiteral(Boolean, Text &); - Boolean parseAttributeValueLiteral(Boolean, Text &); - Boolean parseTokenizedAttributeValueLiteral(Boolean, Text &); - Boolean parseSystemIdentifier(Boolean, Text &); - Boolean parseParameterLiteral(Boolean, Text &); - Boolean parseDataTagParameterLiteral(Boolean, Text &); - // flags for parseLiteral() - enum { - literalSingleSpace = 01, - literalDataTag = 02, - literalMinimumData = 04, - // Keep info about delimiters - literalDelimInfo = 010, - // Ignore references in the literal - literalNoProcess = 020 - }; - Boolean parseLiteral(Mode litMode, Mode liteMode, size_t maxLength, - const MessageType1 &tooLongMessage, - unsigned flags, Text &text); - - Boolean parseGroupToken(const AllowedGroupTokens &allow, - unsigned nestingLevel, - unsigned declInputLevel, - unsigned groupInputLevel, - GroupToken >); - Boolean parseGroupConnector(const AllowedGroupConnectors &allow, - unsigned declInputLevel, - unsigned groupInputLevel, - GroupConnector &gc); - Boolean parseGroup(const AllowedGroupTokens &allowToken, - unsigned declInputLevel, - Param &parm); - Boolean parseModelGroup(unsigned nestingLevel, unsigned declInputLevel, - ModelGroup *&, Mode); - Boolean parseNameGroup(unsigned declInputLevel, Param &); - Boolean parseNameTokenGroup(unsigned declInputLevel, Param &); - Boolean parseDataTagGroup(unsigned nestingLevel, unsigned declInputLevel, - GroupToken &); - Boolean parseDataTagTemplateGroup(unsigned nestingLevel, - unsigned declInputLevel, GroupToken &); - - Boolean parseElementNameGroup(unsigned declInputLevel, Param &); - Boolean parseReservedName(const AllowedParams &allow, Param &parm); - Boolean parseIndicatedReservedName(const AllowedParams &allow, Param &parm); - Boolean getReservedName(Syntax::ReservedName *); - Boolean getIndicatedReservedName(Syntax::ReservedName *); - Boolean parseAttributeValueParam(Param &parm); - Boolean parseEntityReference(Boolean isParameter, - int ignoreLevel, - ConstPtr &entity, - Ptr &origin); - ContentToken::OccurrenceIndicator getOccurrenceIndicator(Mode); - Boolean parseComment(Mode); - Boolean parseNamedCharRef(); - Boolean parseNumericCharRef(Char &, Location &); - Boolean parseDeclarationName(Syntax::ReservedName *, Boolean allowAfdr = 0); - void paramInvalidToken(Token, const AllowedParams &); - void groupTokenInvalidToken(Token, const AllowedGroupTokens &); - void groupConnectorInvalidToken(Token, const AllowedGroupConnectors &); - ElementType *lookupCreateElement(const StringC &); - RankStem *lookupCreateRankStem(const StringC &); - Boolean parseExceptions(unsigned declInputLevel, - Ptr &def); - void parsePcdata(); - void parseStartTag(); - const ElementType *completeRankStem(const StringC &); - void handleRankedElement(const ElementType *); - void parseEmptyStartTag(); - void acceptPcdata(const Location &); - void acceptStartTag(const ElementType *, StartElementEvent *, - Boolean netEnabling); - void handleBadStartTag(const ElementType *, StartElementEvent *, - Boolean netEnabling); - void undo(IList &); - Boolean tryStartTag(const ElementType *, StartElementEvent *, - Boolean netEnabling, IList &); - void checkExclusion(const ElementType *e); - Boolean tryImplyTag(const Location &, unsigned &, unsigned &, - IList &, IList &); - void pushElementCheck(const ElementType *, StartElementEvent *, - Boolean netEnabling); - void pushElementCheck(const ElementType *, StartElementEvent *, - IList &, IList &); - void queueElementEvents(IList &); - Boolean parseAttributeSpec(Boolean inDeclaration, - AttributeList &, - Boolean &netEnabling); - Boolean handleAttributeNameToken(Text &text, - AttributeList &, - unsigned &specLength); - struct AttributeParameter { - enum Type { - end, - name, - nameToken, - vi, - recoverUnquoted - }; - }; - - Boolean parseAttributeParameter(Boolean inDecl, - Boolean allowVi, - AttributeParameter::Type &result, - Boolean &netEnabling); - void extendUnquotedAttributeValue(); - - Boolean parseAttributeValueSpec(Boolean inDecl, - const StringC &name, - AttributeList &atts, - unsigned &specLength); - - void parseEndTag(); - void parseEndTagClose(); - void parseEmptyEndTag(); - void parseNullEndTag(); - void endAllElements(); - void acceptEndTag(const ElementType *, EndElementEvent *); - void implyCurrentElementEnd(const Location &); - void maybeDefineEntity(const Ptr &entity); - Notation *lookupCreateNotation(const StringC &name); - Boolean parseExternalEntity(StringC &name, - Entity::DeclType declType, - unsigned declInputLevel, - Param &parm); - ShortReferenceMap *lookupCreateMap(const StringC &); - StringC prettifyDelim(const StringC &delim); - void handleShortref(int index); - Boolean parseProcessingInstruction(); - Boolean parseAttributed(unsigned declInputLevel, Param &parm, - Vector &attributed, - Boolean &isNotation); - Boolean parseDeclaredValue(unsigned declInputLevel, Boolean isNotation, - Param &parm, Owner &value); - Boolean parseDefaultValue(unsigned declInputLevel, Boolean isNotation, - Param &parm, const StringC &attributeName, - Owner &declaredValue, - Owner &def, - Boolean &anyCurrent); - Boolean reportNonSgmlCharacter(); - void endInstance(); - Boolean implySgmlDecl(); - Boolean scanForSgmlDecl(const CharsetInfo &initCharset); - void findMissingMinimum(const CharsetInfo &charset, ISet &); - Boolean parseSgmlDecl(); - Boolean sdParseDocumentCharset(SdBuilder &sdBuilder, SdParam &parm); - Boolean sdParseCapacity(SdBuilder &sdBuilder, SdParam &parm); - Boolean sdParseScope(SdBuilder &sdBuilder, SdParam &parm); - Boolean sdParseSyntax(SdBuilder &sdBuilder, SdParam &parm); - Boolean sdParseExplicitSyntax(SdBuilder &sdBuilder, SdParam &parm); - Boolean sdParseSyntaxCharset(SdBuilder &sdBuilder, SdParam &parm); - Boolean sdParseShunchar(SdBuilder &sdBuilder, SdParam &parm); - Boolean sdParseFunction(SdBuilder &sdBuilder, SdParam &parm); - Boolean sdParseNaming(SdBuilder &sdBuilder, SdParam &parm); - Boolean sdParseDelim(SdBuilder &sdBuilder, SdParam &parm); - Boolean sdParseNames(SdBuilder &sdBuilder, SdParam &parm); - Boolean sdParseQuantity(SdBuilder &sdBuilder, SdParam &parm); - Boolean sdParseFeatures(SdBuilder &sd, SdParam &parm); - Boolean sdParseAppinfo(SdBuilder &sd, SdParam &parm); - Boolean parseSdParam(const AllowedSdParams &allow, SdParam &); - Boolean parseSdParamLiteral(Boolean lita, String &str); - Boolean stringToNumber(const Char *s, size_t length, unsigned long &); - void sdParamConvertToLiteral(SdParam &parm); - void sdParamInvalidToken(Token token, const AllowedSdParams &); - Boolean sdParseCharset(SdBuilder &sdBuilder, SdParam &parm, - Boolean isDocument, - CharsetDecl &, UnivCharsetDesc &); - Boolean sdParseExternalCharset(Sd &, UnivCharsetDesc &desc); - Boolean translateSyntax(CharSwitcher &switcher, - const CharsetInfo &syntaxCharset, - const CharsetInfo &docCharset, - WideChar syntaxChar, - Char &docChar); - Boolean translateSyntax(SdBuilder &sdBuilder, - WideChar syntaxChar, Char &docChar); - Boolean translateSyntax(SdBuilder &sdBuilder, - const String &syntaxString, - StringC &docString); - Boolean translateSyntaxNoSwitch(SdBuilder &sdBuilder, - WideChar syntaxChar, Char &docChar, - Number &count); - Boolean translateName(SdBuilder &sdBuilder, - const StringC &name, - StringC &str); - void translateRange(SdBuilder &sdBuilder, SyntaxChar start, - SyntaxChar end, ISet &chars); - UnivChar translateUniv(UnivChar univChar, - CharSwitcher &switcher, - const CharsetInfo &syntaxCharset); - Boolean univToDescCheck(const CharsetInfo &charset, UnivChar from, - Char &to); - Boolean univToDescCheck(const CharsetInfo &charset, UnivChar from, - Char &to, WideChar &count); - Boolean checkNotFunction(const Syntax &syn, Char c); - Boolean checkGeneralDelim(const Syntax &syn, const StringC &delim); - Boolean checkShortrefDelim(const Syntax &syn, - const CharsetInfo &charset, - const StringC &delim); - Boolean checkNmchars(const ISet &set, const Syntax &syntax); - void intersectCharSets(const ISet &s1, const ISet &s2, - ISet &inter); - Boolean checkSwitches(CharSwitcher &switcher, - const CharsetInfo &syntaxCharset); - Boolean checkSwitchesMarkup(CharSwitcher &switcher); - - const StandardSyntaxSpec *lookupSyntax(const PublicId &id); - Boolean referencePublic(const PublicId &id, PublicId::TextClass, - Boolean &givenError); - void checkIdrefs(); - void checkTaglen(Index tagStartIndex); - void checkSyntaxNamelen(const Syntax &syn); - void checkElementAttribute(const ElementType *e, size_t checkFrom = 0); - void checkDtd(Dtd &dtd); - Boolean maybeStatusKeyword(const Entity &entity); - void reportAmbiguity(const LeafContentToken *from, - const LeafContentToken *to1, - const LeafContentToken *to2, - unsigned ambigAndDepth); - Boolean parseLinktypeDeclStart(); - Boolean parseLinktypeDeclEnd(); - Boolean parseLinkDecl(); - Boolean parseIdlinkDecl(); - Boolean parseLinkSet(Boolean idlink); - void addIdLinkRule(const StringC &id, IdLinkRule &rule); - void addLinkRule(LinkSet *linkSet, - const ElementType *sourceElement, - const ConstPtr &linkRule); - Boolean parseResultElementSpec(unsigned declInputLevel, - Param &parm, - Boolean idlink, - Boolean &implied, - const ElementType *&resultType, - AttributeList &attributes); - LinkSet *lookupCreateLinkSet(const StringC &name); - const ElementType *lookupResultElementType(const StringC &name); - void endProlog(); - Boolean parseEntityReferenceNameGroup(Boolean &ignore); - Boolean parseTagNameGroup(Boolean &active); - void parseGroupStartTag(); - void parseGroupEndTag(); - Boolean skipAttributeSpec(); - Boolean lookingAtStartTag(StringC &gi); - Boolean implyDtd(const StringC &gi); - void findMissingTag(const ElementType *e, Vector &); - unsigned paramsSubdocLevel(const SgmlParser::Params &); - void addCommonAttributes(Dtd &dtd); - Boolean parseAfdrDecl(); -}; - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* not Parser_INCLUDED */ diff --git a/cde/programs/nsgmls/ParserApp.C b/cde/programs/nsgmls/ParserApp.C deleted file mode 100644 index d72225592..000000000 --- a/cde/programs/nsgmls/ParserApp.C +++ /dev/null @@ -1,216 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: ParserApp.C /main/1 1996/07/29 17:00:34 cde-hp $ */ -// Copyright (c) 1996 James Clark -// See the file COPYING for copying permission. - -#ifdef __GNUG__ -#pragma implementation -#endif - -#include "splib.h" -#include "ParserApp.h" -#include "ParserAppMessages.h" -#include "MessageArg.h" -#include "Location.h" -#include "macros.h" -#include "sptchar.h" -#include "ArcEngine.h" - -#include -#include -#include - -#ifndef DEFAULT_ERROR_LIMIT -#define DEFAULT_ERROR_LIMIT 200 -#endif - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -ParserApp::ParserApp() -: errorLimit_(DEFAULT_ERROR_LIMIT) -{ - registerOption('a', SP_T("link_type")); - registerOption('A', SP_T("arch")); - registerOption('e'); - registerOption('E', SP_T("max_errors")); - registerOption('g'); - registerOption('i', SP_T("entity")); - registerOption('w', SP_T("warning_type")); -} - -void ParserApp::initParser(const StringC &sysid) -{ - SgmlParser::Params params; - params.sysid = sysid; - params.entityManager = entityManager().pointer(); - params.initialCharset = &systemCharset_.desc(); - params.options = &options_; - parser_.init(params); - if (arcNames_.size() > 0) - parser_.activateLinkType(arcNames_[0]); - for (size_t i = 0; i < activeLinkTypes_.size(); i++) - parser_.activateLinkType(convertInput(activeLinkTypes_[i])); - allLinkTypesActivated(); -} - -void ParserApp::allLinkTypesActivated() -{ - parser_.allLinkTypesActivated(); -} - -int ParserApp::processSysid(const StringC &sysid) -{ - initParser(sysid); - ErrorCountEventHandler *eceh = makeEventHandler(); - if (errorLimit_) - eceh->setErrorLimit(errorLimit_); - return generateEvents(eceh); -} - -int ParserApp::generateEvents(ErrorCountEventHandler *eceh) -{ - Owner eh(eceh); - parseAll(parser_, *eh, (SP_CONST sig_atomic_t*) eceh->cancelPtr()); - unsigned errorCount = eceh->errorCount(); - if (errorLimit_ != 0 && errorCount >= errorLimit_) - message(ParserAppMessages::errorLimitExceeded, - NumberMessageArg(errorLimit_)); - return errorCount > 0; -} - -void ParserApp::parseAll(SgmlParser &parser, - EventHandler &eh, - SP_CONST SP_VOLATILE sig_atomic_t *cancelPtr) -{ - if (arcNames_.size() > 0) { - SelectOneArcDirector director(arcNames_, eh); - ArcEngine::parseAll(parser, director, director, cancelPtr); - } - else - parser.parseAll(eh, cancelPtr); -} - -void ParserApp::processOption(AppChar opt, const AppChar *arg) -{ - switch (opt) { - case 'a': - // activate link - activeLinkTypes_.push_back(arg); - break; - case 'A': - arcNames_.push_back(convertInput(arg)); - break; - case 'E': - { - AppChar *end; - unsigned long n = tcstoul((AppChar *)arg, &end, 10); - if ((n == 0 && end == arg) - || *end != SP_T('\0') - || (n == ULONG_MAX && errno == ERANGE) - || n > UINT_MAX) - message(ParserAppMessages::badErrorLimit); - else - errorLimit_ = unsigned(n); - } - break; - case 'e': - // describe open entities in error messages - addOption(MessageReporter::openEntities); - break; - case 'g': - // show gis of open elements in error messages - addOption(MessageReporter::openElements); - break; - case 'i': - // pretend that arg is defined as INCLUDE - options_.includes.push_back(convertInput(arg)); - break; - case 'w': - if (!enableWarning(arg)) - message(ParserAppMessages::unknownWarning, - StringMessageArg(convertInput(arg))); - break; - default: - EntityApp::processOption(opt, arg); - break; - } -} - -Boolean ParserApp::enableWarning(const AppChar *s) -{ - struct { - const AppChar *name; - PackedBoolean ParserOptions::*ptr; - PackedBoolean partOfAll; - } table[] = { - { SP_T("mixed"), &ParserOptions::warnMixedContent, 1 }, - { SP_T("should"), &ParserOptions::warnShould, 1 }, - { SP_T("duplicate"), &ParserOptions::warnDuplicateEntity, 0 }, - { SP_T("default"), &ParserOptions::warnDefaultEntityReference, 1 }, - { SP_T("undefined"), &ParserOptions::warnUndefinedElement, 1 }, - { SP_T("sgmldecl"), &ParserOptions::warnSgmlDecl, 1 }, - { SP_T("unclosed"), &ParserOptions::warnUnclosedTag, 1 }, - { SP_T("empty"), &ParserOptions::warnEmptyTag, 1 }, - { SP_T("net"), &ParserOptions::warnNet, 0 }, - { SP_T("unused-map"), &ParserOptions::warnUnusedMap, 1 }, - { SP_T("unused-param"), &ParserOptions::warnUnusedParam, 1 }, - { SP_T("notation-sysid"), &ParserOptions::warnNotationSystemId, 0 }, - { SP_T("idref"), &ParserOptions::errorIdref, 0 }, - { SP_T("significant"), &ParserOptions::errorSignificant, 0 }, - { SP_T("afdr"), &ParserOptions::errorAfdr, 0 }, - { SP_T("lpd-notation"), &ParserOptions::errorLpdNotation, 0 }, - }; - PackedBoolean val = 1; - if (tcsncmp(s, SP_T("no-"), 3) == 0) { - s += 3; - val = 0; - } - if (tcscmp(s, SP_T("all")) == 0) { - for (size_t i = 0; i < SIZEOF(table); i++) - if (table[i].partOfAll) { - // Use parentheses to work around Watcom 10.0a bug. - (options_.*(table[i].ptr)) = val; - } - return 1; - } - for (size_t i = 0; i < SIZEOF(table); i++) - if (tcscmp(s, table[i].name) == 0) { - // Use parentheses to work around Watcom 10.0a bug. - (options_.*(table[i].ptr)) = val; - return 1; - } - if (tcscmp(s, SP_T("min-tag")) == 0) { - options_.warnUnclosedTag = val; - options_.warnEmptyTag = val; - options_.warnNet = val; - return 1; - } - return 0; -} - -#ifdef SP_NAMESPACE -} -#endif diff --git a/cde/programs/nsgmls/ParserApp.h b/cde/programs/nsgmls/ParserApp.h deleted file mode 100644 index 5019a01e8..000000000 --- a/cde/programs/nsgmls/ParserApp.h +++ /dev/null @@ -1,76 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: ParserApp.h /main/1 1996/07/29 17:00:38 cde-hp $ */ -// Copyright (c) 1996 James Clark -// See the file COPYING for copying permission. - -#ifndef ParserApp_INCLUDED -#define ParserApp_INCLUDED 1 - -#ifdef __GNUG__ -#pragma interface -#endif - -#include "SgmlParser.h" -#include "ParserOptions.h" -#include "EntityApp.h" -#include "StringC.h" -#include "ErrorCountEventHandler.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -class SP_API ParserApp : public EntityApp { -public: - ParserApp(); - void processOption(AppChar opt, const AppChar *arg); - int processSysid(const StringC &); - virtual ErrorCountEventHandler *makeEventHandler() = 0; - Boolean enableWarning(const AppChar *s); - void initParser(const StringC &sysid); - SgmlParser &parser(); - // This calls the ArcEngine if the options have enabled that. - void parseAll(SgmlParser &, EventHandler &, - SP_CONST SP_VOLATILE sig_atomic_t *cancelPtr); - virtual void allLinkTypesActivated(); -protected: - virtual int generateEvents(ErrorCountEventHandler *); - ParserOptions options_; - SgmlParser parser_; - unsigned errorLimit_; - Vector arcNames_; - Vector activeLinkTypes_; -}; - -inline -SgmlParser &ParserApp::parser() -{ - return parser_; -} - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* not ParserApp_INCLUDED */ diff --git a/cde/programs/nsgmls/ParserAppMessages.h b/cde/programs/nsgmls/ParserAppMessages.h deleted file mode 100644 index 9ebf22e56..000000000 --- a/cde/programs/nsgmls/ParserAppMessages.h +++ /dev/null @@ -1,77 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: ParserAppMessages.h /main/1 1996/07/29 17:00:43 cde-hp $ */ -// This file was automatically generated from ParserAppMessages.msg by msggen.pl. -#include "Message.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -struct ParserAppMessages { - // 4200 - static const MessageType1 unknownWarning; - // 4201 - static const MessageType0 badErrorLimit; - // 4202 - static const MessageType1 errorLimitExceeded; -}; -const MessageType1 ParserAppMessages::unknownWarning( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -4200 -#ifndef SP_NO_MESSAGE_TEXT -,"unknown warning type %1" -#endif -); -const MessageType0 ParserAppMessages::badErrorLimit( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -4201 -#ifndef SP_NO_MESSAGE_TEXT -,"invalid error limit" -#endif -); -const MessageType1 ParserAppMessages::errorLimitExceeded( -MessageType::info, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -4202 -#ifndef SP_NO_MESSAGE_TEXT -,"maximum number of errors (%1) reached; change with -E option" -#endif -); -#ifdef SP_NAMESPACE -} -#endif diff --git a/cde/programs/nsgmls/ParserEventGeneratorKit.C b/cde/programs/nsgmls/ParserEventGeneratorKit.C deleted file mode 100644 index e8e915045..000000000 --- a/cde/programs/nsgmls/ParserEventGeneratorKit.C +++ /dev/null @@ -1,221 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: ParserEventGeneratorKit.C /main/1 1996/07/29 17:00:49 cde-hp $ */ -// Copyright (c) 1995 James Clark -// See the file COPYING for copying permission. - -#ifdef __GNUG__ -#pragma implementation -#endif - -#include "splib.h" -#include "Boolean.h" -#include "ParserApp.h" -#include "macros.h" -#include "SGMLApplication.h" -#include "ParserEventGeneratorKit.h" -#include "GenericEventHandler.h" - -#ifdef SP_NAMESPACE -using namespace SP_NAMESPACE; -#endif - -class ParserEventGeneratorKitImpl : public ParserApp { -public: - ParserOptions &options() { return options_; } - bool generalEntities; - unsigned refCount; -private: - ErrorCountEventHandler *makeEventHandler() { return 0; } -}; - -class ParserEventGenerator : public EventGenerator { -public: - ParserEventGenerator(SgmlParser &, - bool generalEntities, - ParserEventGeneratorKitImpl *kit_); - ParserEventGenerator(const SgmlParser &, - const SGMLApplication::Char *, - size_t n, - bool generalEntities, - bool messagesInhibited, - ParserEventGeneratorKitImpl *kit_); - ~ParserEventGenerator(); - unsigned run(SGMLApplication &); - void inhibitMessages(bool); - void halt(); - EventGenerator * - makeSubdocEventGenerator(const SGMLApplication::Char *systemId, - size_t systemIdLength); -private: - SgmlParser parser_; - bool generalEntities_; - bool messagesInhibited_; - sig_atomic_t cancel_; - ParserEventGeneratorKitImpl *kit_; -}; - -ParserEventGeneratorKit::ParserEventGeneratorKit() -{ - impl_ = new ParserEventGeneratorKitImpl; - impl_->refCount = 1; - impl_->generalEntities = 0; -} - -ParserEventGeneratorKit::~ParserEventGeneratorKit() -{ - impl_->refCount -= 1; - if (impl_->refCount == 0) - delete impl_; -} - -EventGenerator * -ParserEventGeneratorKit::makeEventGenerator(int nFiles, - AppChar *const *files) -{ - StringC sysid; - if (impl_->makeSystemId(nFiles, files, sysid)) - impl_->initParser(sysid); - return new ParserEventGenerator(impl_->parser(), - impl_->generalEntities, - impl_); -} - -void ParserEventGeneratorKit::setProgramName(const AppChar *prog) -{ - if (prog) - impl_->setProgramName(impl_->convertInput(prog)); -} - -void ParserEventGeneratorKit::setOption(Option opt) -{ - switch (opt) { - case showOpenEntities: - impl_->processOption('e', 0); - break; - case showOpenElements: - impl_->processOption('g', 0); - break; - case outputCommentDecls: - impl_->options().eventsWanted.addCommentDecls(); - break; - case outputMarkedSections: - impl_->options().eventsWanted.addMarkedSections(); - break; - case outputGeneralEntities: - impl_->generalEntities = 1; - break; - case mapCatalogDocument: - impl_->processOption('C', 0); - break; - } -} - -void ParserEventGeneratorKit::setOption(OptionWithArg opt, - const AppChar *arg) -{ - switch (opt) { - case addCatalog: - impl_->processOption('c', arg); - break; - case includeParam: - impl_->processOption('i', arg); - break; - case enableWarning: - impl_->processOption('w', arg); - break; - case addSearchDir: - impl_->processOption('D', arg); - break; - case activateLink: - impl_->processOption('a', arg); - break; - case architecture: - impl_->processOption('A', arg); - break; - } -} - -ParserEventGenerator::ParserEventGenerator(SgmlParser &parser, - bool generalEntities, - ParserEventGeneratorKitImpl *kit) -: generalEntities_(generalEntities), - messagesInhibited_(0), - cancel_(0), - kit_(kit) -{ - parser_.swap(parser); - kit_->refCount += 1; -} - -ParserEventGenerator::ParserEventGenerator(const SgmlParser &parser, - const SGMLApplication::Char *s, - size_t n, - bool generalEntities, - bool messagesInhibited, - ParserEventGeneratorKitImpl *kit) -: generalEntities_(generalEntities), - messagesInhibited_(messagesInhibited), - cancel_(0), - kit_(kit) -{ - kit_->refCount += 1; - SgmlParser::Params params; - params.parent = &parser; - params.sysid.assign(s, n); - params.entityType = SgmlParser::Params::subdoc; - parser_.init(params); -} - -void ParserEventGenerator::halt() -{ - cancel_ = 1; -} - -ParserEventGenerator::~ParserEventGenerator() -{ - kit_->refCount -= 1; - if (kit_->refCount == 0) - delete kit_; -} - -unsigned ParserEventGenerator::run(SGMLApplication &app) -{ - MsgGenericEventHandler handler(app, generalEntities_, - *kit_, &messagesInhibited_); - kit_->parseAll(parser_, handler, &cancel_); - return handler.errorCount(); -} - -void ParserEventGenerator::inhibitMessages(bool b) -{ - messagesInhibited_ = b; -} - -EventGenerator * -ParserEventGenerator::makeSubdocEventGenerator(const SGMLApplication::Char *s, - size_t n) -{ - return new ParserEventGenerator(parser_, s, n, generalEntities_, - messagesInhibited_, kit_); -} diff --git a/cde/programs/nsgmls/ParserEventGeneratorKit.h b/cde/programs/nsgmls/ParserEventGeneratorKit.h deleted file mode 100644 index 46d38856d..000000000 --- a/cde/programs/nsgmls/ParserEventGeneratorKit.h +++ /dev/null @@ -1,75 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: ParserEventGeneratorKit.h /main/1 1996/07/29 17:00:54 cde-hp $ */ -// Copyright (c) 1995 James Clark -// See the file COPYING for copying permission. - -#ifndef ParserEventGeneratorKit_INCLUDED -#define ParserEventGeneratorKit_INCLUDED 1 - -#ifdef __GNUG__ -#pragma interface -#endif - -#include "EventGenerator.h" - -class ParserEventGeneratorKitImpl; - -class SP_API ParserEventGeneratorKit { -public: - ParserEventGeneratorKit(); - ~ParserEventGeneratorKit(); - enum Option { - showOpenEntities, - showOpenElements, - outputCommentDecls, - outputMarkedSections, - outputGeneralEntities, - mapCatalogDocument - }; - enum OptionWithArg { - addCatalog, - includeParam, - enableWarning, - addSearchDir, - activateLink, - architecture // not implemented - }; - void setOption(Option); -#ifdef SP_WIDE_SYSTEM - void setProgramName(const wchar_t *); - void setOption(OptionWithArg, const wchar_t *); - EventGenerator *makeEventGenerator(int nFiles, wchar_t *const *files); -#else - void setProgramName(const char *); - void setOption(OptionWithArg, const char *); - EventGenerator *makeEventGenerator(int nFiles, char *const *files); -#endif -private: - ParserEventGeneratorKit(const ParserEventGeneratorKit &); // undefined - void operator=(const ParserEventGeneratorKit &); // undefined - - ParserEventGeneratorKitImpl *impl_; -}; - -#endif /* not ParserEventGeneratorKit_INCLUDED */ diff --git a/cde/programs/nsgmls/ParserMessages.C b/cde/programs/nsgmls/ParserMessages.C deleted file mode 100644 index 55954b5ae..000000000 --- a/cde/programs/nsgmls/ParserMessages.C +++ /dev/null @@ -1,4465 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: ParserMessages.C /main/1 1996/07/29 17:00:58 cde-hp $ */ -// This file was automatically generated from ParserMessages.msg by msggen.pl. - -#ifdef __GNUG__ -#pragma implementation -#endif - -#include "splib.h" -#include "ParserMessages.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -const MessageType1 ParserMessages::nameLength( -MessageType::quantityError, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -0 -#ifndef SP_NO_MESSAGE_TEXT -,"length of name must not exceed NAMELEN (%1)" -#endif -); -const MessageType1 ParserMessages::parameterEntityNameLength( -MessageType::quantityError, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -1 -#ifndef SP_NO_MESSAGE_TEXT -,"length of parameter entity name must not exceed NAMELEN less the length of the PERO delimiter (%1)" -#endif -); -const MessageType1 ParserMessages::numberLength( -MessageType::quantityError, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -2 -#ifndef SP_NO_MESSAGE_TEXT -,"length of number must not exceed NAMELEN (%1)" -#endif -); -const MessageType1 ParserMessages::attributeValueLength( -MessageType::quantityError, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -3 -#ifndef SP_NO_MESSAGE_TEXT -,"length of attribute value must not exceed LITLEN less NORMSEP (%1)" -#endif -); -const MessageType0 ParserMessages::peroGrpoProlog( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -4 -#ifndef SP_NO_MESSAGE_TEXT -,"a name group is not allowed in a parameter entity reference in the prolog" -#endif -); -const MessageType0 ParserMessages::groupLevel( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -5 -#ifndef SP_NO_MESSAGE_TEXT -,"an entity end in a token separator must terminate an entity referenced in the same group" -#endif -); -const MessageType2 ParserMessages::groupCharacter( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -6 -#ifndef SP_NO_MESSAGE_TEXT -,"character %1 invalid: only %2 and token separators allowed" -#endif -); -const MessageType0 ParserMessages::psRequired( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -7 -#ifndef SP_NO_MESSAGE_TEXT -,"a parameter separator is required after a number that is followed by a name start character" -#endif -); -const MessageType2 ParserMessages::markupDeclarationCharacter( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -8 -#ifndef SP_NO_MESSAGE_TEXT -,"character %1 invalid: only %2 and parameter separators allowed" -#endif -); -const MessageType0 ParserMessages::declarationLevel( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -9 -#ifndef SP_NO_MESSAGE_TEXT -,"an entity end in a parameter separator must terminate an entity referenced in the same declaration" -#endif -); -const MessageType0 ParserMessages::groupEntityEnd( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -10 -#ifndef SP_NO_MESSAGE_TEXT -,"an entity end is not allowed in a token separator that does not follow a token" -#endif -); -const MessageType1 ParserMessages::invalidToken( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -11 -#ifndef SP_NO_MESSAGE_TEXT -,"%1 is not a valid token here" -#endif -); -const MessageType0 ParserMessages::groupEntityReference( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -12 -#ifndef SP_NO_MESSAGE_TEXT -,"a parameter entity reference can only occur in a group where a token could occur" -#endif -); -const MessageType1 ParserMessages::duplicateGroupToken( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -13 -#ifndef SP_NO_MESSAGE_TEXT -,"token %1 has already occurred in this group" -#endif -); -const MessageType1 ParserMessages::groupCount( -MessageType::quantityError, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -14 -#ifndef SP_NO_MESSAGE_TEXT -,"the number of tokens in a group must not exceed GRPCNT (%1)" -#endif -); -const MessageType0 ParserMessages::literalLevel( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -15 -#ifndef SP_NO_MESSAGE_TEXT -,"an entity end in a literal must terminate an entity referenced in the same literal" -#endif -); -const MessageType1 ParserMessages::literalMinimumData( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -16 -#ifndef SP_NO_MESSAGE_TEXT -,"character %1 invalid: only minimum data characters allowed" -#endif -); -const MessageType0 ParserMessages::dataTagPatternNonSgml( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -17 -#ifndef SP_NO_MESSAGE_TEXT -,"a parameter literal in a data tag pattern must not contain a numeric character reference to a non-SGML character" -#endif -); -const MessageType0 ParserMessages::dataTagPatternFunction( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -18 -#ifndef SP_NO_MESSAGE_TEXT -,"a parameter literal in a data tag pattern must not contain a numeric character reference to a function character" -#endif -); -const MessageType0 ParserMessages::eroGrpoStartTag( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -19 -#ifndef SP_NO_MESSAGE_TEXT -,"a name group is not allowed in a general entity reference in a start tag" -#endif -); -const MessageType0 ParserMessages::eroGrpoProlog( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -20 -#ifndef SP_NO_MESSAGE_TEXT -,"a name group is not allowed in a general entity reference in the prolog" -#endif -); -const MessageType1 ParserMessages::functionName( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -21 -#ifndef SP_NO_MESSAGE_TEXT -,"%1 is not a function name" -#endif -); -const MessageType1 ParserMessages::characterNumber( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -22 -#ifndef SP_NO_MESSAGE_TEXT -,"%1 is not a character number in the document character set" -#endif -); -const MessageType1 ParserMessages::parameterEntityUndefined( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -23 -#ifndef SP_NO_MESSAGE_TEXT -,"parameter entity %1 not defined" -#endif -); -const MessageType1 ParserMessages::entityUndefined( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -24 -#ifndef SP_NO_MESSAGE_TEXT -,"general entity %1 not defined and no default entity" -#endif -); -const MessageType0 ParserMessages::rniNameStart( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -25 -#ifndef SP_NO_MESSAGE_TEXT -,"RNI delimiter must be followed by name start character" -#endif -); -const MessageType0L ParserMessages::commentEntityEnd( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -26 -#ifndef SP_NO_MESSAGE_TEXT -,"unterminated comment: found end of entity inside comment" -,"comment started here" -#endif -); -const MessageType0 ParserMessages::mixedConnectors( -MessageType::warning, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -28 -#ifndef SP_NO_MESSAGE_TEXT -,"only one type of connector should be used in a single group" -#endif -); -const MessageType1 ParserMessages::noSuchReservedName( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -29 -#ifndef SP_NO_MESSAGE_TEXT -,"%1 is not a reserved name" -#endif -); -const MessageType1 ParserMessages::invalidReservedName( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -30 -#ifndef SP_NO_MESSAGE_TEXT -,"%1 is not allowed as a reserved name here" -#endif -); -const MessageType1 ParserMessages::minimumLiteralLength( -MessageType::quantityError, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -31 -#ifndef SP_NO_MESSAGE_TEXT -,"length of interpreted minimum literal must not exceed reference LITLEN (%1)" -#endif -); -const MessageType1 ParserMessages::tokenizedAttributeValueLength( -MessageType::quantityError, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -32 -#ifndef SP_NO_MESSAGE_TEXT -,"length of tokenized attribute value must not exceed LITLEN less NORMSEP (%1)" -#endif -); -const MessageType1 ParserMessages::systemIdentifierLength( -MessageType::quantityError, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -33 -#ifndef SP_NO_MESSAGE_TEXT -,"length of system identifier must not exceed LITLEN (%1)" -#endif -); -const MessageType1 ParserMessages::parameterLiteralLength( -MessageType::quantityError, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -34 -#ifndef SP_NO_MESSAGE_TEXT -,"length of interpreted parameter literal must not exceed LITLEN (%1)" -#endif -); -const MessageType1 ParserMessages::dataTagPatternLiteralLength( -MessageType::quantityError, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -35 -#ifndef SP_NO_MESSAGE_TEXT -,"length of interpreted parameter literal in data tag pattern must not exceed DTEMPLEN" -#endif -); -const MessageType0 ParserMessages::literalClosingDelimiter( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -36 -#ifndef SP_NO_MESSAGE_TEXT -,"literal is missing closing delimiter" -#endif -); -const MessageType2 ParserMessages::paramInvalidToken( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -37 -#ifndef SP_NO_MESSAGE_TEXT -,"%1 invalid: only %2 and parameter separators are allowed" -#endif -); -const MessageType2 ParserMessages::groupTokenInvalidToken( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -38 -#ifndef SP_NO_MESSAGE_TEXT -,"%1 invalid: only %2 and token separators are allowed" -#endif -); -const MessageType2 ParserMessages::connectorInvalidToken( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -39 -#ifndef SP_NO_MESSAGE_TEXT -,"%1 invalid: only %2 and token separators are allowed" -#endif -); -const MessageType1 ParserMessages::noSuchDeclarationType( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -40 -#ifndef SP_NO_MESSAGE_TEXT -,"unknown declaration type %1" -#endif -); -const MessageType1 ParserMessages::dtdSubsetDeclaration( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -41 -#ifndef SP_NO_MESSAGE_TEXT -,"%1 declaration not allowed in DTD subset" -#endif -); -const MessageType1 ParserMessages::declSubsetCharacter( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -42 -#ifndef SP_NO_MESSAGE_TEXT -,"character %1 not allowed in declaration subset" -#endif -); -const MessageType0 ParserMessages::documentEndDtdSubset( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -43 -#ifndef SP_NO_MESSAGE_TEXT -,"end of document in DTD subset" -#endif -); -const MessageType1 ParserMessages::prologCharacter( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -44 -#ifndef SP_NO_MESSAGE_TEXT -,"character %1 not allowed in prolog" -#endif -); -const MessageType0 ParserMessages::documentEndProlog( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -45 -#ifndef SP_NO_MESSAGE_TEXT -,"end of document in prolog" -#endif -); -const MessageType1 ParserMessages::prologDeclaration( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -46 -#ifndef SP_NO_MESSAGE_TEXT -,"%1 declaration not allowed in prolog" -#endif -); -const MessageType1 ParserMessages::rankStemGenericIdentifier( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -47 -#ifndef SP_NO_MESSAGE_TEXT -,"%1 used both a rank stem and generic identifier" -#endif -); -const MessageType0 ParserMessages::missingTagMinimization( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -48 -#ifndef SP_NO_MESSAGE_TEXT -,"omitted tag minimization parameter can be omitted only if \"OMITTAG NO\" is specified on the SGML declaration" -#endif -); -const MessageType1 ParserMessages::duplicateElementDefinition( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -49 -#ifndef SP_NO_MESSAGE_TEXT -,"element type %1 already defined" -#endif -); -const MessageType0 ParserMessages::entityApplicableDtd( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -50 -#ifndef SP_NO_MESSAGE_TEXT -,"entity reference with no applicable DTD" -#endif -); -const MessageType1L ParserMessages::commentDeclInvalidToken( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -51 -#ifndef SP_NO_MESSAGE_TEXT -,"invalid comment declaration: found %1 outside comment but inside comment declaration" -,"comment declaration started here" -#endif -); -const MessageType1 ParserMessages::instanceDeclaration( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -53 -#ifndef SP_NO_MESSAGE_TEXT -,"%1 declaration not allowed in instance" -#endif -); -const MessageType0 ParserMessages::contentNonSgml( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -54 -#ifndef SP_NO_MESSAGE_TEXT -,"non-SGML character not allowed in content" -#endif -); -const MessageType1 ParserMessages::noCurrentRank( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -55 -#ifndef SP_NO_MESSAGE_TEXT -,"no current rank for rank stem %1" -#endif -); -const MessageType1 ParserMessages::duplicateAttlistNotation( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -56 -#ifndef SP_NO_MESSAGE_TEXT -,"duplicate attribute definition list for notation %1" -#endif -); -const MessageType1 ParserMessages::duplicateAttlistElement( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -57 -#ifndef SP_NO_MESSAGE_TEXT -,"duplicate attribute definition list for element %1" -#endif -); -const MessageType0 ParserMessages::endTagEntityEnd( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -58 -#ifndef SP_NO_MESSAGE_TEXT -,"entity end not allowed in end tag" -#endif -); -const MessageType1 ParserMessages::endTagCharacter( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -59 -#ifndef SP_NO_MESSAGE_TEXT -,"character %1 not allowed in end tag" -#endif -); -const MessageType1 ParserMessages::endTagInvalidToken( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -60 -#ifndef SP_NO_MESSAGE_TEXT -,"%1 invalid: only s and tagc allowed here" -#endif -); -const MessageType0 ParserMessages::pcdataNotAllowed( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -61 -#ifndef SP_NO_MESSAGE_TEXT -,"character data is not allowed here" -#endif -); -const MessageType1 ParserMessages::elementNotAllowed( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -62 -#ifndef SP_NO_MESSAGE_TEXT -,"document type does not allow element %1 here" -#endif -); -const MessageType2 ParserMessages::missingElementMultiple( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -63 -#ifndef SP_NO_MESSAGE_TEXT -,"document type does not allow element %1 here; missing one of %2 start-tag" -#endif -); -const MessageType2 ParserMessages::missingElementInferred( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -64 -#ifndef SP_NO_MESSAGE_TEXT -,"document type does not allow element %1 here; assuming missing %2 start-tag" -#endif -); -const MessageType1 ParserMessages::startTagEmptyElement( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -65 -#ifndef SP_NO_MESSAGE_TEXT -,"no start tag specified for implied empty element %1" -#endif -); -const MessageType1L ParserMessages::omitEndTagDeclare( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -66 -#ifndef SP_NO_MESSAGE_TEXT -,"end tag for %1 omitted, but its declaration does not permit this" -,"start tag was here" -#endif -); -const MessageType1L ParserMessages::omitEndTagOmittag( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -68 -#ifndef SP_NO_MESSAGE_TEXT -,"end tag for %1 omitted, but OMITTAG NO was specified" -,"start tag was here" -#endif -); -const MessageType1 ParserMessages::omitStartTagDeclaredContent( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -70 -#ifndef SP_NO_MESSAGE_TEXT -,"start tag omitted for element %1 with declared content" -#endif -); -const MessageType1 ParserMessages::elementEndTagNotFinished( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -71 -#ifndef SP_NO_MESSAGE_TEXT -,"end tag for %1 which is not finished" -#endif -); -const MessageType1 ParserMessages::omitStartTagDeclare( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -72 -#ifndef SP_NO_MESSAGE_TEXT -,"start tag for %1 omitted, but its declaration does not permit this" -#endif -); -const MessageType1 ParserMessages::taglvlOpenElements( -MessageType::quantityError, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -73 -#ifndef SP_NO_MESSAGE_TEXT -,"number of open elements exceeds TAGLVL (%1)" -#endif -); -const MessageType1 ParserMessages::undefinedElement( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -74 -#ifndef SP_NO_MESSAGE_TEXT -,"element %1 undefined" -#endif -); -const MessageType0 ParserMessages::emptyEndTagNoOpenElements( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -75 -#ifndef SP_NO_MESSAGE_TEXT -,"empty end tag but no open elements" -#endif -); -const MessageType1 ParserMessages::elementNotFinished( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -76 -#ifndef SP_NO_MESSAGE_TEXT -,"%1 not finished but containing element ended" -#endif -); -const MessageType1 ParserMessages::elementNotOpen( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -77 -#ifndef SP_NO_MESSAGE_TEXT -,"end tag for element %1 which is not open" -#endif -); -const MessageType1 ParserMessages::internalParameterDataEntity( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -78 -#ifndef SP_NO_MESSAGE_TEXT -,"internal parameter entity %1 cannot be CDATA or SDATA" -#endif -); -const MessageType1 ParserMessages::attributeSpecCharacter( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -79 -#ifndef SP_NO_MESSAGE_TEXT -,"character %1 not allowed in attribute specification list" -#endif -); -const MessageType0 ParserMessages::unquotedAttributeValue( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -80 -#ifndef SP_NO_MESSAGE_TEXT -,"an attribute value must be a literal unless it contains only name characters" -#endif -); -const MessageType0 ParserMessages::attributeSpecEntityEnd( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -81 -#ifndef SP_NO_MESSAGE_TEXT -,"entity end not allowed in attribute specification list except in attribute value literal" -#endif -); -const MessageType1 ParserMessages::externalParameterDataSubdocEntity( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -82 -#ifndef SP_NO_MESSAGE_TEXT -,"external parameter entity %1 cannot be CDATA, SDATA, NDATA or SUBDOC" -#endif -); -const MessageType1 ParserMessages::duplicateEntityDeclaration( -MessageType::warning, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -83 -#ifndef SP_NO_MESSAGE_TEXT -,"duplicate declaration of entity %1" -#endif -); -const MessageType1 ParserMessages::duplicateParameterEntityDeclaration( -MessageType::warning, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -84 -#ifndef SP_NO_MESSAGE_TEXT -,"duplicate declaration of parameter entity %1" -#endif -); -const MessageType1 ParserMessages::noDtdSubset( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -85 -#ifndef SP_NO_MESSAGE_TEXT -,"DTD %1 has neither internal nor external subset" -#endif -); -const MessageType0 ParserMessages::piEntityReference( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -86 -#ifndef SP_NO_MESSAGE_TEXT -,"a reference to a PI entity is allowed only in a context where a processing instruction could occur" -#endif -); -const MessageType0 ParserMessages::internalDataEntityReference( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -87 -#ifndef SP_NO_MESSAGE_TEXT -,"a reference to a CDATA or SDATA entity is allowed only in a context where a data character could occur" -#endif -); -const MessageType0 ParserMessages::externalNonTextEntityReference( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -88 -#ifndef SP_NO_MESSAGE_TEXT -,"a reference to a subdocument entity or external data entity is allowed only in a context where a data character could occur" -#endif -); -const MessageType0 ParserMessages::externalNonTextEntityRcdata( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -89 -#ifndef SP_NO_MESSAGE_TEXT -,"a reference to a subdocument entity or external data entity is not allowed in replaceable character data" -#endif -); -const MessageType0 ParserMessages::entlvl( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -90 -#ifndef SP_NO_MESSAGE_TEXT -,"the number of open entities cannot exceed ENTLVL" -#endif -); -const MessageType0 ParserMessages::piEntityRcdata( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -91 -#ifndef SP_NO_MESSAGE_TEXT -,"a reference to a PI entity is not allowed in replaceable character data" -#endif -); -const MessageType1 ParserMessages::recursiveEntityReference( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -92 -#ifndef SP_NO_MESSAGE_TEXT -,"entity %1 is already open" -#endif -); -const MessageType1 ParserMessages::undefinedShortrefMapInstance( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -93 -#ifndef SP_NO_MESSAGE_TEXT -,"short reference map %1 not defined" -#endif -); -const MessageType0 ParserMessages::usemapAssociatedElementTypeDtd( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -94 -#ifndef SP_NO_MESSAGE_TEXT -,"short reference map in DTD must specify associated element type" -#endif -); -const MessageType0 ParserMessages::usemapAssociatedElementTypeInstance( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -95 -#ifndef SP_NO_MESSAGE_TEXT -,"short reference map in document instance cannot specify associated element type" -#endif -); -const MessageType2 ParserMessages::undefinedShortrefMapDtd( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -96 -#ifndef SP_NO_MESSAGE_TEXT -,"short reference map %1 for element %2 not defined in DTD" -#endif -); -const MessageType1 ParserMessages::unknownShortrefDelim( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -97 -#ifndef SP_NO_MESSAGE_TEXT -,"%1 is not a short reference delimiter" -#endif -); -const MessageType1 ParserMessages::delimDuplicateMap( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -98 -#ifndef SP_NO_MESSAGE_TEXT -,"short reference delimiter %1 already mapped in this declaration" -#endif -); -const MessageType0 ParserMessages::noDocumentElement( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -99 -#ifndef SP_NO_MESSAGE_TEXT -,"no document element" -#endif -); -const MessageType0 ParserMessages::processingInstructionEntityEnd( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -100 -#ifndef SP_NO_MESSAGE_TEXT -,"entity end not allowed in processing instruction" -#endif -); -const MessageType1 ParserMessages::processingInstructionLength( -MessageType::quantityError, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -101 -#ifndef SP_NO_MESSAGE_TEXT -,"length of processing instruction must not exceed PILEN (%1)" -#endif -); -const MessageType0 ParserMessages::processingInstructionClose( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -102 -#ifndef SP_NO_MESSAGE_TEXT -,"missing pic delimiter" -#endif -); -const MessageType0 ParserMessages::attributeSpecNameTokenExpected( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -103 -#ifndef SP_NO_MESSAGE_TEXT -,"an attribute specification must start with a name or name token" -#endif -); -const MessageType1 ParserMessages::noSuchAttributeToken( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -104 -#ifndef SP_NO_MESSAGE_TEXT -,"%1 is not a member of a group specified for any attribute" -#endif -); -const MessageType0 ParserMessages::attributeNameShorttag( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -105 -#ifndef SP_NO_MESSAGE_TEXT -,"the name and vi delimiter can be omitted from an attribute specification only if SHORTTAG YES is specified" -#endif -); -const MessageType1 ParserMessages::noSuchAttribute( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -106 -#ifndef SP_NO_MESSAGE_TEXT -,"there is no attribute %1" -#endif -); -const MessageType0 ParserMessages::attributeValueExpected( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -107 -#ifndef SP_NO_MESSAGE_TEXT -,"an attribute value specification must start with a literal or a name character" -#endif -); -const MessageType1 ParserMessages::nameTokenLength( -MessageType::quantityError, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -108 -#ifndef SP_NO_MESSAGE_TEXT -,"length of name token must not exceed NAMELEN (%1)" -#endif -); -const MessageType0 ParserMessages::attributeSpecLiteral( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -109 -#ifndef SP_NO_MESSAGE_TEXT -,"an attribute value literal can occur in an attribute specification list only after a vi delimiter" -#endif -); -const MessageType1 ParserMessages::duplicateAttributeSpec( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -110 -#ifndef SP_NO_MESSAGE_TEXT -,"duplicate specification of attribute %1" -#endif -); -const MessageType1 ParserMessages::duplicateAttributeDef( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -111 -#ifndef SP_NO_MESSAGE_TEXT -,"duplicate definition of attribute %1" -#endif -); -const MessageType0 ParserMessages::emptyDataAttributeSpec( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -112 -#ifndef SP_NO_MESSAGE_TEXT -,"data attribute specification must be omitted if attribute specification list is empty" -#endif -); -const MessageType0 ParserMessages::markedSectionEnd( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -113 -#ifndef SP_NO_MESSAGE_TEXT -,"marked section end not in marked section declaration" -#endif -); -const MessageType1 ParserMessages::markedSectionLevel( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -114 -#ifndef SP_NO_MESSAGE_TEXT -,"number of open marked sections must not exceed TAGLVL (%1)" -#endif -); -const MessageType0L ParserMessages::unclosedMarkedSection( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -115 -#ifndef SP_NO_MESSAGE_TEXT -,"missing marked section end" -,"marked section started here" -#endif -); -const MessageType0 ParserMessages::specialParseEntityEnd( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -117 -#ifndef SP_NO_MESSAGE_TEXT -,"entity end in character data, replaceable character data or ignored marked section" -#endif -); -const MessageType2 ParserMessages::normalizedAttributeValueLength( -MessageType::quantityError, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -118 -#ifndef SP_NO_MESSAGE_TEXT -,"normalized length of attribute value literal must not exceed LITLEN (%1); length was %2" -#endif -); -const MessageType0 ParserMessages::attributeValueSyntax( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -119 -#ifndef SP_NO_MESSAGE_TEXT -,"syntax of attribute value does not conform to declared value" -#endif -); -const MessageType2 ParserMessages::attributeValueChar( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -120 -#ifndef SP_NO_MESSAGE_TEXT -,"character %1 is not allowed in the value of attribute %2" -#endif -); -const MessageType1 ParserMessages::attributeValueMultiple( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -121 -#ifndef SP_NO_MESSAGE_TEXT -,"value of attribute %1 must be a single token" -#endif -); -const MessageType2 ParserMessages::attributeValueNumberToken( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -122 -#ifndef SP_NO_MESSAGE_TEXT -,"value of attribute %2 invalid: %1 cannot start a number token" -#endif -); -const MessageType2 ParserMessages::attributeValueName( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -123 -#ifndef SP_NO_MESSAGE_TEXT -,"value of attribute %2 invalid: %1 cannot start a name" -#endif -); -const MessageType1 ParserMessages::attributeMissing( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -124 -#ifndef SP_NO_MESSAGE_TEXT -,"non-impliable attribute %1 not specified but OMITTAG NO and SHORTTAG NO" -#endif -); -const MessageType1 ParserMessages::requiredAttributeMissing( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -125 -#ifndef SP_NO_MESSAGE_TEXT -,"required attribute %1 not specified" -#endif -); -const MessageType1 ParserMessages::currentAttributeMissing( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -126 -#ifndef SP_NO_MESSAGE_TEXT -,"first occurrence of current attribute %1 not specified" -#endif -); -const MessageType1 ParserMessages::invalidNotationAttribute( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -127 -#ifndef SP_NO_MESSAGE_TEXT -,"%1 is not a notation name" -#endif -); -const MessageType1 ParserMessages::invalidEntityAttribute( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -128 -#ifndef SP_NO_MESSAGE_TEXT -,"%1 is not a general entity name" -#endif -); -const MessageType3 ParserMessages::attributeValueNotInGroup( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -129 -#ifndef SP_NO_MESSAGE_TEXT -,"value of attribute %2 cannot be %1; must be one of %3" -#endif -); -const MessageType1 ParserMessages::notDataOrSubdocEntity( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -130 -#ifndef SP_NO_MESSAGE_TEXT -,"%1 is not a data or subdocument entity" -#endif -); -const MessageType3 ParserMessages::ambiguousModelInitial( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -131 -#ifndef SP_NO_MESSAGE_TEXT -,"content model is ambiguous: when no tokens have been matched, both the %2 and %3 occurrences of %1 are possible" -#endif -); -const MessageType5 ParserMessages::ambiguousModel( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -132 -#ifndef SP_NO_MESSAGE_TEXT -,"content model is ambiguous: when the current token is the %2 occurrence of %1, both the %4 and %5 occurrences of %3 are possible" -#endif -); -const MessageType5 ParserMessages::ambiguousModelSingleAnd( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -133 -#ifndef SP_NO_MESSAGE_TEXT -,"content model is ambiguous: when the current token is the %2 occurrence of %1 and the innermost containing and group has been matched, both the %4 and %5 occurrences of %3 are possible" -#endif -); -const MessageType6 ParserMessages::ambiguousModelMultipleAnd( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -134 -#ifndef SP_NO_MESSAGE_TEXT -,"content model is ambiguous: when the current token is the %2 occurrence of %1 and the innermost %3 containing and groups have been matched, both the %5 and %6 occurrences of %4 are possible" -#endif -); -const MessageType1L ParserMessages::commentDeclarationCharacter( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -135 -#ifndef SP_NO_MESSAGE_TEXT -,"invalid comment declaration: found character %1 outside comment but inside comment declaration" -,"comment declaration started here" -#endif -); -const MessageType1 ParserMessages::nonSgmlCharacter( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -137 -#ifndef SP_NO_MESSAGE_TEXT -,"non SGML character number %1" -#endif -); -const MessageType0 ParserMessages::dataMarkedSectionDeclSubset( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -138 -#ifndef SP_NO_MESSAGE_TEXT -,"data or replaceable character data in declaration subset" -#endif -); -const MessageType1L ParserMessages::duplicateId( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -139 -#ifndef SP_NO_MESSAGE_TEXT -,"ID %1 already defined" -,"ID %1 first defined here" -#endif -); -const MessageType1 ParserMessages::notFixedValue( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -141 -#ifndef SP_NO_MESSAGE_TEXT -,"value of fixed attribute %1 not equal to default" -#endif -); -const MessageType1 ParserMessages::sdCommentSignificant( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -142 -#ifndef SP_NO_MESSAGE_TEXT -,"character %1 is not significant in the reference concrete syntax and so cannot occur in a comment in the SGML declaration" -#endif -); -const MessageType1 ParserMessages::standardVersion( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -143 -#ifndef SP_NO_MESSAGE_TEXT -,"minimum data of first minimum literal in SGML declaration must be \"ISO 8879:1986\" not %1" -#endif -); -const MessageType1 ParserMessages::namingBeforeLcnmstrt( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -144 -#ifndef SP_NO_MESSAGE_TEXT -,"parameter before \"LCNMSTRT\" must be \"NAMING\" not %1" -#endif -); -const MessageType1 ParserMessages::sdEntityEnd( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -145 -#ifndef SP_NO_MESSAGE_TEXT -,"unexpected entity end in SGML declaration: only %1, S separators and comments allowed" -#endif -); -const MessageType2 ParserMessages::sdInvalidNameToken( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -146 -#ifndef SP_NO_MESSAGE_TEXT -,"%1 invalid: only %2 and parameter separators allowed" -#endif -); -const MessageType1 ParserMessages::numberTooBig( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -147 -#ifndef SP_NO_MESSAGE_TEXT -,"magnitude of %1 too big (length exceeds NAMELEN)" -#endif -); -const MessageType1 ParserMessages::sdLiteralSignificant( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -148 -#ifndef SP_NO_MESSAGE_TEXT -,"character %1 is not significant in the reference concrete syntax and so cannot occur in a literal in the SGML declaration except as the replacement of a character reference" -#endif -); -const MessageType1 ParserMessages::syntaxCharacterNumber( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -149 -#ifndef SP_NO_MESSAGE_TEXT -,"%1 is not a valid syntax reference character number" -#endif -); -const MessageType0 ParserMessages::sdParameterEntity( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -150 -#ifndef SP_NO_MESSAGE_TEXT -,"a parameter entity reference cannot occur in an SGML declaration" -#endif -); -const MessageType2 ParserMessages::sdParamInvalidToken( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -151 -#ifndef SP_NO_MESSAGE_TEXT -,"%1 invalid: only %2 and parameter separators are allowed" -#endif -); -const MessageType0 ParserMessages::giveUp( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -152 -#ifndef SP_NO_MESSAGE_TEXT -,"cannot continue because of previous errors" -#endif -); -const MessageType1 ParserMessages::sdMissingCharacters( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -153 -#ifndef SP_NO_MESSAGE_TEXT -,"SGML declaration cannot be parsed because the character set does not contain characters having the following numbers in ISO 646: %1" -#endif -); -const MessageType1 ParserMessages::missingMinimumChars( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -154 -#ifndef SP_NO_MESSAGE_TEXT -,"the specified character set is invalid because it does not contain the minimum data characters having the following numbers in ISO 646: %1" -#endif -); -const MessageType1 ParserMessages::duplicateCharNumbers( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -155 -#ifndef SP_NO_MESSAGE_TEXT -,"character numbers declared more than once: %1" -#endif -); -const MessageType1 ParserMessages::codeSetHoles( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -156 -#ifndef SP_NO_MESSAGE_TEXT -,"character numbers should have been declared UNUSED: %1" -#endif -); -const MessageType1 ParserMessages::basesetCharsMissing( -MessageType::warning, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -157 -#ifndef SP_NO_MESSAGE_TEXT -,"character numbers missing in base set: %1" -#endif -); -const MessageType1 ParserMessages::documentCharMax( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -158 -#ifndef SP_NO_MESSAGE_TEXT -,"this system requires that characters in the document character set not have numbers exceeding %1" -#endif -); -const MessageType1 ParserMessages::fpiMissingField( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -159 -#ifndef SP_NO_MESSAGE_TEXT -,"invalid formal public identifier %1: missing //" -#endif -); -const MessageType1 ParserMessages::fpiMissingTextClassSpace( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -160 -#ifndef SP_NO_MESSAGE_TEXT -,"invalid formal public identifier %1: no SPACE after public text class" -#endif -); -const MessageType1 ParserMessages::fpiInvalidTextClass( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -161 -#ifndef SP_NO_MESSAGE_TEXT -,"invalid formal public identifier %1: invalid public text class" -#endif -); -const MessageType1 ParserMessages::fpiInvalidLanguage( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -162 -#ifndef SP_NO_MESSAGE_TEXT -,"invalid formal public identifier %1: public text language must be a name containing only upper case letters" -#endif -); -const MessageType1 ParserMessages::fpiIllegalDisplayVersion( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -163 -#ifndef SP_NO_MESSAGE_TEXT -,"invalid formal public identifier %1: public text display version not permitted with this text class" -#endif -); -const MessageType1 ParserMessages::fpiExtraField( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -164 -#ifndef SP_NO_MESSAGE_TEXT -,"invalid formal public identifier %1: extra field" -#endif -); -const MessageType0 ParserMessages::notationIdentifierTextClass( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -165 -#ifndef SP_NO_MESSAGE_TEXT -,"public text class of public identifier in notation identifier must be NOTATION" -#endif -); -const MessageType1 ParserMessages::unknownBaseset( -MessageType::warning, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -166 -#ifndef SP_NO_MESSAGE_TEXT -,"base character set %1 is unknown" -#endif -); -const MessageType2 ParserMessages::lexicalAmbiguity( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -167 -#ifndef SP_NO_MESSAGE_TEXT -,"delimiter set is ambiguous: %1 and %2 can be recognized in the same mode" -#endif -); -const MessageType1 ParserMessages::translateSyntaxChar( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -168 -#ifndef SP_NO_MESSAGE_TEXT -,"there is no unique character in the document character set corresponding to character number %1 in the syntax reference character set" -#endif -); -const MessageType1 ParserMessages::missingSignificant( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -169 -#ifndef SP_NO_MESSAGE_TEXT -,"characters with the following numbers in the syntax reference character set are significant in the concrete syntax but are not in the document character set: %1" -#endif -); -const MessageType1 ParserMessages::missingSyntaxChar( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -170 -#ifndef SP_NO_MESSAGE_TEXT -,"the character with number %1 in ISO 646 is significant but has no representation in the syntax reference character set" -#endif -); -const MessageType1 ParserMessages::unknownCapacitySet( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -171 -#ifndef SP_NO_MESSAGE_TEXT -,"capacity set %1 is unknown" -#endif -); -const MessageType1 ParserMessages::duplicateCapacity( -MessageType::warning, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -172 -#ifndef SP_NO_MESSAGE_TEXT -,"capacity %1 already specified" -#endif -); -const MessageType1 ParserMessages::capacityExceedsTotalcap( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -173 -#ifndef SP_NO_MESSAGE_TEXT -,"value of capacity %1 exceeds value of TOTALCAP" -#endif -); -const MessageType1 ParserMessages::unknownPublicSyntax( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -174 -#ifndef SP_NO_MESSAGE_TEXT -,"syntax %1 is unknown" -#endif -); -const MessageType0 ParserMessages::nmstrtLength( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -175 -#ifndef SP_NO_MESSAGE_TEXT -,"UCNMSTRT must have the same number of characters as LCNMSTRT" -#endif -); -const MessageType0 ParserMessages::nmcharLength( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -176 -#ifndef SP_NO_MESSAGE_TEXT -,"UCNMCHAR must have the same number of characters as LCNMCHAR" -#endif -); -const MessageType1 ParserMessages::subdocLevel( -MessageType::quantityError, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -177 -#ifndef SP_NO_MESSAGE_TEXT -,"number of open subdocuments exceeds quantity specified for SUBDOC parameter in SGML declaration (%1)" -#endif -); -const MessageType1 ParserMessages::subdocEntity( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -178 -#ifndef SP_NO_MESSAGE_TEXT -,"entity %1 declared SUBDOC, but SUBDOC NO specified in SGML declaration" -#endif -); -const MessageType0 ParserMessages::parameterEntityNotEnded( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -179 -#ifndef SP_NO_MESSAGE_TEXT -,"a parameter entity referenced in a parameter separator must end in the same declaration" -#endif -); -const MessageType1 ParserMessages::missingId( -MessageType::idrefError, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -180 -#ifndef SP_NO_MESSAGE_TEXT -,"reference to non-existent ID %1" -#endif -); -const MessageType1 ParserMessages::dtdUndefinedElement( -MessageType::warning, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -181 -#ifndef SP_NO_MESSAGE_TEXT -,"generic identifier %1 used in DTD but not defined" -#endif -); -const MessageType1 ParserMessages::elementNotFinishedDocumentEnd( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -182 -#ifndef SP_NO_MESSAGE_TEXT -,"%1 not finished but document ended" -#endif -); -const MessageType0 ParserMessages::subdocGiveUp( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -183 -#ifndef SP_NO_MESSAGE_TEXT -,"cannot continue with subdocument because of previous errors" -#endif -); -const MessageType0 ParserMessages::noDtd( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -184 -#ifndef SP_NO_MESSAGE_TEXT -,"could not find document type declaration" -#endif -); -const MessageType1 ParserMessages::taglen( -MessageType::quantityError, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -185 -#ifndef SP_NO_MESSAGE_TEXT -,"length of start-tag before interpretation of literals must not exceed TAGLEN (%1)" -#endif -); -const MessageType0 ParserMessages::groupParameterEntityNotEnded( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -186 -#ifndef SP_NO_MESSAGE_TEXT -,"a parameter entity referenced in a token separator must end in the same group" -#endif -); -const MessageType1 ParserMessages::invalidSgmlChar( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -187 -#ifndef SP_NO_MESSAGE_TEXT -,"the following character numbers are shunned characters that are not significant and so should have been declared UNUSED: %1" -#endif -); -const MessageType1 ParserMessages::translateDocChar( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -188 -#ifndef SP_NO_MESSAGE_TEXT -,"there is no unique character in the specified document character set corresponding to character number %1 in ISO 646" -#endif -); -const MessageType1 ParserMessages::attributeValueLengthNeg( -MessageType::quantityError, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -189 -#ifndef SP_NO_MESSAGE_TEXT -,"length of attribute value must not exceed LITLEN less NORMSEP (-%1)" -#endif -); -const MessageType1 ParserMessages::tokenizedAttributeValueLengthNeg( -MessageType::quantityError, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -190 -#ifndef SP_NO_MESSAGE_TEXT -,"length of tokenized attribute value must not exceed LITLEN less NORMSEP (-%1)" -#endif -); -const MessageType1 ParserMessages::scopeInstanceQuantity( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -191 -#ifndef SP_NO_MESSAGE_TEXT -,"concrete syntax scope is INSTANCE but value of %1 quantity is less than value in reference quantity set" -#endif -); -const MessageType1 ParserMessages::basesetTextClass( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -192 -#ifndef SP_NO_MESSAGE_TEXT -,"public text class of formal public identifier of base character set must be CHARSET" -#endif -); -const MessageType1 ParserMessages::capacityTextClass( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -193 -#ifndef SP_NO_MESSAGE_TEXT -,"public text class of formal public identifier of capacity set must be CAPACITY" -#endif -); -const MessageType1 ParserMessages::syntaxTextClass( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -194 -#ifndef SP_NO_MESSAGE_TEXT -,"public text class of formal public identifier of concrete syntax must be SYNTAX" -#endif -); -const MessageType0 ParserMessages::msocharRequiresMsichar( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -195 -#ifndef SP_NO_MESSAGE_TEXT -,"when there is an MSOCHAR there must also be an MSICHAR" -#endif -); -const MessageType1 ParserMessages::switchNotMarkup( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -196 -#ifndef SP_NO_MESSAGE_TEXT -,"character number %1 in the syntax reference character set was specified as a character to be switched but is not a markup character" -#endif -); -const MessageType1 ParserMessages::switchNotInCharset( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -197 -#ifndef SP_NO_MESSAGE_TEXT -,"character number %1 was specified as a character to be switched but is not in the syntax reference character set" -#endif -); -const MessageType1 ParserMessages::ambiguousDocCharacter( -MessageType::warning, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -198 -#ifndef SP_NO_MESSAGE_TEXT -,"character numbers %1 in the document character set have been assigned the same meaning, but this is the meaning of a significant character" -#endif -); -const MessageType1 ParserMessages::oneFunction( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -199 -#ifndef SP_NO_MESSAGE_TEXT -,"character number %1 assigned to more than one function" -#endif -); -const MessageType1 ParserMessages::duplicateFunctionName( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -200 -#ifndef SP_NO_MESSAGE_TEXT -,"%1 is already a function name" -#endif -); -const MessageType1 ParserMessages::missingSignificant646( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -201 -#ifndef SP_NO_MESSAGE_TEXT -,"characters with the following numbers in ISO 646 are significant in the concrete syntax but are not in the document character set: %1" -#endif -); -const MessageType1 ParserMessages::generalDelimAllFunction( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -202 -#ifndef SP_NO_MESSAGE_TEXT -,"general delimiter %1 consists solely of function characters" -#endif -); -const MessageType1 ParserMessages::nmcharLetter( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -203 -#ifndef SP_NO_MESSAGE_TEXT -,"letters assigned to LCNMCHAR, UCNMCHAR, LCNMSTRT or UCNMSTRT: %1" -#endif -); -const MessageType1 ParserMessages::nmcharDigit( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -204 -#ifndef SP_NO_MESSAGE_TEXT -,"digits assigned to LCNMCHAR, UCNMCHAR, LCNMSTRT or UCNMSTRT: %1" -#endif -); -const MessageType1 ParserMessages::nmcharRe( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -205 -#ifndef SP_NO_MESSAGE_TEXT -,"character number %1 cannot be assigned to LCNMCHAR, UCNMCHAR, LCNMSTRT or UCNMSTRT because it is RE" -#endif -); -const MessageType1 ParserMessages::nmcharRs( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -206 -#ifndef SP_NO_MESSAGE_TEXT -,"character number %1 cannot be assigned to LCNMCHAR, UCNMCHAR, LCNMSTRT or UCNMSTRT because it is RS" -#endif -); -const MessageType1 ParserMessages::nmcharSpace( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -207 -#ifndef SP_NO_MESSAGE_TEXT -,"character number %1 cannot be assigned to LCNMCHAR, UCNMCHAR, LCNMSTRT or UCNMSTRT because it is SPACE" -#endif -); -const MessageType1 ParserMessages::nmcharSepchar( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -208 -#ifndef SP_NO_MESSAGE_TEXT -,"separator characters assigned to LCNMCHAR, UCNMCHAR, LCNMSTRT or UCNMSTRT: %1" -#endif -); -const MessageType1 ParserMessages::switchLetterDigit( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -209 -#ifndef SP_NO_MESSAGE_TEXT -,"character number %1 cannot be switched because it is a Digit, LC Letter or UC Letter" -#endif -); -const MessageType0 ParserMessages::zeroNumberOfCharacters( -MessageType::warning, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -210 -#ifndef SP_NO_MESSAGE_TEXT -,"pointless for number of characters to be 0" -#endif -); -const MessageType1 ParserMessages::nameReferenceReservedName( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -211 -#ifndef SP_NO_MESSAGE_TEXT -,"%1 cannot be the replacement for a reference reserved name because it is another reference reserved name" -#endif -); -const MessageType1 ParserMessages::ambiguousReservedName( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -212 -#ifndef SP_NO_MESSAGE_TEXT -,"%1 cannot be the replacement for a reference reserved name because it is the replacement of another reference reserved name" -#endif -); -const MessageType1 ParserMessages::duplicateReservedName( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -213 -#ifndef SP_NO_MESSAGE_TEXT -,"replacement for reserved name %1 already specified" -#endif -); -const MessageType1 ParserMessages::reservedNameSyntax( -MessageType::warning, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -214 -#ifndef SP_NO_MESSAGE_TEXT -,"%1 is not a valid name in the declared concrete syntax" -#endif -); -const MessageType1 ParserMessages::multipleBSequence( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -215 -#ifndef SP_NO_MESSAGE_TEXT -,"%1 is not a valid short reference delimiter because it has more than one B sequence" -#endif -); -const MessageType1 ParserMessages::blankAdjacentBSequence( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -216 -#ifndef SP_NO_MESSAGE_TEXT -,"%1 is not a valid short reference delimiter because it is adjacent to a character that can occur in a blank sequence" -#endif -); -const MessageType2 ParserMessages::delimiterLength( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -217 -#ifndef SP_NO_MESSAGE_TEXT -,"length of delimiter %1 exceeds NAMELEN (%2)" -#endif -); -const MessageType2 ParserMessages::reservedNameLength( -MessageType::warning, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -218 -#ifndef SP_NO_MESSAGE_TEXT -,"length of reserved name %1 exceeds NAMELEN (%2)" -#endif -); -const MessageType1 ParserMessages::nmcharNmstrt( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -219 -#ifndef SP_NO_MESSAGE_TEXT -,"character numbers assigned to both LCNMCHAR or UCNMCHAR and LCNMSTRT or UCNMSTRT: %1" -#endif -); -const MessageType0 ParserMessages::scopeInstanceSyntaxCharset( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -220 -#ifndef SP_NO_MESSAGE_TEXT -,"when the concrete syntax scope is INSTANCE the syntax reference character set of the declared syntax must be the same as that of the reference concrete syntax" -#endif -); -const MessageType0 ParserMessages::emptyOmitEndTag( -MessageType::warning, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -221 -#ifndef SP_NO_MESSAGE_TEXT -,"end-tag minimization should be \"O\" for element with declared content of EMPTY" -#endif -); -const MessageType1 ParserMessages::conrefOmitEndTag( -MessageType::warning, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -222 -#ifndef SP_NO_MESSAGE_TEXT -,"end-tag minimization should be \"O\" for element %1 because it has CONREF attribute" -#endif -); -const MessageType1 ParserMessages::conrefEmpty( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -223 -#ifndef SP_NO_MESSAGE_TEXT -,"element %1 has a declared content of EMPTY and a CONREF attribute" -#endif -); -const MessageType1 ParserMessages::notationEmpty( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -224 -#ifndef SP_NO_MESSAGE_TEXT -,"element %1 has a declared content of EMPTY and a NOTATION attribute" -#endif -); -const MessageType0 ParserMessages::dataAttributeDeclaredValue( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -225 -#ifndef SP_NO_MESSAGE_TEXT -,"declared value of data attribute cannot be ENTITY, ENTITIES, ID, IDREF, IDREFS or NOTATION" -#endif -); -const MessageType0 ParserMessages::dataAttributeDefaultValue( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -226 -#ifndef SP_NO_MESSAGE_TEXT -,"default value of data attribute cannot be CONREF or CURRENT" -#endif -); -const MessageType2 ParserMessages::attcnt( -MessageType::quantityError, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -227 -#ifndef SP_NO_MESSAGE_TEXT -,"number of attribute names and name tokens (%1) exceeds ATTCNT (%2)" -#endif -); -const MessageType0 ParserMessages::idDeclaredValue( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -228 -#ifndef SP_NO_MESSAGE_TEXT -,"if the declared value is ID the default value must be IMPLIED or REQUIRED" -#endif -); -const MessageType1 ParserMessages::multipleIdAttributes( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -229 -#ifndef SP_NO_MESSAGE_TEXT -,"the attribute definition list already declared attribute %1 as the ID attribute" -#endif -); -const MessageType1 ParserMessages::multipleNotationAttributes( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -230 -#ifndef SP_NO_MESSAGE_TEXT -,"the attribute definition list already declared attribute %1 as the NOTATION attribute" -#endif -); -const MessageType1 ParserMessages::duplicateAttributeToken( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -231 -#ifndef SP_NO_MESSAGE_TEXT -,"token %1 occurs more than once in attribute definition list" -#endif -); -const MessageType1 ParserMessages::notationNoAttributes( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -232 -#ifndef SP_NO_MESSAGE_TEXT -,"no attributes defined for notation %1" -#endif -); -const MessageType2 ParserMessages::entityNotationUndefined( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -233 -#ifndef SP_NO_MESSAGE_TEXT -,"notation %1 for entity %2 undefined" -#endif -); -const MessageType2 ParserMessages::mapEntityUndefined( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -234 -#ifndef SP_NO_MESSAGE_TEXT -,"entity %1 undefined in short reference map %2" -#endif -); -const MessageType1 ParserMessages::attlistNotationUndefined( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -235 -#ifndef SP_NO_MESSAGE_TEXT -,"notation %1 is undefined but had attribute definition" -#endif -); -const MessageType1 ParserMessages::bracketedLitlen( -MessageType::quantityError, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -236 -#ifndef SP_NO_MESSAGE_TEXT -,"length of interpreted parameter literal in bracketed text plus the length of the bracketing delimiters must not exceed LITLEN (%1)" -#endif -); -const MessageType1 ParserMessages::genericIdentifierLength( -MessageType::quantityError, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -237 -#ifndef SP_NO_MESSAGE_TEXT -,"length of rank stem plus length of rank suffix must not exceed NAMELEN (%1)" -#endif -); -const MessageType0 ParserMessages::instanceStartOmittag( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -238 -#ifndef SP_NO_MESSAGE_TEXT -,"document instance must start with document element" -#endif -); -const MessageType1 ParserMessages::grplvl( -MessageType::quantityError, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -239 -#ifndef SP_NO_MESSAGE_TEXT -,"content model nesting level exceeds GRPLVL (%1)" -#endif -); -const MessageType1 ParserMessages::grpgtcnt( -MessageType::quantityError, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -240 -#ifndef SP_NO_MESSAGE_TEXT -,"grand total of content tokens exceeds GRPGTCNT (%1)" -#endif -); -const MessageType0 ParserMessages::minimizedStartTag( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -241 -#ifndef SP_NO_MESSAGE_TEXT -,"minimized start-tag requires SHORTTAG YES" -#endif -); -const MessageType0 ParserMessages::minimizedEndTag( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -242 -#ifndef SP_NO_MESSAGE_TEXT -,"minimized end-tag requires SHORTTAG YES" -#endif -); -const MessageType0 ParserMessages::multipleDtds( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -243 -#ifndef SP_NO_MESSAGE_TEXT -,"DTDs other than base allowed only if CONCUR YES or EXPLICIT YES" -#endif -); -const MessageType0 ParserMessages::afterDocumentElementEntityEnd( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -244 -#ifndef SP_NO_MESSAGE_TEXT -,"end of entity other than document entity after document element" -#endif -); -const MessageType1 ParserMessages::declarationAfterDocumentElement( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -245 -#ifndef SP_NO_MESSAGE_TEXT -,"%1 declaration illegal after document element" -#endif -); -const MessageType0 ParserMessages::characterReferenceAfterDocumentElement( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -246 -#ifndef SP_NO_MESSAGE_TEXT -,"character reference illegal after document element" -#endif -); -const MessageType0 ParserMessages::entityReferenceAfterDocumentElement( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -247 -#ifndef SP_NO_MESSAGE_TEXT -,"entity reference illegal after document element" -#endif -); -const MessageType0 ParserMessages::markedSectionAfterDocumentElement( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -248 -#ifndef SP_NO_MESSAGE_TEXT -,"marked section illegal after document element" -#endif -); -const MessageType3 ParserMessages::requiredElementExcluded( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -249 -#ifndef SP_NO_MESSAGE_TEXT -,"the %1 occurrence of %2 in the content model for %3 cannot be excluded at this point because it is contextually required" -#endif -); -const MessageType3 ParserMessages::invalidExclusion( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -250 -#ifndef SP_NO_MESSAGE_TEXT -,"the %1 occurrence of %2 in the content model for %3 cannot be excluded because it is neither inherently optional nor a member of an or group" -#endif -); -const MessageType0 ParserMessages::attributeValueShorttag( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -251 -#ifndef SP_NO_MESSAGE_TEXT -,"an attribute value specification must be an attribute value literal unless SHORTTAG YES is specified" -#endif -); -const MessageType0 ParserMessages::conrefNotation( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -252 -#ifndef SP_NO_MESSAGE_TEXT -,"value cannot be specified both for notation attribute and content reference attribute" -#endif -); -const MessageType1 ParserMessages::duplicateNotationDeclaration( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -253 -#ifndef SP_NO_MESSAGE_TEXT -,"notation %1 already defined" -#endif -); -const MessageType1L ParserMessages::duplicateShortrefDeclaration( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -254 -#ifndef SP_NO_MESSAGE_TEXT -,"short reference map %1 already defined" -,"first defined here" -#endif -); -const MessageType1 ParserMessages::duplicateDelimGeneral( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -256 -#ifndef SP_NO_MESSAGE_TEXT -,"general delimiter role %1 already defined" -#endif -); -const MessageType1 ParserMessages::idrefGrpcnt( -MessageType::quantityError, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -257 -#ifndef SP_NO_MESSAGE_TEXT -,"number of id references in start-tag must not exceed GRPCNT (%1)" -#endif -); -const MessageType1 ParserMessages::entityNameGrpcnt( -MessageType::quantityError, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -258 -#ifndef SP_NO_MESSAGE_TEXT -,"number of entity names in attribute specification list must not exceed GRPCNT (%1)" -#endif -); -const MessageType2 ParserMessages::attsplen( -MessageType::quantityError, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -259 -#ifndef SP_NO_MESSAGE_TEXT -,"normalized length of attribute specification list must not exceed ATTSPLEN (%1); length was %2" -#endif -); -const MessageType1 ParserMessages::duplicateDelimShortref( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -260 -#ifndef SP_NO_MESSAGE_TEXT -,"short reference delimiter %1 already specified" -#endif -); -const MessageType1 ParserMessages::duplicateDelimShortrefSet( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -261 -#ifndef SP_NO_MESSAGE_TEXT -,"single character short references were already specified for character numbers: %1" -#endif -); -const MessageType1 ParserMessages::defaultEntityInAttribute( -MessageType::warning, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -262 -#ifndef SP_NO_MESSAGE_TEXT -,"default entity used in entity attribute %1" -#endif -); -const MessageType1 ParserMessages::defaultEntityReference( -MessageType::warning, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -263 -#ifndef SP_NO_MESSAGE_TEXT -,"reference to entity %1 uses default entity " -#endif -); -const MessageType2 ParserMessages::mapDefaultEntity( -MessageType::warning, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -264 -#ifndef SP_NO_MESSAGE_TEXT -,"entity %1 in short reference map %2 uses default entity" -#endif -); -const MessageType1 ParserMessages::noSuchDtd( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -265 -#ifndef SP_NO_MESSAGE_TEXT -,"no DTD %1 declared" -#endif -); -const MessageType1 ParserMessages::noLpdSubset( -MessageType::warning, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -266 -#ifndef SP_NO_MESSAGE_TEXT -,"LPD %1 has neither internal nor external subset" -#endif -); -const MessageType0 ParserMessages::assocElementDifferentAtts( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -267 -#ifndef SP_NO_MESSAGE_TEXT -,"element types have different link attribute definitions" -#endif -); -const MessageType1 ParserMessages::duplicateLinkSet( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -268 -#ifndef SP_NO_MESSAGE_TEXT -,"link set %1 already defined" -#endif -); -const MessageType0 ParserMessages::emptyResultAttributeSpec( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -269 -#ifndef SP_NO_MESSAGE_TEXT -,"empty result attribute specification" -#endif -); -const MessageType1 ParserMessages::noSuchSourceElement( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -270 -#ifndef SP_NO_MESSAGE_TEXT -,"no source element type %1" -#endif -); -const MessageType1 ParserMessages::noSuchResultElement( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -271 -#ifndef SP_NO_MESSAGE_TEXT -,"no result element type %1" -#endif -); -const MessageType0 ParserMessages::documentEndLpdSubset( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -272 -#ifndef SP_NO_MESSAGE_TEXT -,"end of document in LPD subset" -#endif -); -const MessageType1 ParserMessages::lpdSubsetDeclaration( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -273 -#ifndef SP_NO_MESSAGE_TEXT -,"%1 declaration not allowed in LPD subset" -#endif -); -const MessageType0 ParserMessages::idlinkDeclSimple( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -274 -#ifndef SP_NO_MESSAGE_TEXT -,"ID link set declaration not allowed in simple link declaration subset" -#endif -); -const MessageType0 ParserMessages::linkDeclSimple( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -275 -#ifndef SP_NO_MESSAGE_TEXT -,"link set declaration not allowed in simple link declaration subset" -#endif -); -const MessageType1 ParserMessages::simpleLinkAttlistElement( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -276 -#ifndef SP_NO_MESSAGE_TEXT -,"attributes can only be defined for base document element (not %1) in simple link declaration subset" -#endif -); -const MessageType0 ParserMessages::shortrefOnlyInBaseDtd( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -277 -#ifndef SP_NO_MESSAGE_TEXT -,"a short reference mapping declaration is allowed only in the base DTD" -#endif -); -const MessageType0 ParserMessages::usemapOnlyInBaseDtd( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -278 -#ifndef SP_NO_MESSAGE_TEXT -,"a short reference use declaration is allowed only in the base DTD" -#endif -); -const MessageType0 ParserMessages::linkAttributeDefaultValue( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -279 -#ifndef SP_NO_MESSAGE_TEXT -,"default value of link attribute cannot be CURRENT or CONREF" -#endif -); -const MessageType0 ParserMessages::linkAttributeDeclaredValue( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -280 -#ifndef SP_NO_MESSAGE_TEXT -,"declared value of link attribute cannot be ID, IDREF, IDREFS or NOTATION" -#endif -); -const MessageType0 ParserMessages::simpleLinkFixedAttribute( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -281 -#ifndef SP_NO_MESSAGE_TEXT -,"only fixed attributes can be defined in simple LPD" -#endif -); -const MessageType0 ParserMessages::duplicateIdLinkSet( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -282 -#ifndef SP_NO_MESSAGE_TEXT -,"only one ID link set declaration allowed in an LPD subset" -#endif -); -const MessageType1 ParserMessages::noInitialLinkSet( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -283 -#ifndef SP_NO_MESSAGE_TEXT -,"no initial link set defined for LPD %1" -#endif -); -const MessageType1 ParserMessages::notationUndefinedSourceDtd( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -284 -#ifndef SP_NO_MESSAGE_TEXT -,"notation %1 not defined in source DTD" -#endif -); -const MessageType0 ParserMessages::simpleLinkResultNotImplied( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -285 -#ifndef SP_NO_MESSAGE_TEXT -,"result document type in simple link specification must be implied" -#endif -); -const MessageType0 ParserMessages::simpleLinkFeature( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -286 -#ifndef SP_NO_MESSAGE_TEXT -,"simple link requires SIMPLE YES" -#endif -); -const MessageType0 ParserMessages::implicitLinkFeature( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -287 -#ifndef SP_NO_MESSAGE_TEXT -,"implicit link requires IMPLICIT YES" -#endif -); -const MessageType0 ParserMessages::explicitLinkFeature( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -288 -#ifndef SP_NO_MESSAGE_TEXT -,"explicit link requires EXPLICIT YES" -#endif -); -const MessageType0 ParserMessages::lpdBeforeBaseDtd( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -289 -#ifndef SP_NO_MESSAGE_TEXT -,"LPD not allowed before first DTD" -#endif -); -const MessageType0 ParserMessages::dtdAfterLpd( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -290 -#ifndef SP_NO_MESSAGE_TEXT -,"DTD not allowed after an LPD" -#endif -); -const MessageType1 ParserMessages::unstableLpdGeneralEntity( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -291 -#ifndef SP_NO_MESSAGE_TEXT -,"definition of general entity %1 is unstable" -#endif -); -const MessageType1 ParserMessages::unstableLpdParameterEntity( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -292 -#ifndef SP_NO_MESSAGE_TEXT -,"definition of parameter entity %1 is unstable" -#endif -); -const MessageType1 ParserMessages::multipleIdLinkRuleAttribute( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -293 -#ifndef SP_NO_MESSAGE_TEXT -,"multiple link rules for ID %1 but not all have link attribute specifications" -#endif -); -const MessageType1 ParserMessages::multipleLinkRuleAttribute( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -294 -#ifndef SP_NO_MESSAGE_TEXT -,"multiple link rules for element type %1 but not all have link attribute specifications" -#endif -); -const MessageType2 ParserMessages::uselinkBadLinkSet( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -295 -#ifndef SP_NO_MESSAGE_TEXT -,"link type %1 does not have a link set %2" -#endif -); -const MessageType1 ParserMessages::uselinkSimpleLpd( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -296 -#ifndef SP_NO_MESSAGE_TEXT -,"link set use declaration for simple link process" -#endif -); -const MessageType1 ParserMessages::uselinkBadLinkType( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -297 -#ifndef SP_NO_MESSAGE_TEXT -,"no link type %1" -#endif -); -const MessageType1 ParserMessages::duplicateDtdLpd( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -298 -#ifndef SP_NO_MESSAGE_TEXT -,"both document type and link type %1" -#endif -); -const MessageType1 ParserMessages::duplicateLpd( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -299 -#ifndef SP_NO_MESSAGE_TEXT -,"link type %1 already defined" -#endif -); -const MessageType1 ParserMessages::duplicateDtd( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -300 -#ifndef SP_NO_MESSAGE_TEXT -,"document type %1 already defined" -#endif -); -const MessageType1 ParserMessages::undefinedLinkSet( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -301 -#ifndef SP_NO_MESSAGE_TEXT -,"link set %1 used in LPD but not defined" -#endif -); -const MessageType1 ParserMessages::duplicateImpliedResult( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -302 -#ifndef SP_NO_MESSAGE_TEXT -,"#IMPLIED already linked to result element type %1" -#endif -); -const MessageType1 ParserMessages::simpleLinkCount( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -303 -#ifndef SP_NO_MESSAGE_TEXT -,"number of active simple link processes exceeds quantity specified for SIMPLE parameter in SGML declaration (%1)" -#endif -); -const MessageType0 ParserMessages::duplicateExplicitChain( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -304 -#ifndef SP_NO_MESSAGE_TEXT -,"only one chain of explicit link processes can be active" -#endif -); -const MessageType1 ParserMessages::explicit1RequiresSourceTypeBase( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -305 -#ifndef SP_NO_MESSAGE_TEXT -,"source document type name for link type %1 must be base document type since EXPLICIT YES 1" -#endif -); -const MessageType0 ParserMessages::oneImplicitLink( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -306 -#ifndef SP_NO_MESSAGE_TEXT -,"one one implicit link process can be active" -#endif -); -const MessageType1 ParserMessages::sorryLink( -MessageType::warning, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -307 -#ifndef SP_NO_MESSAGE_TEXT -,"sorry, link type %1 not activated: only one implicit or explicit link process can be active (with base document type as source document type)" -#endif -); -const MessageType0 ParserMessages::entityReferenceMissingName( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -308 -#ifndef SP_NO_MESSAGE_TEXT -,"name missing after name group in entity reference" -#endif -); -const MessageType1 ParserMessages::explicitNoRequiresSourceTypeBase( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -309 -#ifndef SP_NO_MESSAGE_TEXT -,"source document type name for link type %1 must be base document type since EXPLICIT NO" -#endif -); -const MessageType0 ParserMessages::linkActivateTooLate( -MessageType::warning, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -310 -#ifndef SP_NO_MESSAGE_TEXT -,"link process must be activated before base DTD" -#endif -); -const MessageType0 ParserMessages::pass2Ee( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -311 -#ifndef SP_NO_MESSAGE_TEXT -,"unexpected entity end while starting second pass" -#endif -); -const MessageType2 ParserMessages::idlinkElementType( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -312 -#ifndef SP_NO_MESSAGE_TEXT -,"type %1 of element with ID %2 not associated element type for applicable link rule in ID link set" -#endif -); -const MessageType0 ParserMessages::datatagNotImplemented( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -313 -#ifndef SP_NO_MESSAGE_TEXT -,"DATATAG feature not implemented" -#endif -); -const MessageType0 ParserMessages::startTagMissingName( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -314 -#ifndef SP_NO_MESSAGE_TEXT -,"generic identifier specification missing after document type specification in start-tag" -#endif -); -const MessageType0 ParserMessages::endTagMissingName( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -315 -#ifndef SP_NO_MESSAGE_TEXT -,"generic identifier specification missing after document type specification in end-tag" -#endif -); -const MessageType0 ParserMessages::startTagGroupNet( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -316 -#ifndef SP_NO_MESSAGE_TEXT -,"a net-enabling start-tag cannot include a document type specification" -#endif -); -const MessageType0 ParserMessages::documentElementUndefined( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -317 -#ifndef SP_NO_MESSAGE_TEXT -,"DTD did not contain element declaration for document type name" -#endif -); -const MessageType0 ParserMessages::badDefaultSgmlDecl( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -318 -#ifndef SP_NO_MESSAGE_TEXT -,"invalid default SGML declaration" -#endif -); -const MessageType1L ParserMessages::nonExistentEntityRef( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -319 -#ifndef SP_NO_MESSAGE_TEXT -,"reference to entity %1 for which no system identifier could be generated" -,"entity was defined here" -#endif -); -const MessageType0 ParserMessages::pcdataUnreachable( -MessageType::warning, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -321 -#ifndef SP_NO_MESSAGE_TEXT -,"content model is mixed but does not allow #PCDATA everywhere" -#endif -); -const MessageType0 ParserMessages::sdInvalidEllipsis( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -322 -#ifndef SP_NO_MESSAGE_TEXT -,"parameter must specify one character for each adjacent ellipsis" -#endif -); -const MessageType0 ParserMessages::sdInvalidRange( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -323 -#ifndef SP_NO_MESSAGE_TEXT -,"number of first character in range must not exceed number of second character in range" -#endif -); -const MessageType0 ParserMessages::sdEmptyDelimiter( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -324 -#ifndef SP_NO_MESSAGE_TEXT -,"delimiter cannot be an empty string" -#endif -); -const MessageType0 ParserMessages::tooManyCharsMinimumLiteral( -MessageType::warning, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -325 -#ifndef SP_NO_MESSAGE_TEXT -,"too many characters assigned same meaning with minimum literal" -#endif -); -const MessageType1 ParserMessages::defaultedEntityDefined( -MessageType::warning, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -326 -#ifndef SP_NO_MESSAGE_TEXT -,"earlier reference to entity %1 used default entity" -#endif -); -const MessageType0 ParserMessages::unclosedStartTag( -MessageType::warning, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -327 -#ifndef SP_NO_MESSAGE_TEXT -,"unclosed start-tag" -#endif -); -const MessageType0 ParserMessages::unclosedEndTag( -MessageType::warning, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -328 -#ifndef SP_NO_MESSAGE_TEXT -,"unclosed end-tag" -#endif -); -const MessageType0 ParserMessages::emptyStartTag( -MessageType::warning, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -329 -#ifndef SP_NO_MESSAGE_TEXT -,"empty start-tag" -#endif -); -const MessageType0 ParserMessages::emptyEndTag( -MessageType::warning, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -330 -#ifndef SP_NO_MESSAGE_TEXT -,"empty end-tag" -#endif -); -const MessageType0 ParserMessages::netStartTag( -MessageType::warning, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -331 -#ifndef SP_NO_MESSAGE_TEXT -,"net-enabling start-tag" -#endif -); -const MessageType0 ParserMessages::nullEndTag( -MessageType::warning, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -332 -#ifndef SP_NO_MESSAGE_TEXT -,"null end-tag" -#endif -); -const MessageType1 ParserMessages::unusedMap( -MessageType::warning, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -333 -#ifndef SP_NO_MESSAGE_TEXT -,"unused short reference map %1" -#endif -); -const MessageType1 ParserMessages::unusedParamEntity( -MessageType::warning, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -334 -#ifndef SP_NO_MESSAGE_TEXT -,"unused parameter entity %1" -#endif -); -const MessageType1 ParserMessages::cannotGenerateSystemIdPublic( -MessageType::warning, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -335 -#ifndef SP_NO_MESSAGE_TEXT -,"cannot generate system identifier for public text %1" -#endif -); -const MessageType1 ParserMessages::cannotGenerateSystemIdGeneral( -MessageType::warning, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -336 -#ifndef SP_NO_MESSAGE_TEXT -,"cannot generate system identifier for general entity %1" -#endif -); -const MessageType1 ParserMessages::cannotGenerateSystemIdParameter( -MessageType::warning, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -337 -#ifndef SP_NO_MESSAGE_TEXT -,"cannot generate system identifier for parameter entity %1" -#endif -); -const MessageType1 ParserMessages::cannotGenerateSystemIdDoctype( -MessageType::warning, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -338 -#ifndef SP_NO_MESSAGE_TEXT -,"cannot generate system identifier for document type %1" -#endif -); -const MessageType1 ParserMessages::cannotGenerateSystemIdLinktype( -MessageType::warning, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -339 -#ifndef SP_NO_MESSAGE_TEXT -,"cannot generate system identifier for link type %1" -#endif -); -const MessageType1 ParserMessages::cannotGenerateSystemIdNotation( -MessageType::warning, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -340 -#ifndef SP_NO_MESSAGE_TEXT -,"cannot generate system identifier for notation %1" -#endif -); -const MessageType1 ParserMessages::excludeIncludeSame( -MessageType::warning, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -341 -#ifndef SP_NO_MESSAGE_TEXT -,"element type %1 both included and excluded" -#endif -); -const MessageType1 ParserMessages::implyingDtd( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -342 -#ifndef SP_NO_MESSAGE_TEXT -,"no document type declaration; implying %1" -#endif -); -const MessageType1 ParserMessages::afdrVersion( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -343 -#ifndef SP_NO_MESSAGE_TEXT -,"minimum data of AFDR declaration must be \"ISO/IEC 10744:1992\" not %1" -#endif -); -const MessageType0 ParserMessages::missingAfdrDecl( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -344 -#ifndef SP_NO_MESSAGE_TEXT -,"AFDR declaration required before use of AFDR extensions" -#endif -); -const MessageFragment ParserMessages::delimStart( -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -1000 -#ifndef SP_NO_MESSAGE_TEXT -,"delimiter " -#endif -); -const MessageFragment ParserMessages::delimEnd( -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -1001 -#ifndef SP_NO_MESSAGE_TEXT -,"" -#endif -); -const MessageFragment ParserMessages::digit( -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -1002 -#ifndef SP_NO_MESSAGE_TEXT -,"digit" -#endif -); -const MessageFragment ParserMessages::nameStartCharacter( -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -1003 -#ifndef SP_NO_MESSAGE_TEXT -,"name start character" -#endif -); -const MessageFragment ParserMessages::sepchar( -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -1004 -#ifndef SP_NO_MESSAGE_TEXT -,"sepchar" -#endif -); -const MessageFragment ParserMessages::separator( -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -1005 -#ifndef SP_NO_MESSAGE_TEXT -,"separator" -#endif -); -const MessageFragment ParserMessages::nameCharacter( -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -1006 -#ifndef SP_NO_MESSAGE_TEXT -,"name character" -#endif -); -const MessageFragment ParserMessages::dataCharacter( -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -1007 -#ifndef SP_NO_MESSAGE_TEXT -,"data character" -#endif -); -const MessageFragment ParserMessages::minimumDataCharacter( -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -1008 -#ifndef SP_NO_MESSAGE_TEXT -,"minimum data character" -#endif -); -const MessageFragment ParserMessages::significantCharacter( -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -1009 -#ifndef SP_NO_MESSAGE_TEXT -,"significant character" -#endif -); -const MessageFragment ParserMessages::recordEnd( -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -1010 -#ifndef SP_NO_MESSAGE_TEXT -,"record end character" -#endif -); -const MessageFragment ParserMessages::recordStart( -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -1011 -#ifndef SP_NO_MESSAGE_TEXT -,"record start character" -#endif -); -const MessageFragment ParserMessages::space( -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -1012 -#ifndef SP_NO_MESSAGE_TEXT -,"space character" -#endif -); -const MessageFragment ParserMessages::listSep( -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -1013 -#ifndef SP_NO_MESSAGE_TEXT -,", " -#endif -); -const MessageFragment ParserMessages::rangeSep( -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -1014 -#ifndef SP_NO_MESSAGE_TEXT -,"-" -#endif -); -const MessageFragment ParserMessages::parameterLiteral( -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -1015 -#ifndef SP_NO_MESSAGE_TEXT -,"parameter literal" -#endif -); -const MessageFragment ParserMessages::dataTagGroup( -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -1016 -#ifndef SP_NO_MESSAGE_TEXT -,"data tag group" -#endif -); -const MessageFragment ParserMessages::modelGroup( -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -1017 -#ifndef SP_NO_MESSAGE_TEXT -,"model group" -#endif -); -const MessageFragment ParserMessages::dataTagTemplateGroup( -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -1018 -#ifndef SP_NO_MESSAGE_TEXT -,"data tag template group" -#endif -); -const MessageFragment ParserMessages::name( -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -1019 -#ifndef SP_NO_MESSAGE_TEXT -,"name" -#endif -); -const MessageFragment ParserMessages::nameToken( -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -1020 -#ifndef SP_NO_MESSAGE_TEXT -,"name token" -#endif -); -const MessageFragment ParserMessages::elementToken( -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -1021 -#ifndef SP_NO_MESSAGE_TEXT -,"element token" -#endif -); -const MessageFragment ParserMessages::inclusions( -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -1022 -#ifndef SP_NO_MESSAGE_TEXT -,"inclusions" -#endif -); -const MessageFragment ParserMessages::exclusions( -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -1023 -#ifndef SP_NO_MESSAGE_TEXT -,"exclusions" -#endif -); -const MessageFragment ParserMessages::minimumLiteral( -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -1024 -#ifndef SP_NO_MESSAGE_TEXT -,"minimum literal" -#endif -); -const MessageFragment ParserMessages::attributeValueLiteral( -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -1025 -#ifndef SP_NO_MESSAGE_TEXT -,"attribute value literal" -#endif -); -const MessageFragment ParserMessages::systemIdentifier( -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -1026 -#ifndef SP_NO_MESSAGE_TEXT -,"system identifier" -#endif -); -const MessageFragment ParserMessages::number( -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -1027 -#ifndef SP_NO_MESSAGE_TEXT -,"number" -#endif -); -const MessageFragment ParserMessages::attributeValue( -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -1028 -#ifndef SP_NO_MESSAGE_TEXT -,"attribute value" -#endif -); -const MessageFragment ParserMessages::capacityName( -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -1029 -#ifndef SP_NO_MESSAGE_TEXT -,"name of capacity" -#endif -); -const MessageFragment ParserMessages::generalDelimiteRoleName( -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -1030 -#ifndef SP_NO_MESSAGE_TEXT -,"name of general delimiter role" -#endif -); -const MessageFragment ParserMessages::referenceReservedName( -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -1031 -#ifndef SP_NO_MESSAGE_TEXT -,"reference reserved name" -#endif -); -const MessageFragment ParserMessages::quantityName( -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -1032 -#ifndef SP_NO_MESSAGE_TEXT -,"name of quantity" -#endif -); -const MessageFragment ParserMessages::entityEnd( -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -1033 -#ifndef SP_NO_MESSAGE_TEXT -,"entity end" -#endif -); -const MessageFragment ParserMessages::shortrefDelim( -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -1034 -#ifndef SP_NO_MESSAGE_TEXT -,"short reference delimiter" -#endif -); -#ifdef SP_NAMESPACE -} -#endif diff --git a/cde/programs/nsgmls/ParserMessages.h b/cde/programs/nsgmls/ParserMessages.h deleted file mode 100644 index b06e282ad..000000000 --- a/cde/programs/nsgmls/ParserMessages.h +++ /dev/null @@ -1,786 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: ParserMessages.h /main/1 1996/07/29 17:01:05 cde-hp $ */ -// This file was automatically generated from ParserMessages.msg by msggen.pl. -#ifndef ParserMessages_INCLUDED -#define ParserMessages_INCLUDED 1 - -#ifdef __GNUG__ -#pragma interface -#endif -#include "Message.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -struct ParserMessages { - // 0 - static const MessageType1 nameLength; - // 1 - static const MessageType1 parameterEntityNameLength; - // 2 - static const MessageType1 numberLength; - // 3 - static const MessageType1 attributeValueLength; - // 4 - static const MessageType0 peroGrpoProlog; - // 5 - static const MessageType0 groupLevel; - // 6 - static const MessageType2 groupCharacter; - // 7 - static const MessageType0 psRequired; - // 8 - static const MessageType2 markupDeclarationCharacter; - // 9 - static const MessageType0 declarationLevel; - // 10 - static const MessageType0 groupEntityEnd; - // 11 - static const MessageType1 invalidToken; - // 12 - static const MessageType0 groupEntityReference; - // 13 - static const MessageType1 duplicateGroupToken; - // 14 - static const MessageType1 groupCount; - // 15 - static const MessageType0 literalLevel; - // 16 - static const MessageType1 literalMinimumData; - // 17 - static const MessageType0 dataTagPatternNonSgml; - // 18 - static const MessageType0 dataTagPatternFunction; - // 19 - static const MessageType0 eroGrpoStartTag; - // 20 - static const MessageType0 eroGrpoProlog; - // 21 - static const MessageType1 functionName; - // 22 - static const MessageType1 characterNumber; - // 23 - static const MessageType1 parameterEntityUndefined; - // 24 - static const MessageType1 entityUndefined; - // 25 - static const MessageType0 rniNameStart; - // 26 - static const MessageType0L commentEntityEnd; - // 28 - static const MessageType0 mixedConnectors; - // 29 - static const MessageType1 noSuchReservedName; - // 30 - static const MessageType1 invalidReservedName; - // 31 - static const MessageType1 minimumLiteralLength; - // 32 - static const MessageType1 tokenizedAttributeValueLength; - // 33 - static const MessageType1 systemIdentifierLength; - // 34 - static const MessageType1 parameterLiteralLength; - // 35 - static const MessageType1 dataTagPatternLiteralLength; - // 36 - static const MessageType0 literalClosingDelimiter; - // 37 - static const MessageType2 paramInvalidToken; - // 38 - static const MessageType2 groupTokenInvalidToken; - // 39 - static const MessageType2 connectorInvalidToken; - // 40 - static const MessageType1 noSuchDeclarationType; - // 41 - static const MessageType1 dtdSubsetDeclaration; - // 42 - static const MessageType1 declSubsetCharacter; - // 43 - static const MessageType0 documentEndDtdSubset; - // 44 - static const MessageType1 prologCharacter; - // 45 - static const MessageType0 documentEndProlog; - // 46 - static const MessageType1 prologDeclaration; - // 47 - static const MessageType1 rankStemGenericIdentifier; - // 48 - static const MessageType0 missingTagMinimization; - // 49 - static const MessageType1 duplicateElementDefinition; - // 50 - static const MessageType0 entityApplicableDtd; - // 51 - static const MessageType1L commentDeclInvalidToken; - // 53 - static const MessageType1 instanceDeclaration; - // 54 - static const MessageType0 contentNonSgml; - // 55 - static const MessageType1 noCurrentRank; - // 56 - static const MessageType1 duplicateAttlistNotation; - // 57 - static const MessageType1 duplicateAttlistElement; - // 58 - static const MessageType0 endTagEntityEnd; - // 59 - static const MessageType1 endTagCharacter; - // 60 - static const MessageType1 endTagInvalidToken; - // 61 - static const MessageType0 pcdataNotAllowed; - // 62 - static const MessageType1 elementNotAllowed; - // 63 - static const MessageType2 missingElementMultiple; - // 64 - static const MessageType2 missingElementInferred; - // 65 - static const MessageType1 startTagEmptyElement; - // 66 - static const MessageType1L omitEndTagDeclare; - // 68 - static const MessageType1L omitEndTagOmittag; - // 70 - static const MessageType1 omitStartTagDeclaredContent; - // 71 - static const MessageType1 elementEndTagNotFinished; - // 72 - static const MessageType1 omitStartTagDeclare; - // 73 - static const MessageType1 taglvlOpenElements; - // 74 - static const MessageType1 undefinedElement; - // 75 - static const MessageType0 emptyEndTagNoOpenElements; - // 76 - static const MessageType1 elementNotFinished; - // 77 - static const MessageType1 elementNotOpen; - // 78 - static const MessageType1 internalParameterDataEntity; - // 79 - static const MessageType1 attributeSpecCharacter; - // 80 - static const MessageType0 unquotedAttributeValue; - // 81 - static const MessageType0 attributeSpecEntityEnd; - // 82 - static const MessageType1 externalParameterDataSubdocEntity; - // 83 - static const MessageType1 duplicateEntityDeclaration; - // 84 - static const MessageType1 duplicateParameterEntityDeclaration; - // 85 - static const MessageType1 noDtdSubset; - // 86 - static const MessageType0 piEntityReference; - // 87 - static const MessageType0 internalDataEntityReference; - // 88 - static const MessageType0 externalNonTextEntityReference; - // 89 - static const MessageType0 externalNonTextEntityRcdata; - // 90 - static const MessageType0 entlvl; - // 91 - static const MessageType0 piEntityRcdata; - // 92 - static const MessageType1 recursiveEntityReference; - // 93 - static const MessageType1 undefinedShortrefMapInstance; - // 94 - static const MessageType0 usemapAssociatedElementTypeDtd; - // 95 - static const MessageType0 usemapAssociatedElementTypeInstance; - // 96 - static const MessageType2 undefinedShortrefMapDtd; - // 97 - static const MessageType1 unknownShortrefDelim; - // 98 - static const MessageType1 delimDuplicateMap; - // 99 - static const MessageType0 noDocumentElement; - // 100 - static const MessageType0 processingInstructionEntityEnd; - // 101 - static const MessageType1 processingInstructionLength; - // 102 - static const MessageType0 processingInstructionClose; - // 103 - static const MessageType0 attributeSpecNameTokenExpected; - // 104 - static const MessageType1 noSuchAttributeToken; - // 105 - static const MessageType0 attributeNameShorttag; - // 106 - static const MessageType1 noSuchAttribute; - // 107 - static const MessageType0 attributeValueExpected; - // 108 - static const MessageType1 nameTokenLength; - // 109 - static const MessageType0 attributeSpecLiteral; - // 110 - static const MessageType1 duplicateAttributeSpec; - // 111 - static const MessageType1 duplicateAttributeDef; - // 112 - static const MessageType0 emptyDataAttributeSpec; - // 113 - static const MessageType0 markedSectionEnd; - // 114 - static const MessageType1 markedSectionLevel; - // 115 - static const MessageType0L unclosedMarkedSection; - // 117 - static const MessageType0 specialParseEntityEnd; - // 118 - static const MessageType2 normalizedAttributeValueLength; - // 119 - static const MessageType0 attributeValueSyntax; - // 120 - static const MessageType2 attributeValueChar; - // 121 - static const MessageType1 attributeValueMultiple; - // 122 - static const MessageType2 attributeValueNumberToken; - // 123 - static const MessageType2 attributeValueName; - // 124 - static const MessageType1 attributeMissing; - // 125 - static const MessageType1 requiredAttributeMissing; - // 126 - static const MessageType1 currentAttributeMissing; - // 127 - static const MessageType1 invalidNotationAttribute; - // 128 - static const MessageType1 invalidEntityAttribute; - // 129 - static const MessageType3 attributeValueNotInGroup; - // 130 - static const MessageType1 notDataOrSubdocEntity; - // 131 - static const MessageType3 ambiguousModelInitial; - // 132 - static const MessageType5 ambiguousModel; - // 133 - static const MessageType5 ambiguousModelSingleAnd; - // 134 - static const MessageType6 ambiguousModelMultipleAnd; - // 135 - static const MessageType1L commentDeclarationCharacter; - // 137 - static const MessageType1 nonSgmlCharacter; - // 138 - static const MessageType0 dataMarkedSectionDeclSubset; - // 139 - static const MessageType1L duplicateId; - // 141 - static const MessageType1 notFixedValue; - // 142 - static const MessageType1 sdCommentSignificant; - // 143 - static const MessageType1 standardVersion; - // 144 - static const MessageType1 namingBeforeLcnmstrt; - // 145 - static const MessageType1 sdEntityEnd; - // 146 - static const MessageType2 sdInvalidNameToken; - // 147 - static const MessageType1 numberTooBig; - // 148 - static const MessageType1 sdLiteralSignificant; - // 149 - static const MessageType1 syntaxCharacterNumber; - // 150 - static const MessageType0 sdParameterEntity; - // 151 - static const MessageType2 sdParamInvalidToken; - // 152 - static const MessageType0 giveUp; - // 153 - static const MessageType1 sdMissingCharacters; - // 154 - static const MessageType1 missingMinimumChars; - // 155 - static const MessageType1 duplicateCharNumbers; - // 156 - static const MessageType1 codeSetHoles; - // 157 - static const MessageType1 basesetCharsMissing; - // 158 - static const MessageType1 documentCharMax; - // 159 - static const MessageType1 fpiMissingField; - // 160 - static const MessageType1 fpiMissingTextClassSpace; - // 161 - static const MessageType1 fpiInvalidTextClass; - // 162 - static const MessageType1 fpiInvalidLanguage; - // 163 - static const MessageType1 fpiIllegalDisplayVersion; - // 164 - static const MessageType1 fpiExtraField; - // 165 - static const MessageType0 notationIdentifierTextClass; - // 166 - static const MessageType1 unknownBaseset; - // 167 - static const MessageType2 lexicalAmbiguity; - // 168 - static const MessageType1 translateSyntaxChar; - // 169 - static const MessageType1 missingSignificant; - // 170 - static const MessageType1 missingSyntaxChar; - // 171 - static const MessageType1 unknownCapacitySet; - // 172 - static const MessageType1 duplicateCapacity; - // 173 - static const MessageType1 capacityExceedsTotalcap; - // 174 - static const MessageType1 unknownPublicSyntax; - // 175 - static const MessageType0 nmstrtLength; - // 176 - static const MessageType0 nmcharLength; - // 177 - static const MessageType1 subdocLevel; - // 178 - static const MessageType1 subdocEntity; - // 179 - static const MessageType0 parameterEntityNotEnded; - // 180 - static const MessageType1 missingId; - // 181 - static const MessageType1 dtdUndefinedElement; - // 182 - static const MessageType1 elementNotFinishedDocumentEnd; - // 183 - static const MessageType0 subdocGiveUp; - // 184 - static const MessageType0 noDtd; - // 185 - static const MessageType1 taglen; - // 186 - static const MessageType0 groupParameterEntityNotEnded; - // 187 - static const MessageType1 invalidSgmlChar; - // 188 - static const MessageType1 translateDocChar; - // 189 - static const MessageType1 attributeValueLengthNeg; - // 190 - static const MessageType1 tokenizedAttributeValueLengthNeg; - // 191 - static const MessageType1 scopeInstanceQuantity; - // 192 - static const MessageType1 basesetTextClass; - // 193 - static const MessageType1 capacityTextClass; - // 194 - static const MessageType1 syntaxTextClass; - // 195 - static const MessageType0 msocharRequiresMsichar; - // 196 - static const MessageType1 switchNotMarkup; - // 197 - static const MessageType1 switchNotInCharset; - // 198 - static const MessageType1 ambiguousDocCharacter; - // 199 - static const MessageType1 oneFunction; - // 200 - static const MessageType1 duplicateFunctionName; - // 201 - static const MessageType1 missingSignificant646; - // 202 - static const MessageType1 generalDelimAllFunction; - // 203 - static const MessageType1 nmcharLetter; - // 204 - static const MessageType1 nmcharDigit; - // 205 - static const MessageType1 nmcharRe; - // 206 - static const MessageType1 nmcharRs; - // 207 - static const MessageType1 nmcharSpace; - // 208 - static const MessageType1 nmcharSepchar; - // 209 - static const MessageType1 switchLetterDigit; - // 210 - static const MessageType0 zeroNumberOfCharacters; - // 211 - static const MessageType1 nameReferenceReservedName; - // 212 - static const MessageType1 ambiguousReservedName; - // 213 - static const MessageType1 duplicateReservedName; - // 214 - static const MessageType1 reservedNameSyntax; - // 215 - static const MessageType1 multipleBSequence; - // 216 - static const MessageType1 blankAdjacentBSequence; - // 217 - static const MessageType2 delimiterLength; - // 218 - static const MessageType2 reservedNameLength; - // 219 - static const MessageType1 nmcharNmstrt; - // 220 - static const MessageType0 scopeInstanceSyntaxCharset; - // 221 - static const MessageType0 emptyOmitEndTag; - // 222 - static const MessageType1 conrefOmitEndTag; - // 223 - static const MessageType1 conrefEmpty; - // 224 - static const MessageType1 notationEmpty; - // 225 - static const MessageType0 dataAttributeDeclaredValue; - // 226 - static const MessageType0 dataAttributeDefaultValue; - // 227 - static const MessageType2 attcnt; - // 228 - static const MessageType0 idDeclaredValue; - // 229 - static const MessageType1 multipleIdAttributes; - // 230 - static const MessageType1 multipleNotationAttributes; - // 231 - static const MessageType1 duplicateAttributeToken; - // 232 - static const MessageType1 notationNoAttributes; - // 233 - static const MessageType2 entityNotationUndefined; - // 234 - static const MessageType2 mapEntityUndefined; - // 235 - static const MessageType1 attlistNotationUndefined; - // 236 - static const MessageType1 bracketedLitlen; - // 237 - static const MessageType1 genericIdentifierLength; - // 238 - static const MessageType0 instanceStartOmittag; - // 239 - static const MessageType1 grplvl; - // 240 - static const MessageType1 grpgtcnt; - // 241 - static const MessageType0 minimizedStartTag; - // 242 - static const MessageType0 minimizedEndTag; - // 243 - static const MessageType0 multipleDtds; - // 244 - static const MessageType0 afterDocumentElementEntityEnd; - // 245 - static const MessageType1 declarationAfterDocumentElement; - // 246 - static const MessageType0 characterReferenceAfterDocumentElement; - // 247 - static const MessageType0 entityReferenceAfterDocumentElement; - // 248 - static const MessageType0 markedSectionAfterDocumentElement; - // 249 - static const MessageType3 requiredElementExcluded; - // 250 - static const MessageType3 invalidExclusion; - // 251 - static const MessageType0 attributeValueShorttag; - // 252 - static const MessageType0 conrefNotation; - // 253 - static const MessageType1 duplicateNotationDeclaration; - // 254 - static const MessageType1L duplicateShortrefDeclaration; - // 256 - static const MessageType1 duplicateDelimGeneral; - // 257 - static const MessageType1 idrefGrpcnt; - // 258 - static const MessageType1 entityNameGrpcnt; - // 259 - static const MessageType2 attsplen; - // 260 - static const MessageType1 duplicateDelimShortref; - // 261 - static const MessageType1 duplicateDelimShortrefSet; - // 262 - static const MessageType1 defaultEntityInAttribute; - // 263 - static const MessageType1 defaultEntityReference; - // 264 - static const MessageType2 mapDefaultEntity; - // 265 - static const MessageType1 noSuchDtd; - // 266 - static const MessageType1 noLpdSubset; - // 267 - static const MessageType0 assocElementDifferentAtts; - // 268 - static const MessageType1 duplicateLinkSet; - // 269 - static const MessageType0 emptyResultAttributeSpec; - // 270 - static const MessageType1 noSuchSourceElement; - // 271 - static const MessageType1 noSuchResultElement; - // 272 - static const MessageType0 documentEndLpdSubset; - // 273 - static const MessageType1 lpdSubsetDeclaration; - // 274 - static const MessageType0 idlinkDeclSimple; - // 275 - static const MessageType0 linkDeclSimple; - // 276 - static const MessageType1 simpleLinkAttlistElement; - // 277 - static const MessageType0 shortrefOnlyInBaseDtd; - // 278 - static const MessageType0 usemapOnlyInBaseDtd; - // 279 - static const MessageType0 linkAttributeDefaultValue; - // 280 - static const MessageType0 linkAttributeDeclaredValue; - // 281 - static const MessageType0 simpleLinkFixedAttribute; - // 282 - static const MessageType0 duplicateIdLinkSet; - // 283 - static const MessageType1 noInitialLinkSet; - // 284 - static const MessageType1 notationUndefinedSourceDtd; - // 285 - static const MessageType0 simpleLinkResultNotImplied; - // 286 - static const MessageType0 simpleLinkFeature; - // 287 - static const MessageType0 implicitLinkFeature; - // 288 - static const MessageType0 explicitLinkFeature; - // 289 - static const MessageType0 lpdBeforeBaseDtd; - // 290 - static const MessageType0 dtdAfterLpd; - // 291 - static const MessageType1 unstableLpdGeneralEntity; - // 292 - static const MessageType1 unstableLpdParameterEntity; - // 293 - static const MessageType1 multipleIdLinkRuleAttribute; - // 294 - static const MessageType1 multipleLinkRuleAttribute; - // 295 - static const MessageType2 uselinkBadLinkSet; - // 296 - static const MessageType1 uselinkSimpleLpd; - // 297 - static const MessageType1 uselinkBadLinkType; - // 298 - static const MessageType1 duplicateDtdLpd; - // 299 - static const MessageType1 duplicateLpd; - // 300 - static const MessageType1 duplicateDtd; - // 301 - static const MessageType1 undefinedLinkSet; - // 302 - static const MessageType1 duplicateImpliedResult; - // 303 - static const MessageType1 simpleLinkCount; - // 304 - static const MessageType0 duplicateExplicitChain; - // 305 - static const MessageType1 explicit1RequiresSourceTypeBase; - // 306 - static const MessageType0 oneImplicitLink; - // 307 - static const MessageType1 sorryLink; - // 308 - static const MessageType0 entityReferenceMissingName; - // 309 - static const MessageType1 explicitNoRequiresSourceTypeBase; - // 310 - static const MessageType0 linkActivateTooLate; - // 311 - static const MessageType0 pass2Ee; - // 312 - static const MessageType2 idlinkElementType; - // 313 - static const MessageType0 datatagNotImplemented; - // 314 - static const MessageType0 startTagMissingName; - // 315 - static const MessageType0 endTagMissingName; - // 316 - static const MessageType0 startTagGroupNet; - // 317 - static const MessageType0 documentElementUndefined; - // 318 - static const MessageType0 badDefaultSgmlDecl; - // 319 - static const MessageType1L nonExistentEntityRef; - // 321 - static const MessageType0 pcdataUnreachable; - // 322 - static const MessageType0 sdInvalidEllipsis; - // 323 - static const MessageType0 sdInvalidRange; - // 324 - static const MessageType0 sdEmptyDelimiter; - // 325 - static const MessageType0 tooManyCharsMinimumLiteral; - // 326 - static const MessageType1 defaultedEntityDefined; - // 327 - static const MessageType0 unclosedStartTag; - // 328 - static const MessageType0 unclosedEndTag; - // 329 - static const MessageType0 emptyStartTag; - // 330 - static const MessageType0 emptyEndTag; - // 331 - static const MessageType0 netStartTag; - // 332 - static const MessageType0 nullEndTag; - // 333 - static const MessageType1 unusedMap; - // 334 - static const MessageType1 unusedParamEntity; - // 335 - static const MessageType1 cannotGenerateSystemIdPublic; - // 336 - static const MessageType1 cannotGenerateSystemIdGeneral; - // 337 - static const MessageType1 cannotGenerateSystemIdParameter; - // 338 - static const MessageType1 cannotGenerateSystemIdDoctype; - // 339 - static const MessageType1 cannotGenerateSystemIdLinktype; - // 340 - static const MessageType1 cannotGenerateSystemIdNotation; - // 341 - static const MessageType1 excludeIncludeSame; - // 342 - static const MessageType1 implyingDtd; - // 343 - static const MessageType1 afdrVersion; - // 344 - static const MessageType0 missingAfdrDecl; - // 1000 - static const MessageFragment delimStart; - // 1001 - static const MessageFragment delimEnd; - // 1002 - static const MessageFragment digit; - // 1003 - static const MessageFragment nameStartCharacter; - // 1004 - static const MessageFragment sepchar; - // 1005 - static const MessageFragment separator; - // 1006 - static const MessageFragment nameCharacter; - // 1007 - static const MessageFragment dataCharacter; - // 1008 - static const MessageFragment minimumDataCharacter; - // 1009 - static const MessageFragment significantCharacter; - // 1010 - static const MessageFragment recordEnd; - // 1011 - static const MessageFragment recordStart; - // 1012 - static const MessageFragment space; - // 1013 - static const MessageFragment listSep; - // 1014 - static const MessageFragment rangeSep; - // 1015 - static const MessageFragment parameterLiteral; - // 1016 - static const MessageFragment dataTagGroup; - // 1017 - static const MessageFragment modelGroup; - // 1018 - static const MessageFragment dataTagTemplateGroup; - // 1019 - static const MessageFragment name; - // 1020 - static const MessageFragment nameToken; - // 1021 - static const MessageFragment elementToken; - // 1022 - static const MessageFragment inclusions; - // 1023 - static const MessageFragment exclusions; - // 1024 - static const MessageFragment minimumLiteral; - // 1025 - static const MessageFragment attributeValueLiteral; - // 1026 - static const MessageFragment systemIdentifier; - // 1027 - static const MessageFragment number; - // 1028 - static const MessageFragment attributeValue; - // 1029 - static const MessageFragment capacityName; - // 1030 - static const MessageFragment generalDelimiteRoleName; - // 1031 - static const MessageFragment referenceReservedName; - // 1032 - static const MessageFragment quantityName; - // 1033 - static const MessageFragment entityEnd; - // 1034 - static const MessageFragment shortrefDelim; -}; - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* not ParserMessages_INCLUDED */ diff --git a/cde/programs/nsgmls/ParserOptions.C b/cde/programs/nsgmls/ParserOptions.C deleted file mode 100644 index 44999bf2a..000000000 --- a/cde/programs/nsgmls/ParserOptions.C +++ /dev/null @@ -1,77 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: ParserOptions.C /main/1 1996/07/29 17:01:10 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#ifdef __GNUG__ -#pragma implementation -#endif -#include "splib.h" -#include "ParserOptions.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -ParserOptions::ParserOptions() -: datatag(0), - omittag(1), - rank(1), - shorttag(1), - linkSimple(1000), - linkImplicit(1), - linkExplicit(1), - concur(0), - subdoc(99999999), - formal(1), - shortref(1), - errorIdref(1), - errorSignificant(1), - errorAfdr(1), - errorLpdNotation(0), - warnSgmlDecl(0), - warnShould(0), - warnDuplicateEntity(0), - warnUndefinedElement(0), - warnDefaultEntityReference(0), - warnMixedContent(0), - warnUnclosedTag(0), - warnNet(0), - warnEmptyTag(0), - warnUnusedMap(0), - warnUnusedParam(0), - warnNotationSystemId(0) -{ - for (int i = 0; i < nQuantity; i++) - quantity[i] = 99999999; - quantity[BSEQLEN] = 960; - quantity[NORMSEP] = 2; - quantity[LITLEN] = 24000; - quantity[PILEN] = 24000; - quantity[DTEMPLEN] = 24000; -} - -#ifdef SP_NAMESPACE -} -#endif diff --git a/cde/programs/nsgmls/ParserOptions.h b/cde/programs/nsgmls/ParserOptions.h deleted file mode 100644 index 8ff2f9b64..000000000 --- a/cde/programs/nsgmls/ParserOptions.h +++ /dev/null @@ -1,98 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: ParserOptions.h /main/1 1996/07/29 17:01:15 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#ifndef ParserOptions_INCLUDED -#define ParserOptions_INCLUDED 1 -#ifdef __GNUG__ -#pragma interface -#endif - -#include "types.h" -#include "EventsWanted.h" -#include "Vector.h" -#include "StringC.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -struct SP_API ParserOptions { - ParserOptions(); - EventsWanted eventsWanted; - PackedBoolean datatag; - PackedBoolean omittag; - PackedBoolean rank; - PackedBoolean shorttag; - Number linkSimple; - PackedBoolean linkImplicit; - Number linkExplicit; - Number concur; - Number subdoc; - PackedBoolean formal; - PackedBoolean shortref; - enum Quantity { - ATTCNT, - ATTSPLEN, - BSEQLEN, - DTAGLEN, - DTEMPLEN, - ENTLVL, - GRPCNT, - GRPGTCNT, - GRPLVL, - LITLEN, - NAMELEN, - NORMSEP, - PILEN, - TAGLEN, - TAGLVL - }; - enum { nQuantity = TAGLVL + 1 }; - Number quantity[nQuantity]; - PackedBoolean errorIdref; - PackedBoolean errorSignificant; - PackedBoolean errorAfdr; // error if AFDR extensions are used - PackedBoolean errorLpdNotation; - PackedBoolean warnSgmlDecl; - PackedBoolean warnDuplicateEntity; - PackedBoolean warnShould; - PackedBoolean warnUndefinedElement; - PackedBoolean warnDefaultEntityReference; - PackedBoolean warnMixedContent; - PackedBoolean warnUnclosedTag; - PackedBoolean warnNet; - PackedBoolean warnEmptyTag; - PackedBoolean warnUnusedMap; - PackedBoolean warnUnusedParam; - PackedBoolean warnNotationSystemId; - Vector includes; -}; - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* not ParserOptions_INCLUDED */ diff --git a/cde/programs/nsgmls/ParserState.C b/cde/programs/nsgmls/ParserState.C deleted file mode 100644 index ba8dee070..000000000 --- a/cde/programs/nsgmls/ParserState.C +++ /dev/null @@ -1,819 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: ParserState.C /main/1 1996/07/29 17:01:20 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#ifdef __GNUG__ -#pragma implementation -#endif -#include "splib.h" -#include "ParserState.h" -#include "InternalInputSource.h" -#include "MessageArg.h" -#include "macros.h" -#include "SgmlParser.h" -#include "IListIter.h" -#include "ParserMessages.h" -#include "Undo.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -const Location ParserState::nullLocation_; -sig_atomic_t ParserState::dummyCancel_ = 0; - -static const size_t eventSizes[] = { -#define EVENT(c, f) sizeof(c), -#include "events.h" -#undef EVENT -}; - -static const size_t internalSizes[] = { - sizeof(InternalInputSource), - sizeof(EntityOrigin), - sizeof(OpenElement), - sizeof(UndoStartTag), - sizeof(UndoEndTag), - sizeof(UndoTransition) -}; - -static -size_t maxSize(const size_t *v, size_t n) -{ - size_t max = 0; - for (size_t i = 0; i < n; i++) { - if (v[i] > max) - max = v[i]; - } - return max; -} - -ParserState::ParserState(const Ptr &em, - const ParserOptions &opt, - unsigned subdocLevel, - Phase finalPhase) -: entityManager_(em), - options_(opt), - inInstance_(0), - keepingMessages_(0), - eventAllocator_(maxSize(eventSizes, SIZEOF(eventSizes)), 50), - internalAllocator_(maxSize(internalSizes, SIZEOF(internalSizes)), 50), - handler_(&eventQueue_), - subdocLevel_(subdocLevel), - inputLevel_(0), - specialParseInputLevel_(0), - markedSectionLevel_(0), - markedSectionSpecialLevel_(0), - currentMode_(proMode), - hadLpd_(0), - resultAttributeSpecMode_(0), - pass2_(0), - activeLinkTypesSubsted_(0), - allowPass2_(0), - hadPass2Start_(0), - pcdataRecovering_(0), - currentMarkup_(0), - cancelPtr_(&dummyCancel_), - finalPhase_(finalPhase), - hadAfdrDecl_(0), - pass2StartOffset_(0), - phase_(noPhase), - specialParseMode_() -{ -} - -void ParserState::inheritActiveLinkTypes(const ParserState &parent) -{ - activeLinkTypes_ = parent.activeLinkTypes_; - activeLinkTypesSubsted_ = parent.activeLinkTypesSubsted_; -} - -void ParserState::allDone() -{ - phase_ = noPhase; -} - -void ParserState::setPass2Start() -{ - ASSERT(inputLevel_ == 1); - if (hadPass2Start_) - return; - hadPass2Start_ = 1; - if (!pass2() && sd().link() && activeLinkTypes_.size() > 0) { - allowPass2_ = 1; - pass1Handler_.init(handler_); - handler_ = &pass1Handler_; - const InputSourceOrigin *p - = currentLocation().origin()->asInputSourceOrigin(); - pass2StartOffset_= p->startOffset(currentLocation().index()); - } - else { - allowPass2_ = 0; - currentInput()->willNotRewind(); - } -} - -void ParserState::allLinkTypesActivated() -{ - if (activeLinkTypes_.size() == 0 && inputLevel_ == 1) - currentInput()->willNotRewind(); -} - -Boolean ParserState::maybeStartPass2() -{ - if (pass2_ || !allowPass2_) - return 0; - handler_ = pass1Handler_.origHandler(); - if (!nActiveLink() || pass1Handler_.hadError()) { - while (!pass1Handler_.empty()) { - if (cancelled()) - return 0; - pass1Handler_.get()->handle(*handler_); - } - InputSource *top = 0; - for (IListIter iter(inputStack_); - !iter.done(); - iter.next()) - top = iter.cur(); - if (top) - top->willNotRewind(); - return 0; - } - pass1Handler_.clear(); - while (inputLevel_ > 1) { - InputSource *p = inputStack_.get(); - inputLevel_--; - delete p; - } - // Caller will call allDone() if inputLevel_ is 0. - if (inputLevel_ == 0) - return 0; - if (!inputStack_.head()->rewind(*this)) { - inputLevel_ = 0; - delete inputStack_.get(); - return 0; - } - inputStack_.head()->willNotRewind(); - for (; pass2StartOffset_ > 0; pass2StartOffset_--) - if (inputStack_.head()->get(messenger()) == InputSource::eE) { - message(ParserMessages::pass2Ee); - inputLevel_ = 0; - delete inputStack_.get(); - return 0; - } - specialParseInputLevel_ = 0; - markedSectionLevel_ = 0; - markedSectionSpecialLevel_ = 0; - currentMode_ = proMode; - hadLpd_ = 0; - allowPass2_ = 0; - hadPass2Start_ = 0; - currentMarkup_ = 0; - inputLevel_ = 1; - inInstance_ = 0; - defDtd_.clear(); - defLpd_.clear(); - dtd_[0].swap(pass1Dtd_); - dtd_.clear(); - dsEntity_.clear(); - currentDtd_.clear(); - phase_ = noPhase; - pass2_ = 1; - lpd_.clear(); - allLpd_.clear(); - return 1; -} - -Boolean ParserState::referenceDsEntity(const Location &loc) -{ - if (dsEntity_.isNull()) - return 0; - Ptr origin - = new (internalAllocator()) EntityOrigin(dsEntity_, loc); - dsEntity_->dsReference(*this, origin); - dsEntity_.clear(); - return inputLevel() > 1; -} - -void ParserState::startDtd(const StringC &name) -{ - defDtd_ = new Dtd(name, dtd_.size() == 0); - defLpd_.clear(); - for (size_t i = 0; i < options().includes.size(); i++) { - StringC name = options().includes[i]; - const SubstTable *subst = syntax().entitySubstTable(); - for (size_t j = 0; j < name.size(); j++) - subst->subst(name[j]); - Text text; - text.addChars(syntax().reservedName(Syntax::rINCLUDE), Location()); - Entity *entity - = new InternalTextEntity(name, - Entity::parameterEntity, - Location(), - text, - InternalTextEntity::none); - entity->setUsed(); - defDtd_->insertEntity(entity); - } - currentDtd_ = defDtd_; - currentMode_ = dsMode; -} - -void ParserState::endDtd() -{ - dtd_.push_back(defDtd_); - defDtd_.clear(); - currentDtd_.clear(); - currentMode_ = proMode; -} - -void ParserState::startLpd(Ptr &lpd) -{ - defLpd_ = lpd; - defDtd_ = defLpd_->sourceDtd(); - currentDtd_ = defLpd_->sourceDtd(); - currentMode_ = dsMode; -} - -void ParserState::endLpd() -{ - hadLpd_ = 1; - if (defLpd_->active()) - lpd_.push_back(defLpd_); - allLpd_.push_back(defLpd_); - defLpd_.clear(); - currentDtd_.clear(); - currentMode_ = proMode; -} - -void ParserState::popInputStack() -{ - ASSERT(inputLevel_ > 0); - InputSource *p = inputStack_.get(); - inputLevel_--; - delete p; - if (specialParseInputLevel_ > 0 && inputLevel_ == specialParseInputLevel_) - currentMode_ = specialParseMode_; - if (currentMode_ == dsiMode - && inputLevel_ == 1 - && markedSectionLevel_ == 0) - currentMode_ = dsMode; -} - -void ParserState::setSd(ConstPtr sd) -{ - sd_ = sd; - mayDefaultAttribute_ = (sd_->omittag() || sd_->shorttag()); -} - -void ParserState::setSyntax(ConstPtr syntax) -{ - syntax_ = syntax; - prologSyntax_ = syntax; - instanceSyntax_ = syntax; -} - -void ParserState::setSyntaxes(ConstPtr prologSyntax, - ConstPtr instanceSyntax) -{ - syntax_ = prologSyntax; - prologSyntax_ = prologSyntax; - instanceSyntax_ = instanceSyntax; -} - -void ParserState::pushInput(InputSource *in) -{ - if (!in) - return; - if (!syntax_.isNull() && syntax_->multicode()) - in->setMarkupScanTable(syntax_->markupScanTable()); - inputStack_.insert(in); - inputLevel_++; - if (specialParseInputLevel_ > 0 && inputLevel_ > specialParseInputLevel_) - currentMode_ = rcconeMode; // mode for rcdata in an entity - else if (currentMode_ == dsMode) - currentMode_ = dsiMode; -} - -void ParserState::startMarkedSection(const Location &loc) -{ - markedSectionLevel_++; - markedSectionStartLocation_.push_back(loc); - if (currentMode_ == dsMode) - currentMode_ = dsiMode; - if (markedSectionSpecialLevel_) - markedSectionSpecialLevel_++; -} - -void ParserState::startSpecialMarkedSection(Mode mode, const Location &loc) -{ - markedSectionLevel_++; - markedSectionStartLocation_.push_back(loc); - specialParseInputLevel_ = inputLevel_; - markedSectionSpecialLevel_ = 1; - specialParseMode_ = currentMode_ = mode; -} - -void ParserState::endMarkedSection() -{ - ASSERT(markedSectionLevel_ > 0); - markedSectionLevel_--; - markedSectionStartLocation_.resize(markedSectionStartLocation_.size() - - 1); - if (markedSectionSpecialLevel_ > 0) { - markedSectionSpecialLevel_--; - if (markedSectionSpecialLevel_ > 0) - return; // remain in imsMode - specialParseInputLevel_ = 0; - if (inInstance_) - currentMode_ = contentMode(); - else - currentMode_ = dsiMode; - } - if (currentMode_ == dsiMode - && inputLevel_ == 1 - && markedSectionLevel_ == 0) - currentMode_ = dsMode; -} - -void ParserState::pushElement(OpenElement *e) -{ - ContentState::pushElement(e); - pcdataRecovering_ = 0; - // the start tag of this element may have been implied by data - // inside a cdata or rcdata marked section - if (markedSectionSpecialLevel_ == 0) { - currentMode_ = contentMode(); - if (e->requiresSpecialParse()) { - specialParseMode_ = currentMode_; - specialParseInputLevel_ = inputLevel_; - } - } -} - -// PCDATA was encountered somewhere where it was not allowed. -// Change the current mode to improve recovery. - -void ParserState::pcdataRecover() -{ - switch (currentMode_) { - case econMode: - currentMode_ = mconMode; - break; - case econnetMode: - currentMode_ = mconnetMode; - break; - default: - break; - } - pcdataRecovering_ = 1; -} - -OpenElement *ParserState::popSaveElement() -{ - OpenElement *e = ContentState::popSaveElement(); - // the end tag of this element may have been implied by data - // inside a cdata or rcdata marked section - if (markedSectionSpecialLevel_ == 0) { - currentMode_ = contentMode(); - specialParseInputLevel_ = 0; - } - pcdataRecovering_ = 0; - return e; -} - -void ParserState::popElement() -{ - delete popSaveElement(); -} - -Boolean ParserState::entityIsOpen(const Entity *entity) const -{ - for (IListIter iter(inputStack_); !iter.done(); iter.next()) { - const EntityOrigin *eo - = iter.cur()->currentLocation().origin()->asEntityOrigin(); - if (eo && eo->entity().pointer() == entity) - return 1; - } - return 0; -} - -void ParserState::startInstance() -{ - if (!instanceSyntax_.isNull()) - syntax_ = instanceSyntax_; - currentMode_ = econMode; - currentDtd_ = dtd_[0]; - startContent(currentDtd()); - inInstance_ = 1; - if (sd().rank()) - currentRank_.assign(currentDtd().nRankStem(), StringC()); - currentAttributes_.clear(); - currentAttributes_.resize(currentDtd().nCurrentAttribute()); - idTable_.clear(); -} - -Id *ParserState::lookupCreateId(const StringC &name) -{ - Id *id = idTable_.lookup(name); - if (!id) { - id = new Id(name); - idTable_.insert(id); - } - return id; -} - -ConstPtr -ParserState::lookupEntity(Boolean isParameter, - const StringC &name, - const Location &useLocation, - Boolean referenced) -{ - Dtd *dtd; - if (resultAttributeSpecMode_) - dtd = defComplexLpd().resultDtd().pointer(); - else - dtd = (Dtd *)currentDtd_.pointer(); - if (dtd) { - Ptr entity(dtd->lookupEntity(isParameter, name)); - // Did we find it in pass1Dtd? - // Did we look at the defaultEntity? - if (!inInstance_ && pass2() && dtd->isBase() - && !resultAttributeSpecMode_ - && (entity.isNull() || !entity->declInActiveLpd())) { - ConstPtr entity1 - = pass1Dtd_->lookupEntity(isParameter, name); - if (!entity1.isNull() && entity1->declInActiveLpd() - && !entity1->defaulted()) { - if (referenced) - noteReferencedEntity(entity1, 1, 0); - return entity1; - } - else if (!entity.isNull()) { - if (referenced) - noteReferencedEntity(entity, 0, 0); - entity->setUsed(); - return entity; - } - } - else if (!entity.isNull()) { - entity->setUsed(); - return entity; - } - if (!isParameter) { - ConstPtr entity(dtd->defaultEntity()); - Boolean note = 0; - Boolean usedPass1 = 0; - if (!inInstance_ && pass2() && dtd->isBase() - && !resultAttributeSpecMode_ - && (entity.isNull() || !entity->declInActiveLpd())) { - if (referenced) - note = 1; - ConstPtr entity1 = pass1Dtd_->defaultEntity(); - if (!entity1.isNull() && entity1->declInActiveLpd()) { - usedPass1 = 1; - entity = entity1; - } - } - if (!entity.isNull()) { - Boolean mustCopy = 1; - if (inInstance_) { - ConstPtr tem - = instanceDefaultedEntityTable_.lookupConst(name); - if (!tem.isNull()) { - entity = tem; - mustCopy = 0; - } - } - if (mustCopy) { - Ptr p(entity->copy()); - p->setName(name); - p->generateSystemId(*this); - p->setDefaulted(); - entity = p; - if (inInstance_) { - instanceDefaultedEntityTable_.insert(p); - eventHandler().entityDefaulted(new (eventAllocator()) - EntityDefaultedEvent(entity, - useLocation)); - } - else - dtd->insertEntity(p); - } - if (note) - noteReferencedEntity(entity, usedPass1, 1); - } - return entity; - } - } - return (Entity *)0; -} - -void ParserState::noteReferencedEntity(const ConstPtr &entity, - Boolean foundInPass1Dtd, - Boolean lookedAtDefault) -{ - LpdEntityRef ref; - ref.entity = entity; - ref.lookedAtDefault = lookedAtDefault; - ref.foundInPass1Dtd = foundInPass1Dtd; - LpdEntityRef *old = lpdEntityRefs_.lookup(ref); - if (!old) - lpdEntityRefs_.insert(new LpdEntityRef(ref)); -} - -// Compare entity definitions. -// e1 is the original (will not be an external non-text entity). -// FIXME should look at generated sysids as well. -static -Boolean sameEntityDef(const Entity *e1, const Entity *e2) -{ - if (e1->dataType() != e2->dataType()) - return 0; - const InternalEntity *i1 = e1->asInternalEntity(); - const InternalEntity *i2 = e2->asInternalEntity(); - if (i1) { - if (!i2) - return 0; - if (i1->string() != i2->string()) - return 0; - return 1; - } - else if (i2) - return 0; - const ExternalEntity *x1 = e1->asExternalEntity(); - const ExternalEntity *x2 = e2->asExternalEntity(); - const StringC *s1 = x1->externalId().systemIdString(); - const StringC *s2 = x2->externalId().systemIdString(); - if (s1) { - if (!s2) - return 0; - if (*s1 != *s2) - return 0; - } - else if (s2) - return 0; - s1 = x1->externalId().publicIdString(); - s2 = x2->externalId().publicIdString(); - if (s1) { - if (!s2) - return 0; - if (*s1 != *s2) - return 0; - } - else if (s2) - return 0; - return 1; -} - -void ParserState::checkEntityStability() -{ - LpdEntityRefSetIter iter(lpdEntityRefs_); - LpdEntityRef *ref; - while ((ref = iter.next()) != 0) { - ConstPtr entity - = dtd_[0]->lookupEntity(ref->entity->declType() - == Entity::parameterEntity, - ref->entity->name()); - if (entity.isNull() && ref->lookedAtDefault) - entity = dtd_[0]->defaultEntity(); - if (entity.isNull() - ? ref->foundInPass1Dtd - : !sameEntityDef(ref->entity.pointer(), entity.pointer())) - message(((ref->entity->declType() - == Entity::parameterEntity) - ? ParserMessages::unstableLpdParameterEntity - : ParserMessages::unstableLpdGeneralEntity), - StringMessageArg(ref->entity->name())); - } - { - // Ensure that the memory is released. - LpdEntityRefSet tem; - lpdEntityRefs_.swap(tem); - } -} - -Boolean ParserState::appendCurrentRank(StringC &str, const RankStem *stem) - const -{ - const StringC &suffix = currentRank_[stem->index()]; - if (suffix.size() > 0) { - str += suffix; - return 1; - } - return 0; -} - -void ParserState::setCurrentRank(const RankStem *stem, const StringC &suffix) -{ - currentRank_[stem->index()] = suffix; -} - -void ParserState::getCurrentToken(const SubstTable *subst, - StringC &str) const -{ - InputSource *in = currentInput(); - const Char *p = in->currentTokenStart(); - size_t count = in->currentTokenLength(); - str.resize(count); - StringC::iterator s = str.begin(); - for (; count > 0; --count) - *s++ = (*subst)[*p++]; -} - -void ParserState::queueMessage(MessageEvent *event) -{ - if (cancelled()) { - delete event; - return; - } - if (keepingMessages_) - keptMessages_.append(event); - else - handler_->message(event); -} - -void ParserState::releaseKeptMessages() -{ - keepingMessages_ = 0; - while (!keptMessages_.empty()) { - if (cancelled()) { - allDone(); - return; - } - handler_->message(keptMessages_.get()); - } -} - -void ParserState::discardKeptMessages() -{ - keepingMessages_ = 0; - keptMessages_.clear(); -} - -void ParserState::initMessage(Message &msg) -{ - if (inInstance()) { - StringC rniPcdata = syntax().delimGeneral(Syntax::dRNI); - rniPcdata += syntax().reservedName(Syntax::rPCDATA); - getOpenElementInfo(msg.openElementInfo, rniPcdata); - } - msg.loc = currentLocation(); -} - -void ParserState::dispatchMessage(Message &msg) -{ - queueMessage(new MessageEvent(msg)); -} - -void ParserState::dispatchMessage(const Message &msg) -{ - queueMessage(new MessageEvent(msg)); -} - -AttributeList * -ParserState::allocAttributeList(const ConstPtr &def, - unsigned i) -{ - if (i < attributeLists_.size()) - attributeLists_[i]->init(def); - else { - attributeLists_.resize(i + 1); - attributeLists_[i] = new AttributeList(def); - } - return attributeLists_[i].pointer(); -} - -void ParserState::activateLinkType(const StringC &name) -{ - if (!hadPass2Start_ && !pass2_) - activeLinkTypes_.push_back(name); - else - message(ParserMessages::linkActivateTooLate); -} - -Boolean ParserState::shouldActivateLink(const StringC &name) const -{ - if (!activeLinkTypesSubsted_) { - // FIXME use mutable - ParserState *state = (ParserState *)this; - for (size_t i = 0; i < activeLinkTypes_.size(); i++) - for (size_t j = 0; j < activeLinkTypes_[i].size(); j++) - syntax().generalSubstTable()->subst(state->activeLinkTypes_[i][j]); - state->activeLinkTypesSubsted_ = 1; - } - for (size_t i = 0; i < activeLinkTypes_.size(); i++) - if (name == activeLinkTypes_[i]) - return 1; - return 0; -} - -Ptr ParserState::lookupDtd(const StringC &name) -{ - for (size_t i = 0; i < dtd_.size(); i++) - if (dtd_[i]->name() == name) - return dtd_[i]; - return Ptr(); -} - -ConstPtr ParserState::lookupLpd(const StringC &name) const -{ - for (size_t i = 0; i < allLpd_.size(); i++) - if (allLpd_[i]->name() == name) - return allLpd_[i]; - return ConstPtr(); -} - -ConstPtr ParserState::getAttributeNotation(const StringC &name, - const Location &) -{ - ConstPtr notation; - if (haveCurrentDtd()) - notation = currentDtd().lookupNotation(name); - else if (resultAttributeSpecMode_) { - const Dtd *resultDtd = defComplexLpd().resultDtd().pointer(); - if (!resultDtd) - return 0; - notation = resultDtd->lookupNotation(name); - } - return notation; -} - -ConstPtr ParserState::getAttributeEntity(const StringC &str, - const Location &loc) -{ - ConstPtr entity = lookupEntity(0, str, loc, 0); - if (!entity.isNull() - && entity->defaulted() - && options().warnDefaultEntityReference) { - setNextLocation(loc); - message(ParserMessages::defaultEntityInAttribute, - StringMessageArg(str)); - } - return entity; -} - -Boolean ParserState::defineId(const StringC &str, const Location &loc, - Location &prevLoc) -{ - if (!inInstance()) - return 1; - Id *id = lookupCreateId(str); - if (id->defined()) { - prevLoc = id->defLocation(); - return 0; - } - id->define(loc); - return 1; -} - -void ParserState::noteIdref(const StringC &str, const Location &loc) -{ - if (!inInstance() || !options().errorIdref) - return; - Id *id = lookupCreateId(str); - if (!id->defined()) - id->addPendingRef(loc); -} - -void ParserState::noteCurrentAttribute(size_t i, AttributeValue *value) -{ - if (inInstance()) - currentAttributes_[i] = value; -} - -ConstPtr ParserState::getCurrentAttribute(size_t i) const -{ - return currentAttributes_[i]; -} - -const Syntax &ParserState::attributeSyntax() const -{ - return syntax(); -} - -#ifdef SP_NAMESPACE -} -#endif diff --git a/cde/programs/nsgmls/ParserState.h b/cde/programs/nsgmls/ParserState.h deleted file mode 100644 index 67aa7f14c..000000000 --- a/cde/programs/nsgmls/ParserState.h +++ /dev/null @@ -1,821 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: ParserState.h /main/1 1996/07/29 17:01:25 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#ifndef ParserState_INCLUDED -#define ParserState_INCLUDED 1 -#ifdef __GNUG__ -#pragma interface -#endif - -#include -#include -#include "Allocator.h" -#include "Attribute.h" -#include "Boolean.h" -#include "Vector.h" -#include "StringC.h" -#include "Dtd.h" -#include "Entity.h" -#include "EntityCatalog.h" -#include "EntityManager.h" -#include "Event.h" -#include "EventQueue.h" -#include "Id.h" -#include "InputSource.h" -#include "IList.h" -#include "IQueue.h" -#include "Location.h" -#include "Message.h" -#include "Mode.h" -#include "OpenElement.h" -#include "OutputState.h" -#include "ParserOptions.h" -#include "Ptr.h" -#include "Recognizer.h" -#include "Sd.h" -#include "Syntax.h" -#include "NCVector.h" -#include "Owner.h" -#include "Lpd.h" -#include "LpdEntityRef.h" -#include "Markup.h" -#include "ContentState.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -class ParserState : public ContentState, public AttributeContext { -public: - enum Phase { - noPhase, - initPhase, - prologPhase, - declSubsetPhase, - instanceStartPhase, - contentPhase - }; - ParserState(const Ptr &, - const ParserOptions &, - unsigned subdocLevel, - Phase finalPhase); - void setHandler(EventHandler *, SP_CONST SP_VOLATILE sig_atomic_t *cancelPtr); - void unsetHandler(); - Boolean inInstance() const; - Boolean hadDtd() const; - void allDone(); - void startDtd(const StringC &); - void endDtd(); - void startInstance(); - unsigned subdocLevel() const; - Boolean haveDefLpd() const; - Dtd &defDtd(); - const Ptr &defDtdPointer() const; - Boolean haveCurrentDtd() const; - const Dtd ¤tDtd() const; - const ConstPtr ¤tDtdPointer() const; - void startLpd(Ptr &lpd); - void endLpd(); - Lpd &defLpd(); - Ptr &defLpdPointer(); - Ptr defComplexLpdPointer(); - size_t nActiveLink() const; - const Lpd &activeLpd(size_t i) const; - ComplexLpd &defComplexLpd(); - Ptr lookupDtd(const StringC &name); - Ptr baseDtd(); - void activateLinkType(const StringC &); - void allLinkTypesActivated(); - void setResultAttributeSpecMode(); - void clearResultAttributeSpecMode(); - Boolean haveApplicableDtd() const; - Boolean hadLpd() const; - Boolean pass2() const; - void setPass2Start(); - Boolean maybeStartPass2(); - void checkEntityStability(); - void noteReferencedEntity(const ConstPtr &entity, - Boolean, Boolean); - ConstPtr lookupLpd(const StringC &name) const; - Boolean shouldActivateLink(const StringC &) const; - Char currentChar() const; - const Location ¤tLocation() const; - InputSource *currentInput() const; - EntityManager &entityManager() const; - Ptr entityManagerPtr() const; - const EntityCatalog &entityCatalog() const; - ConstPtr entityCatalogPtr() const; - void setEntityCatalog(const ConstPtr &); - void setSyntax(ConstPtr); - void setSyntaxes(ConstPtr, ConstPtr); - void setSd(ConstPtr); - const Syntax &syntax() const; - const Syntax &instanceSyntax() const; - const ConstPtr &syntaxPointer() const; - const ConstPtr &prologSyntaxPointer() const; - const ConstPtr &instanceSyntaxPointer() const; - const Sd &sd() const; - const ConstPtr &sdPointer() const; - void setPhase(Phase phase); - Phase phase() const; - Phase finalPhase() const; - Mode currentMode() const; - void setRecognizer(Mode, ConstPtr); - void setNormalMap(const XcharMap &); - const XcharMap &normalMap() const; - Xchar getChar(); - void skipChar(); - Token getToken(Mode mode); - StringC currentToken() const; - void getCurrentToken(StringC &) const; - void getCurrentToken(const SubstTable *, StringC &) const; - unsigned inputLevel() const; - unsigned specialParseInputLevel() const; - unsigned markedSectionLevel() const; - unsigned markedSectionSpecialLevel() const; - const Location ¤tMarkedSectionStartLocation() const; - Boolean entityIsOpen(const Entity *) const; - void popInputStack(); - void pushInput(InputSource *); - Boolean referenceDsEntity(const Location &); - void setDsEntity(const ConstPtr &); - Boolean eventQueueEmpty() const; - Event *eventQueueGet(); - EventHandler &eventHandler(); - void pushElement(OpenElement *); - OpenElement *popSaveElement(); - void popElement(); - void pcdataRecover(); - Boolean pcdataRecovering() const; - ConstPtr lookupEntity(Boolean isParameter, - const StringC &name, - const Location &, - Boolean referenced); - Boolean appendCurrentRank(StringC &, const RankStem *) const; - void setCurrentRank(const RankStem *, const StringC &); - void startMarkedSection(const Location &); - void startSpecialMarkedSection(Mode, const Location &); - void endMarkedSection(); - void queueRe(const Location &); - void noteMarkup(); - void noteData(); - void noteRs(); - void noteStartElement(Boolean included); - void noteEndElement(Boolean included); - // size of objects allocated with this must not exceed - // sizeof(StartElementEvent) - Allocator &eventAllocator(); - // size of objects allocated with this must not exceed - // sizeof(OpenElement) - Allocator &internalAllocator(); - AttributeList *allocAttributeList(const ConstPtr &, - unsigned i); - - static void freeEvent(void *); - Boolean wantMarkup() const; - const EventsWanted &eventsWanted() const; - StringC &nameBuffer(); - typedef NamedTableIter IdTableIter; - IdTableIter idTableIter(); - const ParserOptions &options() const; - void keepMessages(); - void releaseKeptMessages(); - void discardKeptMessages(); - Messenger &messenger(); - - Markup *currentMarkup(); - const Location &markupLocation() const; - Markup *startMarkup(Boolean, const Location &); - void inheritActiveLinkTypes(const ParserState &parent); - Boolean cancelled() const; - - // AFDR extensions - void setHadAfdrDecl(); - Boolean hadAfdrDecl() const; - - // Implementation of AttributeContext. - Boolean defineId(const StringC &, const Location &, Location &); - void noteIdref(const StringC &, const Location &); - void noteCurrentAttribute(size_t, AttributeValue *); - ConstPtr getCurrentAttribute(size_t) const; - ConstPtr getAttributeEntity(const StringC &, - const Location &); - ConstPtr getAttributeNotation(const StringC &, - const Location &); - const Syntax &attributeSyntax() const; - -private: - ParserState(const ParserState &); // undefined - void operator=(const ParserState &); // undefined - void dispatchMessage(Message &); - void dispatchMessage(const Message &); - void initMessage(Message &); - void queueMessage(MessageEvent *); - Id *lookupCreateId(const StringC &); - - ParserOptions options_; - EventHandler *handler_; - Pass1EventHandler pass1Handler_; - Boolean allowPass2_; - Offset pass2StartOffset_; - Boolean hadPass2Start_; - EventQueue eventQueue_; - OutputState outputState_; - ConstPtr prologSyntax_; - ConstPtr instanceSyntax_; - ConstPtr sd_; - unsigned subdocLevel_; - Ptr entityManager_; - ConstPtr entityCatalog_; - Phase phase_; - Phase finalPhase_; - Boolean inInstance_; - Ptr defDtd_; - Ptr defLpd_; - Vector > allLpd_; - Vector > lpd_; // active LPDs - Vector activeLinkTypes_; - Boolean activeLinkTypesSubsted_; - Boolean hadLpd_; - Boolean resultAttributeSpecMode_; - Boolean pass2_; - typedef OwnerTable - LpdEntityRefSet; - typedef OwnerTableIter - LpdEntityRefSetIter; - LpdEntityRefSet lpdEntityRefs_; - // external entity to be referenced at the end of the declaration subset - ConstPtr dsEntity_; - Allocator eventAllocator_; - Allocator internalAllocator_; - NCVector > attributeLists_; - StringC nameBuffer_; - Boolean keepingMessages_; - IQueue keptMessages_; - Mode currentMode_; - Boolean pcdataRecovering_; - // if in a special parse (cdata, rcdata, ignore), the input level - // at which the special parse started. - unsigned specialParseInputLevel_; - Mode specialParseMode_; - unsigned markedSectionLevel_; - unsigned markedSectionSpecialLevel_; - Vector markedSectionStartLocation_; - ConstPtr recognizers_[nModes]; - XcharMap normalMap_; - unsigned inputLevel_; - IList inputStack_; - ConstPtr currentDtd_; - Vector > dtd_; - Ptr pass1Dtd_; - ConstPtr syntax_; - Vector currentRank_; - NamedTable idTable_; - NamedResourceTable instanceDefaultedEntityTable_; - Vector > currentAttributes_; - Markup *currentMarkup_; - Markup markup_; - Location markupLocation_; - Boolean hadAfdrDecl_; - SP_CONST SP_VOLATILE sig_atomic_t *cancelPtr_; - static sig_atomic_t dummyCancel_; - static const Location nullLocation_; -}; - -inline -Messenger &ParserState::messenger() -{ - return *this; -} - -inline -Boolean ParserState::wantMarkup() const -{ - return (inInstance_ - ? options_.eventsWanted.wantInstanceMarkup() - : options_.eventsWanted.wantPrologMarkup()); -} - -inline -const EventsWanted &ParserState::eventsWanted() const -{ - return options_.eventsWanted; -} - -inline -InputSource *ParserState::currentInput() const -{ - return inputStack_.head(); -} - -inline -const Location &ParserState::currentLocation() const -{ - InputSource *in = currentInput(); - return in ? in->currentLocation() : nullLocation_; -} - -inline -Boolean ParserState::pcdataRecovering() const -{ - return pcdataRecovering_; -} - -inline -unsigned ParserState::inputLevel() const -{ - return inputLevel_; -} - -inline -unsigned ParserState::specialParseInputLevel() const -{ - return specialParseInputLevel_; -} - -inline -unsigned ParserState::markedSectionLevel() const -{ - return markedSectionLevel_; -} - -inline -unsigned ParserState::markedSectionSpecialLevel() const -{ - return markedSectionSpecialLevel_; -} - -inline -const Location &ParserState::currentMarkedSectionStartLocation() const -{ - return markedSectionStartLocation_.back(); -} - -inline -Char ParserState::currentChar() const -{ - return currentInput()->currentTokenStart()[0]; -} - -inline -StringC ParserState::currentToken() const -{ - return StringC(currentInput()->currentTokenStart(), - currentInput()->currentTokenLength()); -} - -inline -void ParserState::getCurrentToken(StringC &str) const -{ - InputSource *in = currentInput(); - str.assign(in->currentTokenStart(), in->currentTokenLength()); -} - -inline -void ParserState::setRecognizer(Mode mode, ConstPtr p) -{ - recognizers_[mode] = p; -} - -inline -void ParserState::setNormalMap(const XcharMap &map) -{ - normalMap_ = map; -} - -inline -const XcharMap &ParserState::normalMap() const -{ - return normalMap_; -} - -inline -Boolean ParserState::haveDefLpd() const -{ - return !defLpd_.isNull(); -} - -inline -Boolean ParserState::haveCurrentDtd() const -{ - return !currentDtd_.isNull(); -} - -inline -Dtd &ParserState::defDtd() -{ - return *defDtd_; -} - -inline -const Dtd &ParserState::currentDtd() const -{ - return *currentDtd_; -} - -inline -const Ptr &ParserState::defDtdPointer() const -{ - return defDtd_; -} - -inline -const ConstPtr &ParserState::currentDtdPointer() const -{ - return currentDtd_; -} - -inline -Boolean ParserState::inInstance() const -{ - return inInstance_; -} - -inline -const Syntax &ParserState::syntax() const -{ - return *syntax_; -} - -inline -const Syntax &ParserState::instanceSyntax() const -{ - return *instanceSyntax_; -} - -inline -const ConstPtr &ParserState::syntaxPointer() const -{ - return syntax_; -} - -inline -const ConstPtr &ParserState::instanceSyntaxPointer() const -{ - return instanceSyntax_; -} - -inline -const ConstPtr &ParserState::prologSyntaxPointer() const -{ - return prologSyntax_; -} - -inline -const Sd &ParserState::sd() const -{ - return *sd_; -} - -inline -const ConstPtr &ParserState::sdPointer() const -{ - return sd_; -} - -inline -void ParserState::setPhase(Phase phase) -{ - phase_ = phase; -} - -inline -Mode ParserState::currentMode() const -{ - return currentMode_; -} - -inline -Xchar ParserState::getChar() -{ - return inputStack_.head()->get(messenger()); -} - -inline -void ParserState::skipChar() -{ - (void)getChar(); -} - -inline -Token ParserState::getToken(Mode mode) -{ - return recognizers_[mode]->recognize(inputStack_.head(), messenger()); -} - -inline -Boolean ParserState::hadDtd() const -{ - return dtd_.size() > 0; -} - -inline -Boolean ParserState::eventQueueEmpty() const -{ - return eventQueue_.empty(); -} - -inline -Event *ParserState::eventQueueGet() -{ - return eventQueue_.get(); -} - -inline -ParserState::Phase ParserState::phase() const -{ - return phase_; -} - -inline -ParserState::Phase ParserState::finalPhase() const -{ - return finalPhase_; -} - -inline -EntityManager &ParserState::entityManager() const -{ - return *entityManager_; -} - -inline -Ptr ParserState::entityManagerPtr() const -{ - return entityManager_; -} - -inline -const EntityCatalog &ParserState::entityCatalog() const -{ - return *entityCatalog_; -} - -inline -ConstPtr ParserState::entityCatalogPtr() const -{ - return entityCatalog_; -} - -inline -void ParserState::setEntityCatalog(const ConstPtr &catalog) -{ - entityCatalog_ = catalog; -} - -inline -void ParserState::setDsEntity(const ConstPtr &entity) -{ - dsEntity_ = entity; -} - -inline -Allocator &ParserState::eventAllocator() -{ - return eventAllocator_; -} - -inline -Allocator &ParserState::internalAllocator() -{ - return internalAllocator_; -} - -inline -StringC &ParserState::nameBuffer() -{ - return nameBuffer_; -} - -inline -void ParserState::setHandler(EventHandler *handler, - SP_CONST SP_VOLATILE sig_atomic_t *cancelPtr) -{ - handler_ = handler; - cancelPtr_ = cancelPtr ? cancelPtr : &dummyCancel_; -} - -inline -void ParserState::unsetHandler() -{ - handler_ = &eventQueue_; - cancelPtr_ = &dummyCancel_; -} - -inline -void ParserState::queueRe(const Location &location) -{ - outputState_.handleRe(*handler_, eventAllocator_, options_.eventsWanted, - syntax().standardFunction(Syntax::fRE), - location); -} - -inline -void ParserState::noteMarkup() -{ - if (inInstance_) - outputState_.noteMarkup(*handler_, eventAllocator_, options_.eventsWanted); -} - -inline -void ParserState::noteRs() -{ - outputState_.noteRs(*handler_, eventAllocator_, options_.eventsWanted); -} - -inline -void ParserState::noteStartElement(Boolean included) -{ - outputState_.noteStartElement(included, *handler_, eventAllocator_, - options_.eventsWanted); -} - -inline -void ParserState::noteEndElement(Boolean included) -{ - outputState_.noteEndElement(included, *handler_, eventAllocator_, - options_.eventsWanted); -} - -inline -void ParserState::noteData() -{ - outputState_.noteData(*handler_, eventAllocator_, options_.eventsWanted); -} - -inline -unsigned ParserState::subdocLevel() const -{ - return subdocLevel_; -} - -inline -EventHandler &ParserState::eventHandler() -{ - return *handler_; -} - -inline -ParserState::IdTableIter ParserState::idTableIter() -{ - // Avoid use of typedef to work around MSVC 2.0 bug. - return NamedTableIter(idTable_); -} - -inline -const ParserOptions &ParserState::options() const -{ - return options_; -} - -inline -void ParserState::keepMessages() -{ - keepingMessages_ = 1; -} - -inline -Boolean ParserState::haveApplicableDtd() const -{ - return !currentDtd_.isNull(); -} - -inline -Boolean ParserState::hadLpd() const -{ - return hadLpd_; -} - -inline -Boolean ParserState::pass2() const -{ - return pass2_; -} - -inline -size_t ParserState::nActiveLink() const -{ - return lpd_.size(); -} - -inline -const Lpd &ParserState::activeLpd(size_t i) const -{ - return *lpd_[i]; -} - -inline -Lpd &ParserState::defLpd() -{ - return *defLpd_; -} - -inline -Ptr &ParserState::defLpdPointer() -{ - return defLpd_; -} - -inline -Ptr ParserState::defComplexLpdPointer() -{ - return (ComplexLpd *)defLpd_.pointer(); -} - -inline -ComplexLpd &ParserState::defComplexLpd() -{ - return (ComplexLpd &)defLpd(); -} - -inline -Ptr ParserState::baseDtd() -{ - if (dtd_.size() > 0) - return dtd_[0]; - else - return Ptr(); -} - -inline -void ParserState::setResultAttributeSpecMode() -{ - resultAttributeSpecMode_ = 1; -} - -inline -void ParserState::clearResultAttributeSpecMode() -{ - resultAttributeSpecMode_ = 0; -} - -inline -Markup *ParserState::currentMarkup() -{ - return currentMarkup_; -} - -inline -const Location &ParserState::markupLocation() const -{ - return markupLocation_; -} - -inline -Markup *ParserState::startMarkup(Boolean storing, const Location &loc) -{ - markupLocation_ = loc; - if (storing) { - markup_.clear(); - return currentMarkup_ = &markup_; - } - else - return currentMarkup_ = 0; -} - -inline -Boolean ParserState::cancelled() const -{ - return *cancelPtr_ != 0; -} - -inline -void ParserState::setHadAfdrDecl() -{ - hadAfdrDecl_ = 1; -} - -inline -Boolean ParserState::hadAfdrDecl() const -{ - return hadAfdrDecl_; -} - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* not ParserState_INCLUDED */ diff --git a/cde/programs/nsgmls/Partition.C b/cde/programs/nsgmls/Partition.C deleted file mode 100644 index c0b8a6f62..000000000 --- a/cde/programs/nsgmls/Partition.C +++ /dev/null @@ -1,242 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: Partition.C /main/1 1996/07/29 17:01:30 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#ifdef __GNUG__ -#pragma implementation -#endif -#include "splib.h" -#include "Partition.h" -#include "ISet.h" -#include "ISetIter.h" -#include "SubstTable.h" -#include "Link.h" -#include "IList.h" -#include "IListIter.h" -#include "Owner.h" -#include "macros.h" -#include "EquivClass.h" -#include "constant.h" -#include "StringC.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -static void refineByChar(IList *, Char); -static void refineBySet(IList *, const ISet &, unsigned); - -#if _MSC_VER == 900 -// Work around MSVC 2.0 bug. -typedef SubstTable _msvc_dummy; -#endif - -Partition::Partition(const ISet &chars, - const ISet **sets, - int nSets, - const SubstTable &subst) -: map_(0) // eE gets code 0 -{ - IList classes; - classes.insert(new EquivClass); - classes.head()->set.addRange(0, charMax); - - { - ISetIter iter(chars); - Char min, max; - while (iter.next(min, max)) { - do { - refineByChar(&classes, subst[min]); - } while (min++ != max); - } - } - - int i; - for (i = 0; i < nSets; i++) - refineBySet(&classes, *sets[i], (1 << i)); - - maxCode_ = 0; - - setCodes_.resize(nSets); - - for (IListIter listIter(classes); - !listIter.done(); - listIter.next()) { - ++maxCode_; - ASSERT(maxCode_ != 0); - EquivClass *p = listIter.cur(); - for (i = 0; i < nSets; i++) - if ((1 << i) & p->inSets) - setCodes_[i] += maxCode_; - ISetIter setIter(p->set); - Char min, max; - while (setIter.next(min, max)) - map_.setRange(min, max, maxCode_); - } - - { - ISetIter iter(chars); - Char min, max; - while (iter.next(min, max)) { - do { - StringC str(subst.inverse(min)); - EquivCode code = map_[min]; - for (size_t i = 0; i < str.size(); i++) - map_.setChar(str[i], code); - } while (min++ != max); - } - } -} - -static -void refineByChar(IList *classes, Char c) -{ - // Avoid modifying *classes, while there's an active iter on it. - EquivClass *found = 0; - { - for (IListIter iter(*classes); !iter.done(); iter.next()) { - if (iter.cur()->set.contains(c)) { - found = iter.cur(); - break; - } - } - } - if (found && !found->set.isSingleton()) { - found->set.remove(c); - classes->insert(new EquivClass(found->inSets)); - classes->head()->set.add(c); - } -} - -static -void addUpTo(ISet *to, Char limit, const ISet &from) -{ - ISetIter iter(from); - Char min, max; - while (iter.next(min, max) && min < limit) - to->addRange(min, max >= limit ? limit - 1 : max); -} - -enum RefineResult { allIn, allOut, someInSomeOut }; - -static -RefineResult refine(const ISet &set, const ISet &refiner, - ISet *inp, ISet *outp) -{ - Char setMin, setMax, refMin, refMax; - ISetIter refIter(refiner); - ISetIter setIter(set); - Boolean oneIn = 0; - Boolean oneOut = 0; - - if (!refIter.next(refMin, refMax)) - return allOut; - while (setIter.next(setMin, setMax)) { - while (setMin <= setMax) { - while (refMax < setMin && refIter.next(refMin, refMax)) - ; - if (refMax < setMin || setMin < refMin) { - if (!oneOut) { - if (oneIn) - addUpTo(inp, setMin, set); - oneOut = 1; - } - if (refMax < setMin || refMin > setMax) { - if (oneIn) - outp->addRange(setMin, setMax); - break; - } - else { - if (oneIn) - outp->addRange(setMin, refMin - 1); - setMin = refMin; - } - } - else { - if (!oneIn) { - if (oneOut) - addUpTo(outp, setMin, set); - oneIn = 1; - } - if (setMax <= refMax) { - if (oneOut) - inp->addRange(setMin, setMax); - break; - } - else { - // refMax < setMax - if (oneOut) - inp->addRange(setMin, refMax); - // avoid wrapping round - if (refMax == charMax) - break; - setMin = refMax + 1; - } - } - } - } - if (oneIn) - return oneOut ? someInSomeOut : allIn; - else - return allOut; -} - -static -void refineBySet(IList *classes, const ISet &set, - unsigned setFlag) -{ - Owner in(new EquivClass), out(new EquivClass); - IList newClasses; - for (;;) { - EquivClass *p = classes->head(); - if (!p) - break; - if (!out) - out = new EquivClass; - switch (refine(p->set, set, &in->set, &out->set)) { - case someInSomeOut: - in->inSets = p->inSets | setFlag; - newClasses.insert(in.extract()); - out->inSets = p->inSets; - newClasses.insert(out.extract()); - in = classes->get(); - in->set.clear(); - in->inSets = 0; - break; - case allIn: - p->inSets |= setFlag; - newClasses.insert(classes->get()); - break; - case allOut: - newClasses.insert(classes->get()); - break; - } - } - classes->swap(newClasses); -} - -#ifdef SP_NAMESPACE -} -#endif diff --git a/cde/programs/nsgmls/Partition.h b/cde/programs/nsgmls/Partition.h deleted file mode 100644 index dcf16ba11..000000000 --- a/cde/programs/nsgmls/Partition.h +++ /dev/null @@ -1,97 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: Partition.h /main/1 1996/07/29 17:01:35 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#ifndef Partition_INCLUDED -#define Partition_INCLUDED 1 -#ifdef __GNUG__ -#pragma interface -#endif - -#include "types.h" -#include "SubstTable.h" -#include "StringOf.h" -#include "ISet.h" -#include "XcharMap.h" -#include "Vector.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -class Partition { -public: - Partition(const ISet &chars, - const ISet **sets, - int nSets, - const SubstTable &subst); - EquivCode maxCode() const; - EquivCode charCode(Char c) const; - EquivCode eECode() const; - const String &setCodes(int i) const; - const XcharMap &map() const; -private: - Partition(const Partition &); // undefined - void operator=(const Partition &); // undefined - EquivCode maxCode_; - Vector > setCodes_; - XcharMap map_; -}; - -inline -EquivCode Partition::maxCode() const -{ - return maxCode_; -} - -inline -EquivCode Partition::charCode(Char c) const -{ - return map_[c]; -} - -inline -EquivCode Partition::eECode() const -{ - return 0; -} - -inline -const String &Partition::setCodes(int i) const -{ - return setCodes_[i]; -} - -inline -const XcharMap &Partition::map() const -{ - return map_; -} - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* not Partition_INCLUDED */ diff --git a/cde/programs/nsgmls/PointerTable.C b/cde/programs/nsgmls/PointerTable.C deleted file mode 100644 index 4c47d64b9..000000000 --- a/cde/programs/nsgmls/PointerTable.C +++ /dev/null @@ -1,169 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: PointerTable.C /main/1 1996/07/29 17:01:40 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#ifndef PointerTable_DEF_INCLUDED -#define PointerTable_DEF_INCLUDED 1 - -#include - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -template -PointerTable::PointerTable() -: used_(0), usedLimit_(0), null_(0) -{ -} - -template -void PointerTable::clear() -{ - vec_.clear(); - used_ = 0; - usedLimit_ = 0; -} - -template -P PointerTable::insert(P p, Boolean replace) -{ - size_t h; - if (vec_.size() == 0) { - vec_.assign(8, P(0)); - usedLimit_ = 4; - h = startIndex(KF::key(*p)); - } - else { - for (h = startIndex(KF::key(*p)); vec_[h] != 0 ; h = nextIndex(h)) - if (KF::key(*vec_[h]) == KF::key(*p)) { - if (replace) { - P tem(vec_[h]); - vec_[h] = p; - return tem; - } - else - return vec_[h]; - } - if (used_ >= usedLimit_) { - if (vec_.size() > size_t(-1)/2) { - if (usedLimit_ == vec_.size() - 1) - abort(); // FIXME throw an exception - else - usedLimit_ = vec_.size() - 1; - } - else { - // rehash - Vector

oldVec(vec_.size()*2, P(0)); - vec_.swap(oldVec); - usedLimit_ = vec_.size() / 2; - for (size_t i = 0; i < oldVec.size(); i++) - if (oldVec[i] != 0) { - size_t j; - for (j = startIndex(KF::key(*oldVec[i])); - vec_[j] != 0; - j = nextIndex(j)) - ; - vec_[j] = oldVec[i]; - } - for (h = startIndex(KF::key(*p)); vec_[h] != 0; h = nextIndex(h)) - ; - } - } - } - used_++; - vec_[h] = p; - return 0; -} - -template -const P &PointerTable::lookup(const K &k) const -{ - if (used_ > 0) { - for (size_t i = startIndex(k); vec_[i] != 0; i = nextIndex(i)) - if (KF::key(*vec_[i]) == k) - return vec_[i]; - } - return null_; -} - -template -P PointerTable::remove(const K &k) -{ - if (used_ > 0) { - for (size_t i = startIndex(k); vec_[i] != 0; i = nextIndex(i)) - if (KF::key(*vec_[i]) == k) { - P p = vec_[i]; - do { - vec_[i] = P(0); - size_t j = i; - size_t r; - do { - i = nextIndex(i); - if (vec_[i] == 0) - break; - r = startIndex(KF::key(*vec_[i])); - } while ((i <= r && r < j) || (r < j && j < i) || (j < i && i <= r)); - vec_[j] = vec_[i]; - } while (vec_[i] != 0); - --used_; - return p; - } - } - return 0; -} - -template -void PointerTable::swap(PointerTable &to) -{ - vec_.swap(to.vec_); - size_t tem = to.used_; - to.used_ = used_; - used_ = tem; - tem = to.usedLimit_; - to.usedLimit_ = usedLimit_; - usedLimit_ = tem; -} - -template -PointerTableIter::PointerTableIter(const PointerTable &table) -: tablePtr_(&table), i_(0) -{ -} - -template -const P &PointerTableIter::next() -{ - for (; i_ < tablePtr_->vec_.size(); i_++) - if (tablePtr_->vec_[i_] != 0) - return tablePtr_->vec_[i_++]; - return tablePtr_->null_; -} - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* not PointerTable_DEF_INCLUDED */ diff --git a/cde/programs/nsgmls/PointerTable.h b/cde/programs/nsgmls/PointerTable.h deleted file mode 100644 index b6467b49b..000000000 --- a/cde/programs/nsgmls/PointerTable.h +++ /dev/null @@ -1,91 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: PointerTable.h /main/1 1996/07/29 17:01:44 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#ifndef PointerTable_INCLUDED -#define PointerTable_INCLUDED 1 - -#include "Vector.h" -#include "Boolean.h" -#include - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -template class PointerTableIter; - -template -class PointerTable { - void constraints() { - P p(0); - K key = KF::key(*p); - unsigned long n = HF::hash(key); - n = 0; // prevent warning - } -public: - PointerTable(); - P insert(P, Boolean replace = 0); - // Return a reference so that it is possible to do - // lookups into a table of smart-pointers from multiple threads. - const P &lookup(const K &) const; - P remove(const K &); - size_t count() const { return used_; } - void clear(); - void swap(PointerTable &); -protected: - size_t used_; - size_t usedLimit_; - Vector

vec_; - P null_; - - size_t startIndex(const K &k) const { - return size_t(HF::hash(k) & (vec_.size() - 1)); - } - size_t nextIndex(size_t i) const { - return i == 0 ? vec_.size() - 1 : i - 1; - } - friend class PointerTableIter; -}; - -template -class PointerTableIter { -public: - PointerTableIter(const PointerTable &); - const P &next(); -private: - const PointerTable *tablePtr_; - size_t i_; -}; - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* not PointerTable_INCLUDED */ - -#ifdef SP_DEFINE_TEMPLATES -#include "PointerTable.C" -#endif diff --git a/cde/programs/nsgmls/PosixStorage.C b/cde/programs/nsgmls/PosixStorage.C deleted file mode 100644 index d7e92d51e..000000000 --- a/cde/programs/nsgmls/PosixStorage.C +++ /dev/null @@ -1,667 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: PosixStorage.C /main/1 1996/07/29 17:01:49 cde-hp $ */ -// Copyright (c) 1994, 1995 James Clark -// See the file COPYING for copying permission. - -#ifdef __GNUG__ -#pragma implementation -#endif - -#include "splib.h" -#include "PosixStorage.h" -#include "RewindStorageObject.h" -#include "StorageManager.h" -#include "DescriptorManager.h" -#include "MessageArg.h" -#include "ErrnoMessageArg.h" -#include "SearchResultMessageArg.h" -#include "Message.h" -#include "StringC.h" -#include "StringOf.h" -#include "CharsetInfo.h" -#include "CodingSystem.h" -#include "macros.h" -#include "PosixStorageMessages.h" - -#include -#include -#include - -#ifdef SP_INCLUDE_IO_H -#include // for open, fstat, lseek, read prototypes -#endif - -#ifdef SP_INCLUDE_UNISTD_H -#include -#endif - -#ifdef SP_INCLUDE_OSFCN_H -#include -#endif - -#include -#include -#include -#include - -#ifndef S_ISREG -#ifndef S_IFREG -#define S_IFREG _S_IFREG -#endif -#ifndef S_IFMT -#define S_IFMT _S_IFMT -#endif -#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG) -#endif /* not S_ISREG */ - -#ifndef O_BINARY -#define O_BINARY 0 -#endif - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -#ifdef SP_WIDE_SYSTEM -typedef wchar_t FChar; -#else -typedef char FChar; -#endif - -class PosixBaseStorageObject : public RewindStorageObject { -public: - PosixBaseStorageObject(int fd, Boolean mayRewind); - size_t getBlockSize() const; -protected: - enum { defaultBlockSize = 8192 }; - int fd_; - PackedBoolean eof_; - - Boolean seekToStart(Messenger &); - virtual Boolean seek(off_t, Messenger &) = 0; - static int xclose(int fd); -private: - Boolean canSeek(int fd); - off_t startOffset_; -}; - -PosixBaseStorageObject::PosixBaseStorageObject(int fd, Boolean mayRewind) -: fd_(fd), eof_(0), - RewindStorageObject(mayRewind, mayRewind && canSeek(fd)), - startOffset_(0) -{ -} - -Boolean PosixBaseStorageObject::canSeek(int fd) -{ - struct stat sb; - if (fstat(fd, &sb) < 0 || !S_ISREG(sb.st_mode) - || (startOffset_ = lseek(fd, off_t(0), SEEK_CUR)) < 0) - return 0; - else - return 1; -} - -Boolean PosixBaseStorageObject::seekToStart(Messenger &mgr) -{ - eof_ = 0; - return seek(startOffset_, mgr); -} - -int PosixBaseStorageObject::xclose(int fd) -{ - int ret; - do { - ret = ::close(fd); - } while (ret < 0 && errno == EINTR); - return ret; -} - -class PosixStorageObject : public PosixBaseStorageObject, private DescriptorUser { -public: - PosixStorageObject(int fd, - const StringC &, - const String &, - Boolean mayRewind, - DescriptorManager *); - ~PosixStorageObject(); - Boolean read(char *buf, size_t bufSize, Messenger &mgr, size_t &nread); - Boolean suspend(); - Boolean seek(off_t, Messenger &); - void willNotRewind(); -private: - void resume(Messenger &); - - PackedBoolean suspended_; - off_t suspendPos_; - const MessageType2 *suspendFailedMessage_; - int suspendErrno_; - StringC filename_; - String cfilename_; - - void systemError(Messenger &, const MessageType2 &, int); -}; - -inline int openFile(const FChar *s) { -#ifdef SP_WIDE_SYSTEM - return _wopen(s, O_RDONLY|O_BINARY); -#else - return ::open(s, O_RDONLY|O_BINARY); -#endif - } - -PosixStorageManager::PosixStorageManager(const char *type, - const UnivCharsetDesc &filenameCharset, -#ifndef SP_WIDE_SYSTEM - const OutputCodingSystem *filenameCodingSystem, -#endif - int maxFDs) -: IdStorageManager(filenameCharset), - type_(type), -#ifndef SP_WIDE_SYSTEM - filenameCodingSystem_(filenameCodingSystem), -#endif - descriptorManager_(maxFDs) -{ - Char newline = idCharset()->execToDesc('\n'); - reString_.assign(&newline, 1); -} - -const char *PosixStorageManager::type() const -{ - return type_; -} - -void PosixStorageManager::addSearchDir(const StringC &str) -{ - searchDirs_.push_back(str); -} - -#ifdef SP_POSIX_FILENAMES - -#define FILENAME_TYPE_DEFINED - -// FIXME should use idCharset. - -Boolean PosixStorageManager::isAbsolute(const StringC &file) const -{ - return file.size() > 0 && file[0] == '/'; -} - -StringC PosixStorageManager::extractDir(const StringC &str) const -{ - for (size_t i = str.size(); i > 0; i--) - if (str[i - 1] == '/') - return StringC(str.data(), i); // include slash for root case - return StringC(); -} - -StringC PosixStorageManager::combineDir(const StringC &dir, - const StringC &base) const -{ - StringC result(dir); - if (dir.size() > 0 && dir[dir.size() - 1] != '/') - result += '/'; - result += base; - return result; -} - -Boolean PosixStorageManager::transformNeutral(StringC &str, Boolean fold, - Messenger &) const -{ - if (fold) - for (size_t i = 0; i < str.size(); i++) { - Char c = str[i]; - if (c <= (unsigned char)-1) - str[i] = tolower(str[i]); - } - return 1; -} - -#endif /* SP_POSIX_FILENAMES */ - -#ifdef SP_MSDOS_FILENAMES - -#define FILENAME_TYPE_DEFINED - -Boolean PosixStorageManager::isAbsolute(const StringC &s) const -{ - if (s.size() == 0) - return 0; - return s[0] == '/' || s[0] == '\\' || (s.size() > 1 && s[1] == ':'); -} - -StringC PosixStorageManager::extractDir(const StringC &str) const -{ - for (size_t i = str.size(); i > 0; i--) - if (str[i - 1] == '/' || str[i - 1] == '\\' - || (i == 2 && str[i - 1] == ':')) - return StringC(str.data(), i); // include separator - return StringC(); -} - -StringC PosixStorageManager::combineDir(const StringC &dir, - const StringC &base) const -{ - StringC result(dir); - if (dir.size() > 0) { - Char lastChar = dir[dir.size() - 1]; - if (lastChar != '/' && lastChar != '\\' - && !(dir.size() == 2 && lastChar == ':')) - result += '\\'; - } - result += base; - return result; -} - -Boolean PosixStorageManager::transformNeutral(StringC &str, Boolean, - Messenger &) const -{ - for (size_t i = 0; i < str.size(); i++) - if (str[i] == '/') - str[i] = '\\'; - return 1; -} - -#endif /* SP_MSDOS_FILENAMES */ - -#ifndef FILENAME_TYPE_DEFINED - -Boolean PosixStorageManager::isAbsolute(const StringC &) const -{ - return 1; -} - -StringC PosixStorageManager::extractDir(const StringC &) const -{ - return StringC(); -} - -StringC PosixStorageManager::combineDir(const StringC &, - const StringC &base) const -{ - return base; -} - -Boolean PosixStorageManager::transformNeutral(StringC &, Boolean, - Messenger &) const -{ - return 1; -} - -#endif /* not FILENAME_TYPE_DEFINED */ - -Boolean PosixStorageManager::resolveRelative(const StringC &baseId, - StringC &specId, - Boolean search) const -{ - if (isAbsolute(specId)) - return 1; - if (!search || searchDirs_.size() == 0) { - specId = combineDir(extractDir(baseId), specId); - return 1; - } - return 0; -} - -StorageObject * -PosixStorageManager::makeStorageObject(const StringC &spec, - const StringC &base, - Boolean search, - Boolean mayRewind, - Messenger &mgr, - StringC &found) -{ - if (spec.size() == 0) { - mgr.message(PosixStorageMessages::invalidFilename, - StringMessageArg(spec)); - return 0; - } - descriptorManager_.acquireD(); - Boolean absolute = isAbsolute(spec); - SearchResultMessageArg sr; - for (size_t i = 0; i < searchDirs_.size() + 1; i++) { - StringC filename; - if (absolute) - filename = spec; - else if (i == 0) - filename = combineDir(extractDir(base), spec); - else - filename = combineDir(searchDirs_[i - 1], spec); -#ifdef SP_WIDE_SYSTEM - String cfilename(filename); - cfilename += FChar(0); -#else - String cfilename = filenameCodingSystem_->convertOut(filename); -#endif - int fd; - do { - fd = openFile(cfilename.data()); - } while (fd < 0 && errno == EINTR); - if (fd >= 0) { - found = filename; - return new PosixStorageObject(fd, - filename, - cfilename, - mayRewind, - &descriptorManager_); - } - int savedErrno = errno; - if (absolute || !search || searchDirs_.size() == 0) { - ParentLocationMessenger(mgr).message(PosixStorageMessages::openSystemCall, - StringMessageArg(filename), - ErrnoMessageArg(savedErrno)); - descriptorManager_.releaseD(); - return 0; - } - sr.add(filename, savedErrno); - } - descriptorManager_.releaseD(); - ParentLocationMessenger(mgr).message(PosixStorageMessages::cannotFind, - StringMessageArg(spec), sr); - return 0; -} - -PosixStorageObject::PosixStorageObject(int fd, - const StringC &filename, - const String &cfilename, - Boolean mayRewind, - DescriptorManager *manager) -: DescriptorUser(manager), - PosixBaseStorageObject(fd, mayRewind), - suspended_(0), - filename_(filename), - cfilename_(cfilename), - suspendPos_(0), - suspendFailedMessage_(NULL), - suspendErrno_(0) -{ -} - -PosixStorageObject::~PosixStorageObject() -{ - if (fd_ >= 0) { - (void)xclose(fd_); - releaseD(); - } -} - -Boolean PosixStorageObject::seek(off_t off, Messenger &mgr) -{ - if (lseek(fd_, off, SEEK_SET) < 0) { - fd_ = -1; - systemError(mgr, PosixStorageMessages::lseekSystemCall, errno); - return 0; - } - else - return 1; -} - -Boolean PosixStorageObject::read(char *buf, size_t bufSize, Messenger &mgr, - size_t &nread) -{ - if (readSaved(buf, bufSize, nread)) - return 1; - if (suspended_) - resume(mgr); - if (fd_ < 0 || eof_) - return 0; - long n; - do { - n = ::read(fd_, buf, bufSize); - } while (n < 0 && errno == EINTR); - if (n > 0) { - nread = size_t(n); - saveBytes(buf, nread); - return 1; - } - if (n < 0) { - int saveErrno = errno; - releaseD(); - (void)xclose(fd_); - systemError(mgr, PosixStorageMessages::readSystemCall, saveErrno); - fd_ = -1; - } - else { - eof_ = 1; - // n == 0, so end of file - if (!mayRewind_) { - releaseD(); - if (xclose(fd_) < 0) - systemError(mgr, PosixStorageMessages::closeSystemCall, errno); - fd_ = -1; - } - - } - return 0; -} - -void PosixStorageObject::willNotRewind() -{ - RewindStorageObject::willNotRewind(); - if (eof_ && fd_ >= 0) { - releaseD(); - (void)xclose(fd_); - fd_ = -1; - } -} - -Boolean PosixStorageObject::suspend() -{ - if (fd_ < 0 || suspended_) - return 0; - struct stat sb; - if (fstat(fd_, &sb) < 0 || !S_ISREG(sb.st_mode)) - return 0; - suspendFailedMessage_ = 0; - suspendPos_ = lseek(fd_, 0, SEEK_CUR); - if (suspendPos_ == (off_t)-1) { - suspendFailedMessage_ = &PosixStorageMessages::lseekSystemCall; - suspendErrno_ = errno; - } - if (xclose(fd_) < 0 && !suspendFailedMessage_) { - suspendFailedMessage_ = &PosixStorageMessages::closeSystemCall; - suspendErrno_ = errno; - } - fd_ = -1; - suspended_ = 1; - releaseD(); - return 1; -} - -void PosixStorageObject::resume(Messenger &mgr) -{ - ASSERT(suspended_); - if (suspendFailedMessage_) { - systemError(mgr, *suspendFailedMessage_, suspendErrno_); - suspended_ = 0; - return; - } - acquireD(); - // suspended_ must be 1 until after acquireD() is called, - // so that we don't try to suspend this one before it is resumed. - suspended_ = 0; - do { - fd_ = openFile(cfilename_.data()); - } while (fd_ < 0 && errno == EINTR); - if (fd_ < 0) { - releaseD(); - systemError(mgr, PosixStorageMessages::openSystemCall, errno); - return; - } - if (lseek(fd_, suspendPos_, SEEK_SET) < 0) { - systemError(mgr, PosixStorageMessages::lseekSystemCall, errno); - (void)xclose(fd_); - fd_ = -1; - releaseD(); - } -} - -#ifdef SP_STAT_BLKSIZE - -size_t PosixBaseStorageObject::getBlockSize() const -{ - struct stat sb; - long sz; - if (fstat(fd_, &sb) < 0) - return defaultBlockSize; - if (!S_ISREG(sb.st_mode)) - return defaultBlockSize; - if ((unsigned long)sb.st_blksize > size_t(-1)) - sz = size_t(-1); - else - sz = sb.st_blksize; - return sz; -} - -#else /* not SP_STAT_BLKSIZE */ - -size_t PosixBaseStorageObject::getBlockSize() const -{ - return defaultBlockSize; -} - -#endif /* not SP_STAT_BLKSIZE */ - -void PosixStorageObject::systemError(Messenger &mgr, - const MessageType2 &msg, - int err) -{ - ParentLocationMessenger(mgr).message(msg, - StringMessageArg(filename_), - ErrnoMessageArg(err)); -} - -class PosixFdStorageObject : public PosixBaseStorageObject { -public: - PosixFdStorageObject(int, Boolean mayRewind); - Boolean read(char *buf, size_t bufSize, Messenger &mgr, size_t &nread); - Boolean seek(off_t, Messenger &); - enum { - noError, - readError, - invalidNumberError, - lseekError - }; -private: - int origFd_; -}; - -PosixFdStorageManager::PosixFdStorageManager(const char *type, - const UnivCharsetDesc &idCharset) -: IdStorageManager(idCharset), type_(type) -{ -} - -Boolean PosixFdStorageManager::inheritable() const -{ - return 0; -} - -StorageObject *PosixFdStorageManager::makeStorageObject(const StringC &id, - const StringC &, - Boolean, - Boolean mayRewind, - Messenger &mgr, - StringC &foundId) -{ - int n = 0; - size_t i; - for (i = 0; i < id.size(); i++) { - UnivChar ch; - if (!idCharset()->descToUniv(id[i], ch)) - break; - if (ch < UnivCharsetDesc::zero || ch > UnivCharsetDesc::zero + 9) - break; - int digit = ch - UnivCharsetDesc::zero; - // Allow the division to be done at compile-time. - if (n > INT_MAX/10) - break; - n *= 10; - if (n > INT_MAX - digit) - break; - n += digit; - } - if (i < id.size() || i == 0) { - mgr.message(PosixStorageMessages::invalidNumber, - StringMessageArg(id)); - return 0; - } - foundId = id; - // Could check access mode with fcntl(n, F_GETFL). - return new PosixFdStorageObject(n, mayRewind); -} - -PosixFdStorageObject::PosixFdStorageObject(int fd, Boolean mayRewind) -: PosixBaseStorageObject(fd, mayRewind), origFd_(fd) -{ -} - -const char *PosixFdStorageManager::type() const -{ - return type_; -} - -Boolean PosixFdStorageObject::read(char *buf, size_t bufSize, Messenger &mgr, - size_t &nread) -{ - if (readSaved(buf, bufSize, nread)) - return 1; - if (fd_ < 0 || eof_) - return 0; - long n; - do { - n = ::read(fd_, buf, bufSize); - } while (n < 0 && errno == EINTR); - if (n > 0) { - nread = size_t(n); - saveBytes(buf, nread); - return 1; - } - if (n < 0) { - ParentLocationMessenger(mgr).message(PosixStorageMessages::fdRead, - NumberMessageArg(fd_), - ErrnoMessageArg(errno)); - fd_ = -1; - } - else - eof_ = 1; - return 0; -} - -Boolean PosixFdStorageObject::seek(off_t off, Messenger &mgr) -{ - if (lseek(fd_, off, SEEK_SET) < 0) { - ParentLocationMessenger(mgr).message(PosixStorageMessages::fdLseek, - NumberMessageArg(fd_), - ErrnoMessageArg(errno)); - return 0; - } - else - return 1; -} - -#ifdef SP_NAMESPACE -} -#endif diff --git a/cde/programs/nsgmls/PosixStorage.h b/cde/programs/nsgmls/PosixStorage.h deleted file mode 100644 index 9781b5e4c..000000000 --- a/cde/programs/nsgmls/PosixStorage.h +++ /dev/null @@ -1,105 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: PosixStorage.h /main/1 1996/07/29 17:01:53 cde-hp $ */ -// Copyright (c) 1994, 1995 James Clark -// See the file COPYING for copying permission. - -#ifndef PosixStorage_INCLUDED -#define PosixStorage_INCLUDED 1 -#ifdef __GNUG__ -#pragma interface -#endif - -#include "StorageManager.h" -#include "DescriptorManager.h" -#include "Vector.h" -#include "StringC.h" -#include "CharsetInfo.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -class Messenger; -class CharsetInfo; -class UnivCharsetDesc; -class Filename; -class OutputCodingSystem; - -class SP_API PosixStorageManager : public IdStorageManager { -public: - PosixStorageManager(const char *type, - const UnivCharsetDesc &filenameCharset, -#ifndef SP_WIDE_SYSTEM - const OutputCodingSystem *filenameCodingSystem, -#endif - int maxFDs); - StorageObject *makeStorageObject(const StringC &id, - const StringC &baseId, - Boolean search, - Boolean mayRewind, - Messenger &, - StringC &foundId); - Boolean resolveRelative(const StringC &, StringC &, Boolean syntactic = 0) - const; - const char *type() const; - void addSearchDir(const StringC &); - Boolean transformNeutral(StringC &, Boolean fold, Messenger &) const; -private: - Boolean isAbsolute(const StringC &) const; - StringC extractDir(const StringC &) const; - StringC combineDir(const StringC &, const StringC &) const; - PosixStorageManager(const PosixStorageManager &); // undefined - void operator=(const PosixStorageManager &); // undefined - DescriptorManager descriptorManager_; -#ifndef SP_WIDE_SYSTEM - const OutputCodingSystem *filenameCodingSystem_; -#endif - const char *type_; - Vector searchDirs_; -}; - -class SP_API PosixFdStorageManager : public IdStorageManager { -public: - PosixFdStorageManager(const char *type, - const UnivCharsetDesc &filenameCharset); - StorageObject *makeStorageObject(const StringC &id, - const StringC &baseId, - Boolean, - Boolean mayRewind, - Messenger &mgr, - StringC &foundId); - const char *type() const; - Boolean inheritable() const; -private: - PosixFdStorageManager(const PosixFdStorageManager &); // undefined - void operator=(const PosixFdStorageManager &); // undefined - const char *type_; - -}; - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* not PosixStorage_INCLUDED */ diff --git a/cde/programs/nsgmls/PosixStorageMessages.h b/cde/programs/nsgmls/PosixStorageMessages.h deleted file mode 100644 index 0f04fcb6e..000000000 --- a/cde/programs/nsgmls/PosixStorageMessages.h +++ /dev/null @@ -1,161 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: PosixStorageMessages.h /main/1 1996/07/29 17:01:59 cde-hp $ */ -// This file was automatically generated from PosixStorageMessages.msg by msggen.pl. -#include "Message.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -struct PosixStorageMessages { - // 2200 - static const MessageType2 readSystemCall; - // 2201 - static const MessageType2 openSystemCall; - // 2202 - static const MessageType2 closeSystemCall; - // 2203 - static const MessageType2 lseekSystemCall; - // 2204 - static const MessageType1 invalidFilename; - // 2205 - static const MessageType2 fdRead; - // 2206 - static const MessageType2 fdLseek; - // 2207 - static const MessageType1 invalidNumber; - // 2208 - static const MessageType2 cannotFind; -}; -const MessageType2 PosixStorageMessages::readSystemCall( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -2200 -#ifndef SP_NO_MESSAGE_TEXT -,"error reading %1 (%2)" -#endif -); -const MessageType2 PosixStorageMessages::openSystemCall( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -2201 -#ifndef SP_NO_MESSAGE_TEXT -,"cannot open %1 (%2)" -#endif -); -const MessageType2 PosixStorageMessages::closeSystemCall( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -2202 -#ifndef SP_NO_MESSAGE_TEXT -,"error closing %1 (%2)" -#endif -); -const MessageType2 PosixStorageMessages::lseekSystemCall( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -2203 -#ifndef SP_NO_MESSAGE_TEXT -,"error seeking on %1 (%2)" -#endif -); -const MessageType1 PosixStorageMessages::invalidFilename( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -2204 -#ifndef SP_NO_MESSAGE_TEXT -,"invalid filename %1" -#endif -); -const MessageType2 PosixStorageMessages::fdRead( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -2205 -#ifndef SP_NO_MESSAGE_TEXT -,"error reading file descriptor %1 (%2)" -#endif -); -const MessageType2 PosixStorageMessages::fdLseek( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -2206 -#ifndef SP_NO_MESSAGE_TEXT -,"error seeking on file descriptor %1 (%2)" -#endif -); -const MessageType1 PosixStorageMessages::invalidNumber( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -2207 -#ifndef SP_NO_MESSAGE_TEXT -,"%1 is not a valid file descriptor number" -#endif -); -const MessageType2 PosixStorageMessages::cannotFind( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -2208 -#ifndef SP_NO_MESSAGE_TEXT -,"cannot find %1; tried %2" -#endif -); -#ifdef SP_NAMESPACE -} -#endif diff --git a/cde/programs/nsgmls/Priority.h b/cde/programs/nsgmls/Priority.h deleted file mode 100644 index 16de86ca6..000000000 --- a/cde/programs/nsgmls/Priority.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: Priority.h /main/1 1996/07/29 17:02:03 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#ifndef Priority_INCLUDED -#define Priority_INCLUDED 1 - -#include -#include "Boolean.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -class Priority { -public: - typedef unsigned char Type; - enum { - data = 0, - function = 1, - delim = UCHAR_MAX - }; - static inline Type blank(int n) { - // `Priority::' works round gcc 2.5.5 bug - return Priority::Type(n + 1); - } - static inline Boolean isBlank(Type t) { - return function < t && t < delim; - } -}; - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* not Priority_INCLUDED */ diff --git a/cde/programs/nsgmls/Ptr.C b/cde/programs/nsgmls/Ptr.C deleted file mode 100644 index b1119c2e5..000000000 --- a/cde/programs/nsgmls/Ptr.C +++ /dev/null @@ -1,95 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: Ptr.C /main/1 1996/07/29 17:02:08 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#ifndef Ptr_DEF_INCLUDED -#define Ptr_DEF_INCLUDED 1 - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -template -Ptr::Ptr(T *ptr) : ptr_(ptr) -{ - if (ptr_) - ptr_->ref(); -} - -template -Ptr::~Ptr() -{ - if (ptr_) { - if (ptr_->unref()) - delete ptr_; - ptr_ = 0; - } -} - -template -Ptr::Ptr(const Ptr &p) -: ptr_(p.ptr_) -{ - if (p.ptr_) - p.ptr_->ref(); -} - -template -Ptr &Ptr::operator=(const Ptr &p) -{ - if (p.ptr_) - p.ptr_->ref(); - if (ptr_ && ptr_->unref()) - delete ptr_; - ptr_ = p.ptr_; - return *this; -} - -template -Ptr &Ptr::operator=(T *p) -{ - if (p) - p->ref(); - if (ptr_ && ptr_->unref()) - delete ptr_; - ptr_ = p; - return *this; -} - -template -void Ptr::clear() -{ - if (ptr_) { - if (ptr_->unref()) - delete ptr_; - ptr_ = 0; - } -} - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* not Ptr_DEF_INCLUDED */ diff --git a/cde/programs/nsgmls/Ptr.h b/cde/programs/nsgmls/Ptr.h deleted file mode 100644 index 24baf0636..000000000 --- a/cde/programs/nsgmls/Ptr.h +++ /dev/null @@ -1,122 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: Ptr.h /main/2 1996/08/12 16:00:24 mgreess $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#ifndef Ptr_INCLUDED -#define Ptr_INCLUDED 1 - -#include "Boolean.h" - -// T must have Resource as a public base class -// T may be an incomplete type - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -template -class Ptr { -public: - Ptr() : ptr_(0) { } - Ptr(T *ptr); - ~Ptr(); - Ptr(const Ptr &); - Ptr &operator=(const Ptr &); - Ptr &operator=(T *); - T *pointer() const { return ptr_; } - T *operator->() const { return ptr_; } - T &operator*() const { return *ptr_; } - void swap(Ptr &p) { - T *tem = p.ptr_; - p.ptr_ = ptr_; - ptr_ = tem; - } - Boolean isNull() const { return ptr_ == 0; } - // operator const void *() const { return ptr_; } - void clear(); - Boolean operator==(const Ptr &p) const { - return ptr_ == p.ptr_; - } - Boolean operator!=(const Ptr &p) const { - return ptr_ != p.ptr_; - } - Boolean operator==(const T *p) const { - return ptr_ == p; - } - Boolean operator!=(const T *p) const { - return ptr_ != p; - } -private: - T *ptr_; -}; - -template -class ConstPtr : private Ptr { -public: - ConstPtr() { } - ConstPtr(T *ptr) : Ptr(ptr) { } - ConstPtr(const Ptr &p) : Ptr(p) { } - ConstPtr(const ConstPtr &p) : Ptr(p) { } - ConstPtr &operator=(const Ptr &p) { - Ptr::operator=(p); return *this; - } - ConstPtr &operator=(const ConstPtr &p) { - Ptr::operator=(p); return *this; - } - ConstPtr &operator=(T *p) { - Ptr::operator=(p); return *this; - } - const T *pointer() const { return Ptr::pointer(); } - const T *operator->() const { return Ptr::pointer(); } - const T &operator*() const { return *Ptr::pointer(); } - void swap(ConstPtr &p) { Ptr::swap(p); } - using Ptr::isNull; - -#if defined(__SUNPRO_CC) && __SUNPRO_CC == 0x5100 - /* Needed to avoid symbol export collision */ - void clear() { Ptr::clear(); } -#else - using Ptr::clear; -#endif - - Boolean operator==(const Ptr &p) const { return Ptr::operator==(p); } - Boolean operator!=(const Ptr &p) const { return Ptr::operator!=(p); } - Boolean operator==(const ConstPtr &p) const { - return Ptr::operator==(p); - } - Boolean operator!=(const ConstPtr &p) const { - return Ptr::operator!=(p); - } -}; - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* not Ptr_INCLUDED */ - -#ifdef SP_DEFINE_TEMPLATES -#include "Ptr.C" -#endif diff --git a/cde/programs/nsgmls/RangeMap.C b/cde/programs/nsgmls/RangeMap.C deleted file mode 100644 index c3b416649..000000000 --- a/cde/programs/nsgmls/RangeMap.C +++ /dev/null @@ -1,176 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: RangeMap.C /main/1 1996/07/29 17:02:17 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#ifndef RangeMap_DEF_INCLUDED -#define RangeMap_DEF_INCLUDED 1 - -#include "RangeMap.h" -#include "ISet.h" -#include "types.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -template -RangeMap::RangeMap() -{ -} - -template -Boolean RangeMap::map(From from, To &to, From &alsoMax) const -{ - // FIXME use binary search - for (size_t i = 0; i < ranges_.size(); i++) { - const RangeMapRange &r = ranges_[i]; - if (r.fromMin <= from && from <= r.fromMax) { - to = r.toMin + (from - r.fromMin); - alsoMax = r.fromMax; - return 1; - } - } - return 0; -} - - -typedef ISet RangeMap_dummy; - -template -unsigned RangeMap::inverseMap(To to, From &from, - ISet &fromSet, - WideChar &count) const -{ - // FIXME use binary search - unsigned ret = 0; - for (size_t i = 0; i < ranges_.size(); i++) { - const RangeMapRange &r = ranges_[i]; - if (r.toMin <= to && to <= r.toMin + (r.fromMax - r.fromMin)) { - From n = r.fromMin + (to - r.toMin); - WideChar thisCount = r.fromMax - r.fromMin + 1; - if (ret > 1) { - fromSet.add(n); - if (thisCount < count) - count = thisCount; - } - else if (ret == 1) { - fromSet.add(from); - fromSet.add(n); - ret = 2; - if (thisCount < count) - count = thisCount; - } - else { - count = thisCount; - from = n; - ret = 1; - } - } - } - return ret; -} - -template -RangeMapIter::RangeMapIter(const RangeMap &map) -: count_(map.ranges_.size()), ptr_(map.ranges_.begin()) -{ -} - -// If the new range overlaps an existing one, the new -// one takes precedence. - -template -void RangeMap::addRange(From fromMin, From fromMax, To toMin) -{ - // FIXME use binary search - size_t i; - for (i = ranges_.size(); i > 0; i--) - if (fromMin > ranges_[i - 1].fromMax) - break; - // fromMin <= ranges[i].fromMax - Boolean coalesced = 0; - if (i > 0 - && ranges_[i - 1].fromMax + 1 == fromMin - && ranges_[i - 1].toMin + (fromMin - ranges_[i - 1].fromMin) == toMin) { - // coalesce with previous - ranges_[i - 1].fromMax = fromMax; - i--; - coalesced = 1; - } - else if (i < ranges_.size() && fromMax >= ranges_[i].fromMin - 1) { - // overlap - if (fromMin <= ranges_[i].fromMin) { - if (toMin + (ranges_[i].fromMin - fromMin) == ranges_[i].toMin) { - ranges_[i].fromMin = fromMin; - if (fromMax <= ranges_[i].fromMax) - return; - ranges_[i].fromMax = fromMax; - coalesced = 1; - } - } - else { - // fromMin > ranges_[i].fromMin - if (ranges_[i].toMin + (fromMin - ranges_[i].fromMin) == toMin) { - if (fromMax < ranges_[i].fromMax) - return; - ranges_[i].fromMax = fromMax; - coalesced = 1; - } - } - } - if (!coalesced) { - // insert - ranges_.resize(ranges_.size() + 1); - for (size_t j = ranges_.size() - 1; j > i; j--) - ranges_[j] = ranges_[j - 1]; - ranges_[i].fromMin = fromMin; - ranges_[i].fromMax = fromMax; - ranges_[i].toMin = toMin; - } - // Delete overlapping ranges starting at i + 1. - size_t j; - for (j = i + 1; j < ranges_.size(); j++) { - if (fromMax < ranges_[j].fromMax) { - if (fromMax >= ranges_[j].fromMin) - ranges_[j].fromMin = fromMax + 1; - break; - } - } - if (j > i + 1) { - // delete i + 1 ... j - 1 - // j -> i + 1 - // j - 1 -> i + 2 - size_t count = ranges_.size() - j; - for (size_t k = 0; k < count; k++) - ranges_[i + 1 + count] = ranges_[j + count]; - ranges_.resize(ranges_.size() - (j - (i + 1))); - } -} - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* not RangeMap_DEF_INCLUDED */ diff --git a/cde/programs/nsgmls/RangeMap.h b/cde/programs/nsgmls/RangeMap.h deleted file mode 100644 index 74fa000bb..000000000 --- a/cde/programs/nsgmls/RangeMap.h +++ /dev/null @@ -1,94 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: RangeMap.h /main/1 1996/07/29 17:02:22 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#ifndef RangeMap_INCLUDED -#define RangeMap_INCLUDED 1 - -#include "Vector.h" -#include "Boolean.h" -#include "ISet.h" -#include "types.h" -#include - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -template -struct RangeMapRange { - RangeMapRange() { } - ~RangeMapRange() { } - From fromMin; - From fromMax; - To toMin; -}; - -template class RangeMapIter; - -template -class RangeMap { -public: - RangeMap(); - Boolean map(From, To &, From &alsoMax) const; - // Return 0 for no matches, 1 for 1, 2 for more than 1. - unsigned inverseMap(To, From &, ISet &, WideChar &count) const; - void addRange(From, From, To); -private: - Vector > ranges_; - friend class RangeMapIter; -}; - -template -class RangeMapIter { -public: - RangeMapIter(const RangeMap &map); - Boolean next(From &fromMin, From &fromMax, To &toMin) { - if (!count_) - return 0; - else { - fromMin = ptr_->fromMin; - fromMax = ptr_->fromMax; - toMin = ptr_->toMin; - ptr_++; - count_--; - return 1; - } - } -private: - size_t count_; - const RangeMapRange *ptr_; -// Vector >::const_iterator ptr_; -}; - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* not RangeMap_INCLUDED */ - -#ifdef SP_DEFINE_TEMPLATES -#include "RangeMap.C" -#endif diff --git a/cde/programs/nsgmls/RastEventHandler.C b/cde/programs/nsgmls/RastEventHandler.C deleted file mode 100644 index 3a742070a..000000000 --- a/cde/programs/nsgmls/RastEventHandler.C +++ /dev/null @@ -1,928 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: RastEventHandler.C /main/1 1996/07/29 17:02:26 cde-hp $ */ -// Copyright (c) 1994,1995 James Clark -// See the file COPYING for copying permission. - -#ifdef __GNUG__ -#pragma implementation -#endif - -#include "config.h" -#include "RastEventHandler.h" -#include "SgmlParser.h" -#include "ParserOptions.h" -#include "Entity.h" -#include "Notation.h" -#include "Attribute.h" -#include "Vector.h" -#include "Vector.h" -#include "MessageArg.h" - -#include "RastEventHandlerMessages.h" - -#include -#include - -// This is based on ISO/IEC 13673, Intermediate Editor's Draft, 1994/8/29, -// together with editing instructions in ISO/IEC JTC1/SC18/WG8 N1777. - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -const OutputCharStream::Newline nl = OutputCharStream::newline; - -class EventHandlerMessenger : public Messenger { -public: - EventHandlerMessenger(EventHandler *eh) : eh_(eh) { } - void dispatchMessage(const Message &message) { - eh_->message(new MessageEvent(message)); - } - void dispatchMessage(Message &message) { - eh_->message(new MessageEvent(message)); - } -private: - EventHandler *eh_; -}; - -#if 0 -const -#endif -RastPrintable RastEventHandler::printable; - -RastPrintable::RastPrintable() -{ - static const char s[] = - " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~"; - size_t i; - for (i = 0; i < sizeof(v_); i++) - v_[i] = 0; - for (i = 0; s[i] != '\0'; i++) - v_[(unsigned char)s[i]] = 32 + i; -} - -// inline -void RastEventHandler::flushLine(LineType type) -{ - if (lineLength_ > 0) { - os() << char(type) << nl; - lineLength_ = 0; - } -} - -RastSubdocState::RastSubdocState() -{ - init(0, 0); -} - -RastSubdocState::RastSubdocState(SgmlParser *parser, RastEventHandler *rast) -{ - init(parser, rast); -} - -void RastSubdocState::init(SgmlParser *parser, RastEventHandler *rast) -{ - parser_ = parser; - hadActiveLpdOrDtd_ = 0; - activeLinkTypes_.clear(); - hadDocumentElement_ = 0; - linkProcess_.clear(); - linkProcess_.setHandler(rast); - haveLinkProcess_ = 0; - endPrologEvent_.clear(); - parseSubdocQueue_.clear(); - linkRuleQueue_.clear(); - for (int i = 0; i < nAttributeType; i++) - attributeSortOrder_[i].clear(); -} - -void RastSubdocState::swap(RastSubdocState &to) -{ - { - SgmlParser *tem = to.parser_; - to.parser_ = parser_; - parser_ = tem; - } - { - Boolean tem = to.hadActiveLpdOrDtd_; - to.hadActiveLpdOrDtd_ = hadActiveLpdOrDtd_; - hadActiveLpdOrDtd_ = tem; - } - { - Boolean tem = to.hadDocumentElement_; - to.hadDocumentElement_ = hadDocumentElement_; - hadDocumentElement_ = tem; - } - activeLpdOrDtdLocation_.swap(to.activeLpdOrDtdLocation_); - activeLinkTypes_.swap(to.activeLinkTypes_); - linkProcess_.swap(to.linkProcess_); - endPrologEvent_.swap(to.endPrologEvent_); - parseSubdocQueue_.swap(to.parseSubdocQueue_); - linkRuleQueue_.swap(to.linkRuleQueue_); - for (int i = 0; i < nAttributeType; i++) - attributeSortOrder_[i].swap(to.attributeSortOrder_[i]); -} - -RastEventHandler::RastEventHandler(SgmlParser *parser, Messenger *mgr) -: lineLength_(0), - os_(0), - piErrorCount_(0), - RastSubdocState(parser, this), - mgr_(mgr) -{ - RastSubdocState::init(parser, this); -} - -void RastEventHandler::end() -{ - if (errorCount() != 0) { - truncateOutput(); - os() << (piErrorCount_ != 0 - ? "#RAST-PI-ERROR" - : "#ERROR") - << nl; - } -} - -void RastEventHandler::truncateOutput() -{ - // This must be handled by derived classes to get conforming output. -} - -void RastEventHandler::sgmlDecl(SgmlDeclEvent *event) -{ - rastParseSubdocYesString_ = event->sd().execToDoc("rast-parse-subdoc:yes"); - rastParseSubdocNoString_ = event->sd().execToDoc("rast-parse-subdoc:no"); - rastActiveLpdString_ = event->sd().execToDoc("rast-active-lpd:"); - rastLinkRuleString_ = event->sd().execToDoc("rast-link-rule:"); - delete event; -} - -void RastEventHandler::startElement(StartElementEvent *event) -{ - flushLine(dataLine); - if (!hadDocumentElement_) { - if (activeLinkTypes_.size() > 0) { - activeLinks(); - simpleLinkInfo(); - } - hadDocumentElement_ = 1; - } - os() << '[' << event->name(); - Boolean hadNewline; - if (event->attributes().size() > 0) { - hadNewline = 1; - os() << nl; - attributeInfo(event->attributes(), dtdAttribute); - } - else - hadNewline = 0; - if (haveLinkProcess_) { - const AttributeList *linkAttributes; - const ResultElementSpec *resultElementSpec; - EventHandlerMessenger messenger(this); - linkProcess_.startElement(event->elementType(), - event->attributes(), - event->location(), - messenger, - linkAttributes, - resultElementSpec); - if (linkProcess_.nImpliedLinkRules() > 0) { - if (!hadNewline) { - os() << nl; - hadNewline = 1; - } - os() << "#LINK-SET-INFO" << nl; - impliedSourceLinkRules(); - } - if (linkAttributes) { - if (!hadNewline) { - os() << nl; - hadNewline = 1; - } - os() << "#LINK-RULE" << nl; - attributeInfo(*linkAttributes, linkAttribute); - if (linkProcess_.isExplicit()) { - os() << "#RESULT="; - if (resultElementSpec && resultElementSpec->elementType) { - os() << resultElementSpec->elementType->name() << nl; - attributeInfo(resultElementSpec->attributeList, resultAttribute); - } - else - os() << "#IMPLIED" << nl; - } - } - else - hadNewline = 0; - } - os() << ']' << nl; - delete event; -} - -void RastEventHandler::activeLinks() -{ - for (size_t i = 0; i < activeLinkTypes_.size(); i++) { - os() << "#ACTIVE-LINK=" << activeLinkTypes_[i] << nl; - Boolean found = 0; - if (haveLinkProcess_ && linkProcess_.name() == activeLinkTypes_[i]) { - found = 1; - if (linkProcess_.nImpliedLinkRules() > 0) { - os() << "#INITIAL" << nl; - impliedSourceLinkRules(); - } - } - if (!found) { - if (endPrologEvent_) { - for (size_t j = 0; j < endPrologEvent_->simpleLinkNames().size(); j++) - if (endPrologEvent_->simpleLinkNames()[j] == activeLinkTypes_[i]) { - found = 1; - break; - } - } - if (!found) { - setNextLocation(activeLpdOrDtdLocation_); - Messenger::message(RastEventHandlerMessages::invalidActiveLinkType, - StringMessageArg(activeLinkTypes_[i])); - } - } - os() << "#END-ACTIVE-LINK" << nl; - } -} - -void RastEventHandler::simpleLinkInfo() -{ - if (!endPrologEvent_) - return; - for (size_t i = 0; i < activeLinkTypes_.size(); i++) { - for (size_t j = 0; j < endPrologEvent_->simpleLinkNames().size(); j++) { - const StringC &name = endPrologEvent_->simpleLinkNames()[j]; - if (name == activeLinkTypes_[i]) { - os() << "#SIMPLE-LINK=" << name << nl; - if (endPrologEvent_->simpleLinkAttributes()[j].size() > 0) - attributeInfo(endPrologEvent_->simpleLinkAttributes()[j], - simpleAttribute); - os() << "#END-SIMPLE-LINK" << nl; - break; - } - } - } -} - -void RastEventHandler::impliedSourceLinkRules() -{ - size_t n = linkProcess_.nImpliedLinkRules(); - Vector sortOrder(n); - size_t i; - for (i = 0; i < n; i++) - sortOrder[i] = i; - for (i = 1; i < n; i++) { - size_t tem = sortOrder[i]; - const StringC &name - = linkProcess_.impliedLinkRule(tem).elementType->name(); - size_t j; - for (j = i; j > 0; j--) { - if (lexCmp(linkProcess_.impliedLinkRule(j - 1).elementType->name(), - name) <= 0) - break; - sortOrder[j] = sortOrder[j - 1]; - } - sortOrder[j] = tem; - } - for (i = 0; i < n; i++) { - const ResultElementSpec &result - = linkProcess_.impliedLinkRule(sortOrder[i]); - os() << '[' << result.elementType->name(); - if (result.attributeList.size() > 0) { - os() << nl; - attributeInfo(result.attributeList, resultAttribute); - } - os() << ']' << nl; - } -} - -void RastEventHandler::endElement(EndElementEvent *event) -{ - if (haveLinkProcess_) - linkProcess_.endElement(); - flushLine(dataLine); - os() << "[/" << event->name() << ']' << nl; - if (haveLinkProcess_ && linkProcess_.nImpliedLinkRules() > 0) { - os() << "#LINK-SET-INFO" << nl; - impliedSourceLinkRules(); - os() << "#END-LINK-SET-INFO" << nl; - } - delete event; -} - -void RastEventHandler::data(DataEvent *event) -{ - lines(dataLine, event->data(), event->dataLength()); - delete event; -} - -void RastEventHandler::pi(PiEvent *event) -{ - flushLine(dataLine); - os() << "[?"; - size_t dataLength = event->dataLength(); - if (dataLength > 0) { - const Char *data = event->data(); - if (dataLength >= 4 - && memcmp(data, - rastParseSubdocYesString_.data(), - 4*sizeof(Char)) == 0 - && !interpretRastPi(data, dataLength, event->location())) { - setNextLocation(event->location()); - Messenger::message(RastEventHandlerMessages::invalidRastPiError); - } - os() << nl; - lines(dataLine, event->data(), dataLength); - flushLine(dataLine); - } - os() << ']' << nl; - delete event; -} - -inline -Boolean equal(const Char *s1, size_t n1, const StringC &s2) -{ - return (n1 == s2.size() - && (n1 == 0 - || memcmp(s1, s2.data(), n1*sizeof(Char)) == 0)); -} - -// Is s2 a prefix of s1 of length n1? - -inline -Boolean prefix(const Char *s1, size_t n1, const StringC &s2) -{ - return (n1 >= s2.size() - && (n1 == 0 - || memcmp(s1, s2.data(), s2.size()*sizeof(Char)) == 0)); -} - -Boolean RastEventHandler::interpretRastPi(const Char *data, - size_t dataLength, - const Location &loc) -{ - if (equal(data, dataLength, rastParseSubdocNoString_)) { - queueParseSubdoc(0); - return 1; - } - if (equal(data, dataLength, rastParseSubdocYesString_)) { - queueParseSubdoc(1); - return 1; - } - if (prefix(data, dataLength, rastActiveLpdString_)) { - if (hadActiveLpdOrDtd_) - return 1; - hadActiveLpdOrDtd_ = 1; - activeLpdOrDtdLocation_ = loc; - const Char *p = data + rastActiveLpdString_.size(); - size_t n = dataLength - rastActiveLpdString_.size(); - StringC name; - for (;;) { - if (n == 0 || *p == ',') { - if (name.size() == 0) - return 0; - for (size_t i = 0; i < activeLinkTypes_.size(); i++) - if (name == activeLinkTypes_[i]) { - setNextLocation(activeLpdOrDtdLocation_); - Messenger::message(RastEventHandlerMessages::duplicateActiveLinkType, - StringMessageArg(name)); - } - activeLinkTypes_.resize(activeLinkTypes_.size() + 1); - name.swap(activeLinkTypes_.back()); - if (n == 0) - break; - } - else - name += *p; - p++; - n--; - } - for (size_t i = 0; i < activeLinkTypes_.size(); i++) - parser_->activateLinkType(activeLinkTypes_[i]); - return 1; - } - if (prefix(data, dataLength, rastLinkRuleString_)) { - LinkRulePi *p = new LinkRulePi; - p->pi.assign(data + rastLinkRuleString_.size(), - dataLength - rastLinkRuleString_.size()); - p->loc = loc; - linkRuleQueue_.append(p); - return 1; - } - return 0; -} - -void RastEventHandler::sdataEntity(SdataEntityEvent *event) -{ - flushLine(dataLine); - os() << "#SDATA-TEXT" << nl; - lines(markupLine, event->data(), event->dataLength()); - flushLine(markupLine); - os() << "#END-SDATA" << nl; - delete event; -} - -void RastEventHandler::externalDataEntity(ExternalDataEntityEvent *event) -{ - const ExternalDataEntity *entity = event->entity(); - if (!entity) - return; - flushLine(dataLine); - os() << "[&" << entity->name() << nl; - externalEntityInfo(entity, dtdAttribute); - os() << ']' << nl; - delete event; -} - -void RastEventHandler::externalEntityInfo(const ExternalDataEntity *entity, - AttributeType attributeType) -{ - char c; - switch (entity->dataType()) { - case Entity::cdata: - c = 'C'; - break; - case Entity::sdata: - c = 'S'; - break; - case Entity::ndata: - c = 'N'; - break; - default: - return; - } - os() << '#' << c << "DATA-EXTERNAL" << nl; - externalIdInfo(entity->externalId()); - os() << "#NOTATION=" << entity->notation()->name() << nl; - externalIdInfo(entity->notation()->externalId()); - attributeInfo(entity->attributes(), - (attributeType == resultAttribute - ? resultAttribute - : dtdAttribute)); -} - -void RastEventHandler::subdocEntity(SubdocEntityEvent *event) -{ - const SubdocEntity *entity = event->entity(); - if (!entity) - return; - flushLine(dataLine); - os() << "[&" << entity->name() << nl; - Ptr origin(event->entityOrigin()->copy()); - subdocEntityInfo(entity, origin, 1); - os() << ']' << nl; - delete event; -} - -void RastEventHandler::subdocEntityInfo(const SubdocEntity *entity, - const Ptr &entityOrigin, - Boolean referenced) -{ - os() << "#SUBDOC" << nl; - externalIdInfo(entity->externalId()); - if (parseNextSubdoc()) { - // FIXME subdocuments in entity attributes shouldn't count against - // SUBDOC quantity limit. - os() << "#PARSED-SUBDOCUMENT" << nl; - SgmlParser::Params params; - params.entityType = SgmlParser::Params::subdoc; - params.subdocInheritActiveLinkTypes = 0; - params.subdocReferenced = referenced; - params.parent = parser_; - params.sysid = entity->externalId().effectiveSystemId(); - params.origin = entityOrigin; - SgmlParser parser(params); - RastSubdocState oldSubdocState; - RastSubdocState::swap(oldSubdocState); - RastSubdocState::init(&parser, this); - parser.parseAll(*this); - oldSubdocState.swap(*this); - } -} - -void RastEventHandler::queueParseSubdoc(Boolean parseSubdoc) -{ - parseSubdocQueue_.push_back(PackedBoolean(parseSubdoc)); -} - -Boolean RastEventHandler::parseNextSubdoc() -{ - if (parseSubdocQueue_.size() == 0) - return 0; - Boolean result = parseSubdocQueue_[0]; - if (parseSubdocQueue_.size() > 1) { - for (size_t i = 1; i < parseSubdocQueue_.size(); i++) - parseSubdocQueue_[i - 1] = parseSubdocQueue_[i]; - } - parseSubdocQueue_.resize(parseSubdocQueue_.size() - 1); - return result; -} - - -void RastEventHandler::externalIdInfo(const ExternalId &id) -{ - const StringC *systemId = id.systemIdString(); - const StringC *publicId = id.publicIdString(); - if (publicId) { - os() << "#PUBLIC" << nl; - if (publicId->size() == 0) - os() << "#EMPTY" << nl; - else { - lines(markupLine, publicId->data(), publicId->size()); - flushLine(markupLine); - } - } - if (systemId || !publicId) { - os() << "#SYSTEM" << nl; - if (!systemId) - os() << "#NONE" << nl; - else if (systemId->size() == 0) - os() << "#EMPTY" << nl; - else { - lines(markupLine, systemId->data(), systemId->size()); - flushLine(markupLine); - } - } -} - -void RastEventHandler::lines(LineType type, const Char *p, size_t length) -{ - // This needs to be fast. - while (length != 0) { - if (printable(*p)) { - size_t lim; - switch (lineLength_) { - case maxLineLength: - os() << char(type) << nl; - lineLength_ = 0; - // fall through - case 0: - os() << char(type); - lim = maxLineLength; - break; - default: - lim = maxLineLength - lineLength_; - break; - } - if (lim > length) - lim = length; - size_t n = lim; - for (;;) { - os().put(*p); - p++; - if (--n == 0) - break; - if (!printable(*p)) { - lim -= n; - break; - } - } - length -= lim; - lineLength_ += lim; - } - else { - // *p is an unprintable character print it - flushLine(type); - switch (*p) { - case RS: - os() << "#RS" << nl; - break; - case RE: - os() << "#RE" << nl; - break; - case TAB: - os() << "#TAB" << nl; - break; - default: - os() << '#' << (unsigned long)*p << nl; - break; - } - p++; - length--; - } - } -} - -int RastEventHandler::lexCmp(const StringC &s1, const StringC &s2) -{ - const Char *p1 = s1.data(); - size_t n1 = s1.size(); - const Char *p2 = s2.data(); - size_t n2 = s2.size(); - for (;;) { - if (n1 == 0) - return n2 == 0 ? 0 : -1; - if (n2 == 0) - return 1; - if (*p1 != *p2) { - // printable characters precede non-printable characters; - // printable characters are in ASCII order - // non-printable characters are in document character set order - int a1 = printable(*p1); - int a2 = printable(*p2); - if (a1 == 0) { - if (a2 == 0) - return *p1 < *p2 ? -1 : 1; - else - return 1; - } - else if (a2 == 0) - return -1; - else - return a1 - a2; - } - p1++; - p2++; - n1--; - n2--; - } -} - -void RastEventHandler::attributeInfo(const AttributeList &attributes, - AttributeType attributeType) -{ - size_t length = attributes.size(); - if (length == 0) - return; - size_t defIndex = attributes.defIndex(); - if (defIndex >= attributeSortOrder_[attributeType].size()) - attributeSortOrder_[attributeType].resize(defIndex + 1); - Vector &sortOrder = attributeSortOrder_[attributeType][defIndex]; - if (sortOrder.size() == 0 - || attributeType == simpleAttribute) { - sortOrder.resize(length); - size_t i; - for (i = 0; i < length; i++) - sortOrder[i] = i; - // insertion sort - for (i = 1; i < length; i++) { - size_t tem = sortOrder[i]; - size_t j; - for (j = i; j > 0; j--) { - if (lexCmp(attributes.name(sortOrder[j - 1]), - attributes.name(tem)) <= 0) - break; - sortOrder[j] = sortOrder[j - 1]; - } - sortOrder[j] = tem; - } - } - for (size_t j = 0; j < length; j++) { - // Don't use sortOrder because attributeSortOrder_ may be grown - // because of data attributes. - size_t i = attributeSortOrder_[attributeType][defIndex][j]; - os() << attributes.name(i) << '=' << nl; - const Text *text; - const StringC *string; - const AttributeValue *value = attributes.value(i); - if (value) { - switch (value->info(text, string)) { - case AttributeValue::implied: - os() << "#IMPLIED" << nl; - break; - case AttributeValue::tokenized: - lines(markupLine, string->data(), string->size()); - flushLine(markupLine); - break; - case AttributeValue::cdata: - { - TextIter iter(*text); - TextItem::Type type; - const Char *p; - size_t length; - const Location *loc; - while (iter.next(type, p, length, loc)) - switch (type) { - case TextItem::data: - case TextItem::cdata: - lines(markupLine, p, length); - break; - case TextItem::sdata: - flushLine(markupLine); - os() << "#SDATA-TEXT" << nl; - lines(markupLine, p, length); - flushLine(markupLine); - os() << "#END-SDATA" << nl; - break; - default: - break; - } - flushLine(markupLine); - } - break; - } - } - const AttributeSemantics *semantics = attributes.semantics(i); - if (semantics) { - ConstPtr notation - = semantics->notation(); - if (!notation.isNull()) - externalIdInfo(notation->externalId()); - size_t nEntities = semantics->nEntities(); - for (size_t i = 0; i < nEntities; i++) { - ConstPtr entity - = semantics->entity(i); - if (!entity.isNull()) { - const ExternalDataEntity *externalDataEntity - = entity->asExternalDataEntity(); - if (externalDataEntity) - externalEntityInfo(externalDataEntity, - (attributeType == resultAttribute - ? resultAttribute - : dtdAttribute)); - else { - const SubdocEntity *subdocEntity = entity->asSubdocEntity(); - if (subdocEntity) { - Ptr entityOrigin - = new EntityOrigin(entity, - ((TokenizedAttributeValue *)value) - ->tokenLocation(i)); - subdocEntityInfo(subdocEntity, entityOrigin, 0); - } - else { - const InternalEntity *internalEntity = entity->asInternalEntity(); - if (internalEntity) - internalEntityInfo(internalEntity); - } - } - } - os() << "#END-ENTITY" << nl; - } - } - } -} - -void RastEventHandler::internalEntityInfo(const InternalEntity *entity) -{ - if (!entity) - return; - os() << '#' - << char(entity->dataType() == Entity::cdata ? 'C' : 'S') - << "DATA-INTERNAL" << nl; - const StringC &str = entity->string(); - lines(markupLine, str.data(), str.size()); - flushLine(markupLine); -} - -void RastEventHandler::endProlog(EndPrologEvent *event) -{ - if (!event->lpdPointer().isNull()) { - linkProcess_.init(event->lpdPointer()); - haveLinkProcess_ = 1; - } - if (event->simpleLinkNames().size() > 0) - endPrologEvent_ = event; - else - delete event; -} - -void RastEventHandler::uselink(UselinkEvent *event) -{ - linkProcess_.uselink(event->linkSet(), - event->restore(), - event->lpd().pointer()); - if (haveLinkProcess_ && linkProcess_.nImpliedLinkRules() > 0) { - flushLine(dataLine); - os() << "#LINK-SET-INFO" << nl; - impliedSourceLinkRules(); - os() << "#END-LINK-SET-INFO" << nl; - } - delete event; -} - -void RastEventHandler::initMessage(Message &msg) -{ - mgr_->initMessage(msg); -} - -void RastEventHandler::dispatchMessage(Message &msg) -{ - dispatchMessage((const Message &) msg); -} - -void RastEventHandler::dispatchMessage(const Message &msg) -{ - if (msg.isError()) - piErrorCount_++; - if (!cancelled()) { - noteMessage(msg); - mgr_->dispatchMessage(msg); - } -} - -RastLinkProcess::RastLinkProcess() -: rast_(0) -{ -} - -void RastLinkProcess::setHandler(RastEventHandler *rast) -{ - rast_ = rast; -} - -// Always return 1. 0 means not ready. - -Boolean RastLinkProcess::selectLinkRule(const Vector &linkAttributes, - const Location &location, - size_t &selected) -{ - if (!rast_->linkRuleQueue_.empty()) { - LinkRulePi *p = rast_->linkRuleQueue_.get(); - if (!selectLinkRulePi(p->pi, p->loc, linkAttributes, selected)) - selected = 0; - } - else { - if (linkAttributes.size() > 0) { - rast_->setNextLocation(location); - rast_->Messenger::message(RastEventHandlerMessages::multipleLinkRules); - } - selected = 0; - } - return 1; -} - -// Return zero for failure (RAST-PI-ERROR). - -Boolean RastLinkProcess::selectLinkRulePi(const StringC &value, - const Location &loc, - const Vector &linkAttributes, - size_t &selected) -{ - Boolean haveSelection = 0; - size_t i; - for (i = 0; i < linkAttributes.size(); i++) { - const AttributeList &a = *linkAttributes[i]; - Boolean matchValue = 0; - for (size_t j = 0; j < a.size(); j++) { - const Text *textp; - const StringC *strp; - switch (a.value(j)->info(textp, strp)) { - case AttributeValue::cdata: - // What if it contains SDATA entities? - if (textp->string() == value) - matchValue = 1; - break; - case AttributeValue::tokenized: - if (*strp == value) - matchValue = 1; - break; - default: - break; - } - if (matchValue) - break; - } - if (matchValue) { - if (haveSelection) { - rast_->setNextLocation(loc); - rast_->Messenger::message(RastEventHandlerMessages::multipleLinkRuleMatch); - return 0; - } - haveSelection = 1; - selected = i; - } - } - if (!haveSelection) { - rast_->setNextLocation(loc); - rast_->Messenger::message(RastEventHandlerMessages::noLinkRuleMatch); - return 0; - } - return 1; -} - -void RastLinkProcess::swap(RastLinkProcess &to) -{ - LinkProcess::swap(to); - RastEventHandler *tem = to.rast_; - to.rast_ = rast_; - rast_ = tem; -} - -#ifdef SP_NAMESPACE -} -#endif diff --git a/cde/programs/nsgmls/RastEventHandler.h b/cde/programs/nsgmls/RastEventHandler.h deleted file mode 100644 index 9c2be52ed..000000000 --- a/cde/programs/nsgmls/RastEventHandler.h +++ /dev/null @@ -1,215 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: RastEventHandler.h /main/1 1996/07/29 17:02:31 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#ifndef RastEventHandler_INCLUDED -#define RastEventHandler_INCLUDED 1 -#ifdef __GNUG__ -#pragma interface -#endif - -#include "Event.h" -#include "Vector.h" -#include "Vector.h" -#include "Boolean.h" -#include "Vector.h" -#include "StringC.h" -#include "types.h" -#include "OutputCharStream.h" -#include "LinkProcess.h" -#include "Message.h" -#include "Link.h" -#include "IQueue.h" -#include "ErrorCountEventHandler.h" - -#include -#include - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -class AttributeList; -class ExternalDataEntity; -class SubdocEntity; -class ExternalId; -class InternalEntity; -class SgmlParser; - -class RastPrintable { -public: - RastPrintable(); - int operator()(Char c) const; -private: - char v_[UCHAR_MAX + 1]; -}; - -class RastEventHandler; - -class RastLinkProcess : public LinkProcess { -public: - RastLinkProcess(); - void setHandler(RastEventHandler *); - Boolean selectLinkRule(const Vector &linkAttributes, - const Location &location, - size_t &selected); - void swap(RastLinkProcess &); -private: - Boolean selectLinkRulePi(const StringC &str, - const Location &loc, - const Vector &linkAttributes, - size_t &selected); - - RastLinkProcess(const RastLinkProcess &); // undefined - void operator=(RastLinkProcess &); // undefined - RastEventHandler *rast_; -}; - -struct LinkRulePi : public Link { - StringC pi; - Location loc; -}; - -class RastSubdocState { -public: - RastSubdocState(); - RastSubdocState(SgmlParser *, RastEventHandler *); - void init(SgmlParser *, RastEventHandler *); - void swap(RastSubdocState &); -protected: - SgmlParser *parser_; - Boolean hadActiveLpdOrDtd_; - Location activeLpdOrDtdLocation_; - Vector activeLinkTypes_; - Boolean hadDocumentElement_; - RastLinkProcess linkProcess_; - Boolean haveLinkProcess_; - Owner endPrologEvent_; - Vector parseSubdocQueue_; - IQueue linkRuleQueue_; - enum AttributeType { - dtdAttribute, - linkAttribute, - resultAttribute, - simpleAttribute - }; - enum { nAttributeType = simpleAttribute + 1 }; - Vector > attributeSortOrder_[nAttributeType]; -private: - RastSubdocState(const RastSubdocState &); // undefined - void operator=(const RastSubdocState &); // undefined - friend class RastLinkProcess; -}; - -class RastEventHandler : public ErrorCountEventHandler, - private RastSubdocState, - private Messenger { -public: - RastEventHandler(SgmlParser *, Messenger *); - void data(DataEvent *); - void startElement(StartElementEvent *); - void endElement(EndElementEvent *); - void pi(PiEvent *); - void sdataEntity(SdataEntityEvent *); - void externalDataEntity(ExternalDataEntityEvent *); - void subdocEntity(SubdocEntityEvent *); - void sgmlDecl(SgmlDeclEvent *); - void endProlog(EndPrologEvent *); - void uselink(UselinkEvent *); - virtual void truncateOutput(); - void end(); - void setOutputStream(OutputCharStream *os); - // static const char *messageText(int); - // static const char messageSource[]; -protected: - void initMessage(Message &); - void dispatchMessage(const Message &); - void dispatchMessage(Message &); -private: - RastEventHandler(const RastEventHandler &); // undefined - void operator=(const RastEventHandler &); // undefined - - enum LineType { dataLine = '|', markupLine = '!' }; - void lines(LineType, const Char *p, size_t length); - enum { maxLineLength = 60 }; - enum { RS = '\n', RE = '\r', TAB = '\t' }; -#if 0 - static const RastPrintable printable; -#else - static RastPrintable printable; -#endif - int lineLength_; - OutputCharStream *os_; - StringC rastParseSubdocYesString_; - StringC rastParseSubdocNoString_; - StringC rastActiveLpdString_; - StringC rastLinkRuleString_; - unsigned piErrorCount_; - Messenger *mgr_; - - int lexCmp(const StringC &s1, const StringC &s2); - void flushLine(LineType); - void attributeInfo(const AttributeList &, AttributeType); - void externalEntityInfo(const ExternalDataEntity *, AttributeType); - void subdocEntityInfo(const SubdocEntity *, - const Ptr &entityOrigin, - Boolean referenced); - void externalIdInfo(const ExternalId &); - void internalEntityInfo(const InternalEntity *); - void queueParseSubdoc(Boolean); - Boolean parseNextSubdoc(); - Boolean interpretRastPi(const Char *data, size_t dataLength, - const Location &); - void activeLinks(); - void simpleLinkInfo(); - void impliedSourceLinkRules(); - - OutputCharStream &os(); - friend class RastLinkProcess; -}; - -inline -int RastPrintable::operator()(Char c) const -{ - return c <= UCHAR_MAX ? v_[c] : 0; -} - -inline -void RastEventHandler::setOutputStream(OutputCharStream *os) -{ - os_ = os; -} - -inline -OutputCharStream &RastEventHandler::os() -{ - return *os_; -} - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* not RastEventHandler_INCLUDED */ diff --git a/cde/programs/nsgmls/RastEventHandlerMessages.h b/cde/programs/nsgmls/RastEventHandlerMessages.h deleted file mode 100644 index 31c3e47bd..000000000 --- a/cde/programs/nsgmls/RastEventHandlerMessages.h +++ /dev/null @@ -1,119 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: RastEventHandlerMessages.h /main/1 1996/07/29 17:02:35 cde-hp $ */ -// This file was automatically generated from RastEventHandlerMessages.msg by msggen.pl. -#include "Message.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -struct RastEventHandlerMessages { - // 100 - static const MessageType0 invalidRastPiError; - // 101 - static const MessageType1 invalidActiveLinkType; - // 102 - static const MessageType1 duplicateActiveLinkType; - // 103 - static const MessageType0 multipleLinkRuleMatch; - // 104 - static const MessageType0 noLinkRuleMatch; - // 105 - static const MessageType0 multipleLinkRules; -}; -const MessageType0 RastEventHandlerMessages::invalidRastPiError( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -100 -#ifndef SP_NO_MESSAGE_TEXT -,"invalid RAST processing instruction" -#endif -); -const MessageType1 RastEventHandlerMessages::invalidActiveLinkType( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -101 -#ifndef SP_NO_MESSAGE_TEXT -,"invalid link type %1 in rast-active-lpd processing instruction" -#endif -); -const MessageType1 RastEventHandlerMessages::duplicateActiveLinkType( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -102 -#ifndef SP_NO_MESSAGE_TEXT -,"duplicate link type %1 in rast-active-lpd processing instruction" -#endif -); -const MessageType0 RastEventHandlerMessages::multipleLinkRuleMatch( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -103 -#ifndef SP_NO_MESSAGE_TEXT -,"rast-link-rule: processing instruction matches more than one link rule" -#endif -); -const MessageType0 RastEventHandlerMessages::noLinkRuleMatch( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -104 -#ifndef SP_NO_MESSAGE_TEXT -,"rast-link-rule: processing instruction matches does not match any link rules" -#endif -); -const MessageType0 RastEventHandlerMessages::multipleLinkRules( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -105 -#ifndef SP_NO_MESSAGE_TEXT -,"multiple applicable link rules without disambiguating rast-link-rule: processing instruction" -#endif -); -#ifdef SP_NAMESPACE -} -#endif diff --git a/cde/programs/nsgmls/Recognizer.C b/cde/programs/nsgmls/Recognizer.C deleted file mode 100644 index 5688d8b9c..000000000 --- a/cde/programs/nsgmls/Recognizer.C +++ /dev/null @@ -1,98 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: Recognizer.C /main/1 1996/07/29 17:02:40 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#ifdef __GNUG__ -#pragma implementation -#endif -#include "splib.h" -#include "Resource.h" -#include "Trie.h" -#include "Owner.h" -#include "XcharMap.h" -#include "Recognizer.h" -#include "InputSource.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -Recognizer::Recognizer(Trie *trie, const XcharMap &map) -: trie_(trie), map_(map), multicode_(0) -{ -} - -Recognizer::Recognizer(Trie *trie, const XcharMap &map, - Vector &suppressTokens) -: trie_(trie), map_(map), multicode_(1) -{ - suppressTokens.swap(suppressTokens_); -} - -Token Recognizer::recognize(InputSource *in, Messenger &mgr) const -{ - if (multicode_) { - in->startToken(); - if (in->scanSuppress()) - return suppressTokens_[map_[in->tokenChar(mgr)]]; - } - else - in->startTokenNoMulticode(); - const Trie *pos = trie_.pointer(); - do { - pos = pos->next(map_[in->tokenChar(mgr)]); - } while (pos->hasNext()); - if (!pos->blank()) { - in->endToken(pos->tokenLength()); - return pos->token(); - } - const BlankTrie *b = pos->blank(); - const Trie *newPos = b; - size_t maxBlanks = b->maxBlanksToScan(); - size_t nBlanks; - for (nBlanks = 0; nBlanks < maxBlanks; nBlanks++) { - EquivCode code = map_[in->tokenChar(mgr)]; - if (!b->codeIsBlank(code)) { - if (newPos->hasNext()) - newPos = newPos->next(code); - break; - } - } - while (newPos->hasNext()) - newPos = newPos->next(map_[in->tokenChar(mgr)]); - if (newPos->token() != 0) { - in->endToken(newPos->tokenLength() + b->additionalLength() + nBlanks); - return newPos->token(); - } - else { - in->endToken(pos->tokenLength() + (pos->includeBlanks() ? nBlanks : 0)); - return pos->token(); - } -} - - -#ifdef SP_NAMESPACE -} -#endif diff --git a/cde/programs/nsgmls/Recognizer.h b/cde/programs/nsgmls/Recognizer.h deleted file mode 100644 index 53201f733..000000000 --- a/cde/programs/nsgmls/Recognizer.h +++ /dev/null @@ -1,65 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: Recognizer.h /main/1 1996/07/29 17:02:44 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#ifndef Recognizer_INCLUDED -#define Recognizer_INCLUDED 1 -#ifdef __GNUG__ -#pragma interface -#endif - -#include "Resource.h" -#include "Owner.h" -#include "XcharMap.h" -#include "types.h" -#include "Vector.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -class Messenger; -class InputSource; -class Trie; - -class Recognizer : public Resource { -public: - Recognizer(Trie *, const XcharMap &); - Recognizer(Trie *, const XcharMap &, Vector &); - Token recognize(InputSource *, Messenger &) const; -private: - Recognizer(const Recognizer &); // undefined - void operator=(const Recognizer &); // undefined - Boolean multicode_; - Owner trie_; - XcharMap map_; - Vector suppressTokens_; -}; - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* not Recognizer_INCLUDED */ diff --git a/cde/programs/nsgmls/RegisteredCodingSystem.h b/cde/programs/nsgmls/RegisteredCodingSystem.h deleted file mode 100644 index 0d6545cd6..000000000 --- a/cde/programs/nsgmls/RegisteredCodingSystem.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: RegisteredCodingSystem.h /main/1 1996/07/29 17:02:50 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#ifndef RegisteredCodingSystem_INCLUDED -#define RegisteredCodingSystem_INCLUDED 1 - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -class InputCodingSystem; - -struct RegisteredCodingSystem { - RegisteredCodingSystem() { } - ~RegisteredCodingSystem() { } - const char *name; - const InputCodingSystem *ics; -}; - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* not RegisteredCodingSystem_INCLUDED */ diff --git a/cde/programs/nsgmls/Resource.h b/cde/programs/nsgmls/Resource.h deleted file mode 100644 index ee37ec54d..000000000 --- a/cde/programs/nsgmls/Resource.h +++ /dev/null @@ -1,83 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: Resource.h /main/1 1996/07/29 17:02:54 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#ifndef Resource_INCLUDED -#define Resource_INCLUDED 1 - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -#ifndef SP_API -#define SP_API /* as nothing */ -#endif - -class SP_API Resource { -public: - Resource(); - Resource(const Resource &); - int unref(); // return 1 if it should be deleted - void ref(); - int count() const; -private: - int count_; -}; - -inline -Resource::Resource() -: count_(0) -{ -} - -inline -Resource::Resource(const Resource &) -: count_(0) -{ -} - -inline -int Resource::count() const -{ - return count_; -} - -inline -int Resource::unref() -{ - return --count_ <= 0; -} - -inline -void Resource::ref() -{ - ++count_; -} - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* not Resource_INCLUDED */ diff --git a/cde/programs/nsgmls/RewindStorageObject.C b/cde/programs/nsgmls/RewindStorageObject.C deleted file mode 100644 index f3fdd1e16..000000000 --- a/cde/programs/nsgmls/RewindStorageObject.C +++ /dev/null @@ -1,102 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: RewindStorageObject.C /main/1 1996/07/29 17:02:59 cde-hp $ */ -// Copyright (c) 1994, 1995 James Clark -// See the file COPYING for copying permission. - -#ifdef __GNUG__ -#pragma implementation -#endif - -#include "splib.h" -#include "RewindStorageObject.h" -#include "macros.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -RewindStorageObject::RewindStorageObject(Boolean mayRewind, Boolean canSeek) -: mayRewind_(mayRewind), canSeek_(canSeek), - savingBytes_(mayRewind && canSeek), readingSaved_(0), - nBytesRead_(0) -{ -} - -Boolean RewindStorageObject::rewind(Messenger &mgr) -{ - ASSERT(mayRewind_); - if (canSeek_) - return seekToStart(mgr); - else { - readingSaved_ = 1; - nBytesRead_ = 0; - return 1; - } -} - -void RewindStorageObject::unread(const char *s, size_t n) -{ - savedBytes_.append(s, n); - if (!readingSaved_) { - readingSaved_ = 1; - nBytesRead_ = 0; - } -} - -void RewindStorageObject::willNotRewind() -{ - mayRewind_ = 0; - savingBytes_ = 0; - if (!readingSaved_) { - // Ensure that memory is released now. - String tem; - tem.swap(savedBytes_); - } -} - -Boolean RewindStorageObject::readSaved(char *buf, size_t bufSize, - size_t &nread) -{ - if (!readingSaved_) - return 0; - if (nBytesRead_ >= savedBytes_.size()) { - if (!mayRewind_) { - // Ensure that memory is released now. - String tem; - tem.swap(savedBytes_); - } - readingSaved_ = 0; - return 0; - } - nread = savedBytes_.size() - nBytesRead_; - if (nread > bufSize) - nread = bufSize; - memcpy(buf, savedBytes_.data() + nBytesRead_, nread); - nBytesRead_ += nread; - return 1; -} - -#ifdef SP_NAMESPACE -} -#endif diff --git a/cde/programs/nsgmls/RewindStorageObject.h b/cde/programs/nsgmls/RewindStorageObject.h deleted file mode 100644 index 645b9510d..000000000 --- a/cde/programs/nsgmls/RewindStorageObject.h +++ /dev/null @@ -1,68 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: RewindStorageObject.h /main/1 1996/07/29 17:03:03 cde-hp $ */ -#ifndef RewindStorageObject_INCLUDED -#define RewindStorageObject_INCLUDED 1 - -#include "StorageManager.h" -#include "Boolean.h" -#include "StringOf.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -class Messenger; - -class SP_API RewindStorageObject : public StorageObject { -public: - RewindStorageObject(Boolean mayRewind, Boolean canSeek); -protected: - PackedBoolean mayRewind_; - - void saveBytes(const char *, size_t); - Boolean readSaved(char *, size_t, size_t &); - Boolean rewind(Messenger &); - void willNotRewind(); - void unread(const char *s, size_t n); - virtual Boolean seekToStart(Messenger &) = 0; -private: - PackedBoolean savingBytes_; - PackedBoolean readingSaved_; - PackedBoolean canSeek_; - String savedBytes_; - size_t nBytesRead_; -}; - -inline -void RewindStorageObject::saveBytes(const char *s, size_t n) -{ - if (savingBytes_) - savedBytes_.append(s, n); -} - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* not RewindStorageObject_INCLUDED */ diff --git a/cde/programs/nsgmls/SGMLApplication.C b/cde/programs/nsgmls/SGMLApplication.C deleted file mode 100644 index bf5ca5623..000000000 --- a/cde/programs/nsgmls/SGMLApplication.C +++ /dev/null @@ -1,178 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: SGMLApplication.C /main/1 1996/07/29 17:03:08 cde-hp $ */ -// Copyright (c) 1995 James Clark -// See the file COPYING for copying permission. - -#ifdef __GNUG__ -#pragma implementation -#endif - -#include "splib.h" -#include "Boolean.h" -#include "SGMLApplication.h" - -SGMLApplication::~SGMLApplication() -{ -} - -void SGMLApplication::appinfo(const AppinfoEvent &) -{ -} - -void SGMLApplication::startDtd(const StartDtdEvent &) -{ -} - -void SGMLApplication::endDtd(const EndDtdEvent &) -{ -} - -void SGMLApplication::endProlog(const EndPrologEvent &) -{ -} - -void SGMLApplication::startElement(const StartElementEvent &) -{ -} - -void SGMLApplication::endElement(const EndElementEvent &) -{ -} - -void SGMLApplication::data(const DataEvent &) -{ -} - -void SGMLApplication::sdata(const SdataEvent &) -{ -} - -void SGMLApplication::pi(const PiEvent &) -{ -} - -void SGMLApplication::externalDataEntityRef(const ExternalDataEntityRefEvent &) -{ -} - -void SGMLApplication::subdocEntityRef(const SubdocEntityRefEvent &) -{ -} - -void SGMLApplication::commentDecl(const CommentDeclEvent &) -{ -} - -void SGMLApplication::markedSectionStart(const MarkedSectionStartEvent &) -{ -} - -void SGMLApplication::markedSectionEnd(const MarkedSectionEndEvent &) -{ -} - -void SGMLApplication::ignoredChars(const IgnoredCharsEvent &) -{ -} - -void SGMLApplication::generalEntity(const GeneralEntityEvent &) -{ -} - -void SGMLApplication::error(const ErrorEvent &) -{ -} - -void SGMLApplication::openEntityChange(const OpenEntityPtr &) -{ -} - - -SGMLApplication::OpenEntity::OpenEntity() -: count_(0) -{ -} - -SGMLApplication::OpenEntity::~OpenEntity() -{ -} - -SGMLApplication::OpenEntityPtr::OpenEntityPtr() -: ptr_(0) -{ -} - -SGMLApplication::OpenEntityPtr::OpenEntityPtr(const OpenEntityPtr &ptr) -: ptr_(ptr.ptr_) -{ - if (ptr_) - ptr_->count_ += 1; -} - -SGMLApplication::OpenEntityPtr::~OpenEntityPtr() -{ - if (ptr_) { - ptr_->count_ -= 1; - if (ptr_->count_ == 0) - delete ptr_; - } -} - -void SGMLApplication::OpenEntityPtr::operator=(OpenEntity *p) -{ - if (p) - p->count_ += 1; - if (ptr_) { - ptr_->count_ -= 1; - if (ptr_->count_ == 0) - delete ptr_; - } - ptr_ = p; -} - -SGMLApplication::Location::Location() -{ - init(); -} - -SGMLApplication::Location::Location(const OpenEntityPtr &ptr, Position pos) -{ - if (ptr) - *this = ptr->location(pos); - else - init(); -} - -void SGMLApplication::Location::init() -{ - entityName.ptr = 0; - entityName.len = 0; - filename.ptr = 0; - filename.len = 0; - lineNumber = (unsigned long)-1; - columnNumber = (unsigned long)-1; - byteOffset = (unsigned long)-1; - entityOffset = (unsigned long)-1; - other = 0; -} diff --git a/cde/programs/nsgmls/SGMLApplication.h b/cde/programs/nsgmls/SGMLApplication.h deleted file mode 100644 index b3bb4a554..000000000 --- a/cde/programs/nsgmls/SGMLApplication.h +++ /dev/null @@ -1,322 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: SGMLApplication.h /main/1 1996/07/29 17:03:14 cde-hp $ */ -// Copyright (c) 1995 James Clark -// See the file COPYING for copying permission. - -#ifndef SGMLApplication_INCLUDED -#define SGMLApplication_INCLUDED 1 - -#ifdef __GNUG__ -#pragma interface -#endif - -#include - -#ifndef SP_API -#define SP_API /* as nothing */ -#endif - -class SP_API SGMLApplication { -public: -#ifdef SP_MULTI_BYTE - typedef unsigned short Char; -#else - typedef unsigned char Char; -#endif - // A Position represents a position in an OpenEntity. - // The meaning of a Position depends on the - // particular implementation of OpenEntity. - // It might be a line number or it might be - // an offset in the entity. The only thing - // that can be done with Position is to use - // it with an OpenEntityPtr to get a Location. - typedef unsigned long Position; - struct CharString { - const Char *ptr; - size_t len; - }; - struct ExternalId { - bool haveSystemId; - bool havePublicId; - bool haveGeneratedSystemId; - CharString systemId; // valid only if haveSystemId is true - CharString publicId; // valid only if havePublicId is true - CharString generatedSystemId; // valid if haveGeneratedSystemId is true - }; - struct Notation { - CharString name; - ExternalId externalId; - }; - struct Attribute; - struct Entity { - CharString name; - enum DataType { sgml, cdata, sdata, ndata, subdoc, pi }; - enum DeclType { general, parameter, doctype, linktype }; - DataType dataType; - DeclType declType; - bool isInternal; - // Following valid if isInternal is true - CharString text; - // Following valid if isInternal is false - ExternalId externalId; - size_t nAttributes; - const Attribute *attributes; - Notation notation; - }; - struct Attribute { - CharString name; - enum Type { - invalid, - implied, - cdata, - tokenized - }; - Type type; - enum Defaulted { - specified, // not defaulted - definition, // defaulted from definition - current // defaulted from current value - }; - Defaulted defaulted; // non-ESIS; valid only if type != implied - struct CdataChunk { - bool isSdata; - CharString data; - CharString entityName; // non-ESIS; optional for SDATA chunks - }; - // Following valid if type == cdata - size_t nCdataChunks; - const CdataChunk *cdataChunks; // valid if type == cdata - // Following valid if type == tokenized - CharString tokens; // separated by spaces - bool isId; // non-ESIS (probably) - bool isGroup; // non-ESIS - size_t nEntities; - const Entity *entities; - // length of notation.name will be 0 if no notation - Notation notation; - }; - struct PiEvent { - Position pos; - CharString data; - CharString entityName; // non-ESIS; optional for PI entities - }; - struct StartElementEvent { - Position pos; - enum ContentType { - empty, // declared EMPTY or with CONREF attribute - cdata, - rcdata, - mixed, - element - }; - CharString gi; - ContentType contentType; // non-ESIS - bool included; // non-ESIS - size_t nAttributes; - const Attribute *attributes; - }; - - struct EndElementEvent { - Position pos; - CharString gi; - }; - struct DataEvent { - Position pos; - CharString data; - }; - struct SdataEvent { - Position pos; - CharString text; - CharString entityName; // non-ESIS; optional - }; - struct ExternalDataEntityRefEvent { - Position pos; - Entity entity; - }; - struct SubdocEntityRefEvent { - Position pos; - Entity entity; - }; - struct ErrorEvent { - Position pos; - enum Type { - info, // not an error - warning, // not an error - quantity, - idref, - capacity, - otherError - }; - Type type; - CharString message; - }; - struct AppinfoEvent { - Position pos; - bool none; - CharString string; - }; - struct StartDtdEvent { - Position pos; - CharString name; - bool haveExternalId; - ExternalId externalId; - }; - struct EndDtdEvent { - Position pos; - CharString name; - }; - struct EndPrologEvent { - Position pos; - }; - // non-ESIS - struct GeneralEntityEvent { - // no position - Entity entity; - }; - // non-ESIS - struct CommentDeclEvent { - Position pos; - size_t nComments; - const CharString *comments; - const CharString *seps; - }; - // non-ESIS - struct MarkedSectionStartEvent { - Position pos; - enum Status { - include, - rcdata, - cdata, - ignore - }; - Status status; - struct Param { - enum Type { - temp, - include, - rcdata, - cdata, - ignore, - entityRef - }; - Type type; - CharString entityName; - }; - size_t nParams; - const Param *params; - }; - // non-ESIS - struct MarkedSectionEndEvent { - Position pos; - enum Status { - include, - rcdata, - cdata, - ignore - }; - Status status; - }; - struct IgnoredCharsEvent { - Position pos; - CharString data; - }; - class OpenEntityPtr; - struct SP_API Location { - Location(); - Location(const OpenEntityPtr &, Position); - void init(); - - unsigned long lineNumber; - unsigned long columnNumber; - unsigned long byteOffset; - unsigned long entityOffset; - CharString entityName; - CharString filename; - const void *other; - }; - class OpenEntity; - class SP_API OpenEntityPtr { - public: - OpenEntityPtr(); - OpenEntityPtr(const OpenEntityPtr &); - void operator=(const OpenEntityPtr &); - void operator=(OpenEntity *); - ~OpenEntityPtr(); - const OpenEntity *operator->() const; - operator int() const; - private: - OpenEntity *ptr_; - }; - class SP_API OpenEntity { - public: - OpenEntity(); - virtual ~OpenEntity(); - virtual Location location(Position) const = 0; - private: - OpenEntity(const OpenEntity &); // undefined - void operator=(const OpenEntity &); // undefined - unsigned count_; - friend class OpenEntityPtr; - }; - virtual ~SGMLApplication(); - virtual void appinfo(const AppinfoEvent &); - virtual void startDtd(const StartDtdEvent &); - virtual void endDtd(const EndDtdEvent &); - virtual void endProlog(const EndPrologEvent &); - virtual void startElement(const StartElementEvent &); - virtual void endElement(const EndElementEvent &); - virtual void data(const DataEvent &); - virtual void sdata(const SdataEvent &); - virtual void pi(const PiEvent &); - virtual void externalDataEntityRef(const ExternalDataEntityRefEvent &); - virtual void subdocEntityRef(const SubdocEntityRefEvent &); - virtual void commentDecl(const CommentDeclEvent &); - virtual void markedSectionStart(const MarkedSectionStartEvent &); - virtual void markedSectionEnd(const MarkedSectionEndEvent &); - virtual void ignoredChars(const IgnoredCharsEvent &); - virtual void generalEntity(const GeneralEntityEvent &); - virtual void error(const ErrorEvent &); - virtual void openEntityChange(const OpenEntityPtr &); -}; - -inline -const SGMLApplication::OpenEntity * -SGMLApplication::OpenEntityPtr::operator->() const -{ - return ptr_; -} - -inline -void SGMLApplication::OpenEntityPtr::operator=(const OpenEntityPtr &ptr) -{ - *this = ptr.ptr_; -} - -inline -SGMLApplication::OpenEntityPtr::operator int() const -{ - return ptr_ != 0; -} - -#endif /* not SGMLApplication_INCLUDED */ diff --git a/cde/programs/nsgmls/SJISCodingSystem.C b/cde/programs/nsgmls/SJISCodingSystem.C deleted file mode 100644 index 9ec256755..000000000 --- a/cde/programs/nsgmls/SJISCodingSystem.C +++ /dev/null @@ -1,207 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: SJISCodingSystem.C /main/1 1996/07/29 17:03:20 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#include "splib.h" - -#ifdef SP_MULTI_BYTE - -#include "SJISCodingSystem.h" - -#if defined(__linux__) || defined(CSRG_BASED) || defined(sun) -#include -#else -#include -#endif - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -class SJISDecoder : public Decoder { -public: - SJISDecoder(); - size_t decode(Char *, const char *, size_t, const char **); -private: -}; - -class SJISEncoder : public Encoder { -public: - SJISEncoder(); - void output(const Char *, size_t, streambuf *); -}; - -Decoder *SJISCodingSystem::makeDecoder() const -{ - return new SJISDecoder; -} - -Encoder *SJISCodingSystem::makeEncoder() const -{ - return new SJISEncoder; -} - - -SJISDecoder::SJISDecoder() -{ -} - -size_t SJISDecoder::decode(Char *to, const char *s, - size_t slen, const char **rest) -{ - Char *start = to; - while (slen > 0) { - unsigned char c = *(unsigned char *)s; - if (!(c & 0x80)) { - *to++ = c; - s++; - slen--; - } - else if (129 <= c && c <= 159) { - if (slen < 2) - break; - s++; - slen -= 2; - unsigned char c2 = *(unsigned char *)s++; - unsigned short n = ((c - 112) << 9) | c2; - if (64 <= c2 && c2 <= 127) - n -= 31 + (1 << 8); - else if (c2 <= 158) - n -= 32 + (1 << 8); - else if (c2 <= 252) - n -= 126; - else - continue; - n |= 0x8080; - *to++ = n; - } - else if (224 <= c && c <= 239) { - if (slen < 2) - break; - s++; - slen -= 2; - unsigned char c2 = *(unsigned char *)s++; - unsigned short n = ((c - 176) << 9) | c2; - if (64 <= c2 && c2 <= 127) - n -= 31 + (1 << 8); - else if (c2 <= 158) - n -= 32 + (1 << 8); - else if (c2 <= 252) - n -= 126; - else - continue; - n |= 0x8080; - *to++ = n; - } - else if (161 <= c && c <= 223) { - slen--; - s++; - *to++ = c; - } - else { - // 128, 160, 240-255 - slen--; - s++; - } - } - *rest = s; - return to - start; -} - -SJISEncoder::SJISEncoder() -{ -} - -// FIXME handle errors from streambuf::sputc - -void SJISEncoder::output(const Char *s, size_t n, streambuf *sb) -{ - for (; n > 0; s++, n--) { - Char c = *s; - unsigned short mask = (unsigned short)(c & 0x8080); - if (mask == 0) - sb->sputc(char(c & 0xff)); - else if (mask == 0x8080) { - unsigned char c1 = (c >> 8) & 0x7f; - unsigned char c2 = c & 0x7f; - char out1; - if (c1 < 33) - out1 = 0; - else if (c1 < 95) - out1 = ((c1 + 1) >> 1) + 112; - else if (c1 < 127) - out1 = ((c1 + 1) >> 1) + 176; - else - out1 = 0; - if (out1) { - char out2; - if (c1 & 1) { - if (c2 < 33) - out2 = 0; - else if (c2 <= 95) - out2 = c2 + 31; - else if (c2 <= 126) - out2 = c2 + 32; - else - out2 = 0; - } - else { - if (33 <= c2 && c2 <= 126) - out2 = c2 + 126; - else - out2 = 0; - } - if (out2) { - sb->sputc(out1); - sb->sputc(out2); - } - else - handleUnencodable(c, sb); - } - else - handleUnencodable(c, sb); - } - else if (mask == 0x0080) { - if (161 <= c && c <= 223) - sb->sputc(char(c & 0xff)); - else - handleUnencodable(c, sb); - } - else - handleUnencodable(c, sb); - } -} - -#ifdef SP_NAMESPACE -} -#endif - -#else /* not SP_MULTI_BYTE */ - -#ifndef __GNUG__ -static char non_empty_translation_unit; // sigh -#endif - -#endif /* not SP_MULTI_BYTE */ diff --git a/cde/programs/nsgmls/SJISCodingSystem.h b/cde/programs/nsgmls/SJISCodingSystem.h deleted file mode 100644 index d2beabdad..000000000 --- a/cde/programs/nsgmls/SJISCodingSystem.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: SJISCodingSystem.h /main/1 1996/07/29 17:03:26 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#ifndef SJISCodingSystem_INCLUDED -#define SJISCodingSystem_INCLUDED 1 - -#include "CodingSystem.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -class SP_API SJISCodingSystem : public CodingSystem { -public: - Decoder *makeDecoder() const; - Encoder *makeEncoder() const; -}; - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* not SJISCodingSystem_INCLUDED */ diff --git a/cde/programs/nsgmls/SOEntityCatalog.C b/cde/programs/nsgmls/SOEntityCatalog.C deleted file mode 100644 index 2d135f245..000000000 --- a/cde/programs/nsgmls/SOEntityCatalog.C +++ /dev/null @@ -1,1144 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: SOEntityCatalog.C /main/1 1996/07/29 17:03:30 cde-hp $ */ -// Copyright (c) 1994, 1995, 1996 James Clark -// See the file COPYING for copying permission. - -#ifdef __GNUG__ -#pragma implementation -#endif - -#include "splib.h" -#include "CharsetInfo.h" -#include "MessageArg.h" -#include "CatalogMessages.h" -#include "SOEntityCatalog.h" -#include "EntityDecl.h" -#include "EntityCatalog.h" -#include "Message.h" -#include "StringC.h" -#include "types.h" -#include "HashTable.h" -#include "InputSource.h" -#include "Boolean.h" -#include "SubstTable.h" -#include "CatalogEntry.h" -#include "Vector.h" -#include "StorageManager.h" -#include "macros.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -class CatalogParser; -class SOEntityCatalog; - -class SOCatalogManagerImpl : public SOCatalogManager { -public: - SOCatalogManagerImpl(const Vector &sysids, - size_t nSysidsMustExist, - const CharsetInfo &sysidCharset, - const CharsetInfo &catalogCharset); - ConstPtr makeCatalog(StringC &systemId, - const CharsetInfo &charset, - ExtendEntityManager *, - Messenger &) const; - Boolean mapCatalog(ParsedSystemId &systemId, - ExtendEntityManager *em, - Messenger &mgr) const; -private: - void addCatalogsForDocument(CatalogParser &parser, - StringC &sysid, - SOEntityCatalog *, - const CharsetInfo &charset, - Messenger &mgr) const; - size_t nSystemCatalogsMustExist_; - Vector systemCatalogs_; - CharsetInfo sysidCharset_; - CharsetInfo catalogCharset_; -}; - -class SOEntityCatalog : public EntityCatalog { -public: - SOEntityCatalog(Ptr em); - typedef EntityDecl::DeclType DeclType; - Boolean document(const CharsetInfo &, Messenger &, StringC &) const; - Boolean sgmlDecl(const CharsetInfo &, Messenger &, StringC &) const; - Boolean defaultDoctype(const CharsetInfo &, - Messenger &, - StringC &, - StringC &) const; - Boolean lookup(const EntityDecl &entity, - const Syntax &, - const CharsetInfo &, - Messenger &, - StringC &) const; - Boolean lookupPublic(const StringC &, - const CharsetInfo &, - Messenger &, - StringC &) const; - void addPublicId(StringC &publicId, StringC &systemId, const Location &, - Boolean override); - void addDelegate(StringC &prefix, StringC &systemId, const Location &, - Boolean override); - void addSystemId(StringC &systemId, StringC &replSystemId, const Location &); - void addName(StringC &name, DeclType, StringC &systemId, const Location &, - Boolean override); - void setSgmlDecl(StringC &str, const Location &loc); - void setDocument(StringC &str, const Location &loc); - void setBase(const Location &loc); - void endCatalog(); - const Ptr &entityManager() { - return em_; - } -private: - SOEntityCatalog(const SOEntityCatalog &); // undefined - void operator=(const SOEntityCatalog &); // undefined - - Boolean expandCatalogSystemId(const StringC &str, - const Location &loc, - size_t baseNumber, - Boolean isNdata, - const CharsetInfo &charset, - const StringC *lookupPublicId, - Messenger &mgr, - StringC &result) const; - const CatalogEntry * - findBestPublicEntry(const StringC &publicId, Boolean overrideOnly, - const CharsetInfo &charset, Boolean &delegated) const; - - class Table { - public: - Table(); - const CatalogEntry *lookup(const StringC &, Boolean overrideOnly) const; - const CatalogEntry *lookup(const StringC &key, - const SubstTable &substTable, - Boolean overrideOnly) const; - void insert(const StringC &, const CatalogEntry &, Boolean override); - size_t count() const; - private: - Table(const Table &); // undefined - void operator=(const Table &); // undefined - // These are entries that are applicable when an explicit system id - // was specified in the external identifier. - HashTable overrideEntries_; - // This specifies the entries that should substitute for the - // overrideEntries_ when an explicit system identifier was not specified. - HashTable normalEntries_; - }; - - Table publicIds_; - Table delegates_; - HashTable systemIds_; - Table names_[4]; - size_t catalogNumber_; - Boolean haveSgmlDecl_; - StringC sgmlDecl_; - Location sgmlDeclLoc_; - size_t sgmlDeclBaseNumber_; - StringC document_; - Boolean haveDocument_; - Location documentLoc_; - size_t documentBaseNumber_; - StringC defaultDoctype_; - Boolean haveCurrentBase_; - Vector base_; - Ptr em_; -}; - -class CatalogParser : private Messenger { -public: - CatalogParser(const CharsetInfo &); - void parseCatalog(const StringC &sysid, - Boolean mustExist, - const CharsetInfo &sysidCharset, - const CharsetInfo &catalogCharset, - InputSourceOrigin *origin, - SOEntityCatalog *catalog, - Messenger &mgr); -public: - // Since it's a return type, it has to be public to keep some - // (broken) compilers happy. - enum Param { - eofParam, - literalParam, - nameParam, - percentParam - }; -private: - enum { - data, - eof, - nul, - lit, - lita, - minus, - s, - min // other minimum data characters - }; - enum { minimumLiteral = 01 }; - - Messenger &messenger() { return *this; } - void dispatchMessage(Message &); - void dispatchMessage(const Message &); - void initMessage(Message &); - void parsePublic(); - void parseDelegate(); - void parseSystem(); - void parseNameMap(EntityDecl::DeclType declType); - void parseOverride(); - Param parseParam(unsigned flags = 0); - Boolean parseArg(); - void parseLiteral(Char delim, unsigned flags); - void parseName(); - void skipComment(); - void upcase(StringC &); - Boolean inLoop(const Location &loc); - Boolean isMinimumData(Xchar c) { - int cat = categoryTable_[c]; - return (cat == min || (cat == s && c != tab_) - || cat == minus || cat == lita); - } - Xchar get() { return in_->get(messenger()); } - void unget() { in_->ungetToken(); } - Messenger *mgr_; - InputSource *in_; - SOEntityCatalog *catalog_; - StringC param_; - Location paramLoc_; - Char minus_; - Char tab_; - Char rs_; - Char re_; - Char space_; - StringC publicKey_; - StringC systemKey_; - StringC entityKey_; - StringC doctypeKey_; - StringC linktypeKey_; - StringC notationKey_; - StringC overrideKey_; - StringC sgmlDeclKey_; - StringC documentKey_; - StringC catalogKey_; - StringC yesKey_; - StringC noKey_; - StringC baseKey_; - StringC delegateKey_; - XcharMap categoryTable_; - SubstTable substTable_; - Boolean override_; -}; - -ExtendEntityManager::CatalogManager * -SOCatalogManager::make(const Vector &sysids, - size_t nSysidsMustExist, - const CharsetInfo &sysidCharset, - const CharsetInfo &catalogCharset) -{ - return new SOCatalogManagerImpl(sysids, - nSysidsMustExist, - sysidCharset, - catalogCharset); -} - -SOCatalogManagerImpl::SOCatalogManagerImpl(const Vector &systemCatalogs, - size_t nSystemCatalogsMustExist, - const CharsetInfo &sysidCharset, - const CharsetInfo &catalogCharset) -: systemCatalogs_(systemCatalogs), - nSystemCatalogsMustExist_(nSystemCatalogsMustExist), - sysidCharset_(sysidCharset), - catalogCharset_(catalogCharset) -{ -} - -Boolean SOCatalogManagerImpl::mapCatalog(ParsedSystemId &systemId, - ExtendEntityManager *em, - Messenger &mgr) const -{ - Vector maps; - systemId.maps.swap(maps); - while (maps.size() > 0) { - StringC catalogSystemId; - systemId.unparse(sysidCharset_, catalogSystemId); - SOEntityCatalog *catalog = new SOEntityCatalog(em); - ConstPtr deleter(catalog); - CatalogParser parser(catalogCharset_); - parser.parseCatalog(catalogSystemId, 1, sysidCharset_, catalogCharset_, - new InputSourceOrigin, catalog, mgr); - // FIXME do catalog caching here - StringC s; - if (maps.back().type == ParsedSystemIdMap::catalogDocument) { - if (!catalog->document(sysidCharset_, mgr, s)) { - mgr.message(CatalogMessages::noDocumentEntry, - StringMessageArg(catalogSystemId)); - return 0; - } - } - else { - ASSERT(maps.back().type == ParsedSystemIdMap::catalogPublic); - if (!catalog->lookupPublic(maps.back().publicId, sysidCharset_, mgr, - s)) { - mgr.message(CatalogMessages::noPublicEntry, - StringMessageArg(maps.back().publicId), - StringMessageArg(catalogSystemId)); - return 0; - } - } - ParsedSystemId tem; - if (!em->parseSystemId(s, sysidCharset_, 0, 0, mgr, tem)) - return 0; - systemId = tem; - maps.resize(maps.size() - 1); - for (size_t i = 0; i < systemId.maps.size(); i++) - maps.push_back(systemId.maps[i]); - systemId.maps.clear(); - } - return 1; -} - -ConstPtr -SOCatalogManagerImpl::makeCatalog(StringC &systemId, - const CharsetInfo &charset, - ExtendEntityManager *em, - Messenger &mgr) const -{ - SOEntityCatalog *entityCatalog = new SOEntityCatalog(em); - CatalogParser parser(catalogCharset_); - size_t i; - for (i = 0; i < nSystemCatalogsMustExist_; i++) - parser.parseCatalog(systemCatalogs_[i], 1, - sysidCharset_, catalogCharset_, - new InputSourceOrigin, entityCatalog, - mgr); - addCatalogsForDocument(parser, systemId, entityCatalog, charset, mgr); - for (i = nSystemCatalogsMustExist_; i < systemCatalogs_.size(); i++) - parser.parseCatalog(systemCatalogs_[i], 0, - sysidCharset_, catalogCharset_, - new InputSourceOrigin, entityCatalog, - mgr); - - return entityCatalog; -} - - -void SOCatalogManagerImpl::addCatalogsForDocument(CatalogParser &parser, - StringC &sysid, - SOEntityCatalog *impl, - const CharsetInfo &charset, - Messenger &mgr) const -{ - ParsedSystemId v; - if (!impl->entityManager()->parseSystemId(sysid, charset, 0, 0, mgr, v)) - return; - if (v.maps.size() > 0) { - if (v.maps[0].type == ParsedSystemIdMap::catalogDocument) { - v.maps.erase(v.maps.begin(), v.maps.begin() + 1); - StringC tem; - v.unparse(charset, tem); - parser.parseCatalog(tem, 1, charset, catalogCharset_, - new InputSourceOrigin, impl, mgr); - if (!impl->document(charset, mgr, sysid)) { - mgr.message(CatalogMessages::noDocumentEntry, StringMessageArg(tem)); - sysid.resize(0); - } - } - return; - } - Vector catalogs; - size_t i; - for (i = 0; i < v.size(); i++) - if (v[i].storageManager->inheritable()) { - ParsedSystemId catalogId; - catalogId.resize(1); - StorageObjectSpec &spec = catalogId.back(); - spec.storageManager = v[i].storageManager; - spec.codingSystemName = v[i].codingSystemName; - spec.specId = spec.storageManager->idCharset()->execToDesc("catalog"); - spec.storageManager->resolveRelative(v[i].specId, spec.specId, 0); - spec.baseId = v[i].baseId; - spec.records = v[i].records; - StringC tem; - catalogId.unparse(charset, tem); - for (size_t j = 0; j < catalogs.size(); j++) - if (tem == catalogs[j]) { - tem.resize(0); - break; - } - if (tem.size() > 0) { - catalogs.resize(catalogs.size() + 1); - tem.swap(catalogs.back()); - } - } - for (i = 0; i < catalogs.size(); i++) - parser.parseCatalog(catalogs[i], 0, charset, - catalogCharset_, new InputSourceOrigin, impl, - mgr); -} - -SOEntityCatalog::SOEntityCatalog(Ptr em) -: em_(em), catalogNumber_(0), haveSgmlDecl_(0), haveDocument_(0), - haveCurrentBase_(0), sgmlDeclBaseNumber_(0), documentBaseNumber_(0) -{ -} - -void SOEntityCatalog::endCatalog() -{ - catalogNumber_++; - haveCurrentBase_ = 0; -} - -Boolean SOEntityCatalog::expandCatalogSystemId(const StringC &str, - const Location &loc, - size_t baseNumber, - Boolean isNdata, - const CharsetInfo &charset, - const StringC *lookupPublicId, - Messenger &mgr, - StringC &result) const -{ - return em_->expandSystemId(str, - (baseNumber ? base_[baseNumber - 1] : loc), - isNdata, - charset, - lookupPublicId, - mgr, - result); -} - -Boolean SOEntityCatalog::lookup(const EntityDecl &entity, - const Syntax &syntax, - const CharsetInfo &charset, - Messenger &mgr, - StringC &result) const -{ - const CatalogEntry *entry = 0; - const CatalogEntry *delegatedEntry = 0; - if (entity.systemIdPointer()) - entry = systemIds_.lookup(*entity.systemIdPointer()); - if (entity.publicIdPointer()) { - const CatalogEntry *publicEntry; - Boolean delegated; - publicEntry = findBestPublicEntry(*entity.publicIdPointer(), - entity.systemIdPointer() != 0, - charset, - delegated); - if (publicEntry && delegated) - delegatedEntry = publicEntry; - // match for system id has priority over match for public id in same - // catalog - if (publicEntry - && (!entry || publicEntry->catalogNumber < entry->catalogNumber)) - entry = publicEntry; - } - if (entity.name().size() > 0 - && (!entry || entry->catalogNumber > 0)) { - const CatalogEntry *entityEntry; - int tableIndex = (entity.declType() >= EntityDecl::parameterEntity - ? int(entity.declType()) - 1 - : int(entity.declType())); - StringC name(entity.name()); - Boolean subst; - switch (entity.declType()) { - case EntityDecl::parameterEntity: - { - StringC tem(name); - name = syntax.peroDelim(); - name += tem; - } - // fall through - case EntityDecl::generalEntity: - subst = syntax.namecaseEntity(); - break; - default: - subst = syntax.namecaseGeneral(); - break; - } - if (!subst) - entityEntry = names_[tableIndex].lookup(name, - entity.systemIdPointer() != 0); - else - entityEntry = names_[tableIndex].lookup(entity.name(), - syntax.upperSubstTable(), - entity.systemIdPointer() != 0); - // match for public id has priority over match for entity in same - // catalog - if (entityEntry - && (!entry || entityEntry->catalogNumber < entry->catalogNumber)) - entry = entityEntry; - } - if (entry) - return expandCatalogSystemId(entry->to, - entry->loc, - entry->baseNumber, - entity.dataType() == EntityDecl::ndata, - charset, - entry == delegatedEntry - ? entity.publicIdPointer() - : 0, - mgr, - result); - if (entity.systemIdPointer()) - return em_->expandSystemId(*entity.systemIdPointer(), - entity.defLocation(), - entity.dataType() == EntityDecl::ndata, - charset, - 0, - mgr, - result); - return 0; -} - -Boolean SOEntityCatalog::lookupPublic(const StringC &publicId, - const CharsetInfo &charset, - Messenger &mgr, - StringC &result) const -{ - Boolean delegated; - const CatalogEntry *entry = findBestPublicEntry(publicId, 0, charset, - delegated); - return (entry - && expandCatalogSystemId(entry->to, entry->loc, entry->baseNumber, - 0, charset, delegated ? &publicId : 0, - mgr, result)); - -} - -const CatalogEntry * -SOEntityCatalog::findBestPublicEntry(const StringC &publicId, - Boolean overrideOnly, - const CharsetInfo &charset, - Boolean &delegated) const -{ - Char slash = charset.execToDesc('/'); - Char colon = charset.execToDesc(':'); - const CatalogEntry *bestEntry = 0; - for (size_t i = 0; i <= publicId.size(); i++) { - if ((i + 1 < publicId.size() - && (publicId[i] == slash || publicId[i] == colon) - && publicId[i + 1] == publicId[i]) - || (i >= 2 - && (publicId[i - 1] == slash || publicId[i - 1] == colon) - && publicId[i - 2] == publicId[i - 1])) { - StringC tem(publicId.data(), i); - const CatalogEntry *entry = delegates_.lookup(tem, overrideOnly); - if (entry - && (!bestEntry - || entry->catalogNumber <= bestEntry->catalogNumber)) { - bestEntry = entry; - delegated = 1; - } - } - } - const CatalogEntry *entry = publicIds_.lookup(publicId, overrideOnly); - if (entry - && (!bestEntry || entry->catalogNumber <= bestEntry->catalogNumber)) { - bestEntry = entry; - delegated = 0; - } - return bestEntry; -} - -Boolean SOEntityCatalog::sgmlDecl(const CharsetInfo &charset, - Messenger &mgr, - StringC &result) const - -{ - return haveSgmlDecl_ && expandCatalogSystemId(sgmlDecl_, sgmlDeclLoc_, - sgmlDeclBaseNumber_, - 0, charset, 0, mgr, result); -} - -Boolean SOEntityCatalog::document(const CharsetInfo &charset, - Messenger &mgr, - StringC &result) const - -{ - return haveDocument_ && expandCatalogSystemId(document_, documentLoc_, - documentBaseNumber_, - 0, charset, 0, mgr, result); -} - -Boolean SOEntityCatalog::defaultDoctype(const CharsetInfo &charset, - Messenger &mgr, - StringC &name, - StringC &sysid) const -{ - if (defaultDoctype_.size() == 0) - return 0; - int tableIndex = EntityDecl::doctype; - if (tableIndex >= EntityDecl::parameterEntity) - tableIndex--; - const CatalogEntry *entry - = names_[tableIndex].lookup(defaultDoctype_, 0); - name = defaultDoctype_; - return expandCatalogSystemId(entry->to, - entry->loc, - entry->baseNumber, - 0, - charset, - 0, - mgr, - sysid); -} - -void SOEntityCatalog::addPublicId(StringC &publicId, StringC &systemId, - const Location &loc, Boolean override) -{ - CatalogEntry entry; - entry.loc = loc; - entry.catalogNumber = catalogNumber_; - entry.baseNumber = haveCurrentBase_ ? base_.size() : 0; - systemId.swap(entry.to); - publicIds_.insert(publicId, entry, override); -} - -void SOEntityCatalog::addDelegate(StringC &prefix, StringC &systemId, - const Location &loc, Boolean override) -{ - CatalogEntry entry; - entry.loc = loc; - entry.catalogNumber = catalogNumber_; - entry.baseNumber = haveCurrentBase_ ? base_.size() : 0; - systemId.swap(entry.to); - delegates_.insert(prefix, entry, override); -} - -void SOEntityCatalog::addSystemId(StringC &systemId, StringC &toSystemId, - const Location &loc) -{ - CatalogEntry entry; - entry.loc = loc; - entry.catalogNumber = catalogNumber_; - entry.baseNumber = haveCurrentBase_ ? base_.size() : 0; - toSystemId.swap(entry.to); - systemIds_.insert(systemId, entry, false); -} - -void SOEntityCatalog::addName(StringC &name, DeclType declType, - StringC &systemId, const Location &loc, - Boolean override) -{ - if (declType == EntityDecl::doctype - && defaultDoctype_.size() == 0) - defaultDoctype_ = name; - CatalogEntry entry; - entry.loc = loc; - entry.catalogNumber = catalogNumber_; - entry.baseNumber = haveCurrentBase_ ? base_.size() : 0; - int tableIndex = (declType >= EntityDecl::parameterEntity - ? int(declType) - 1 - : int(declType)); - entry.serial = names_[tableIndex].count(); - systemId.swap(entry.to); - names_[tableIndex].insert(name, entry, override); -} - -void SOEntityCatalog::setSgmlDecl(StringC &str, const Location &loc) -{ - if (!haveSgmlDecl_) { - haveSgmlDecl_ = true; - str.swap(sgmlDecl_); - sgmlDeclLoc_ = loc; - sgmlDeclBaseNumber_ = haveCurrentBase_ ? base_.size() : 0; - - } -} - -void SOEntityCatalog::setDocument(StringC &str, const Location &loc) -{ - if (!haveDocument_) { - haveDocument_ = true; - str.swap(document_); - documentLoc_ = loc; - documentBaseNumber_ = haveCurrentBase_ ? base_.size() : 0; - } -} - -void SOEntityCatalog::setBase(const Location &loc) -{ - if (loc.origin().isNull()) - haveCurrentBase_ = 0; - else { - haveCurrentBase_ = 1; - base_.push_back(loc); - } -} - -SOEntityCatalog::Table::Table() -{ -} - -void SOEntityCatalog::Table::insert(const StringC &key, - const CatalogEntry &entry, - Boolean override) -{ - if (override) - overrideEntries_.insert(key, entry, false); - else { - const CatalogEntry *e = overrideEntries_.lookup(key); - if (!e) - normalEntries_.insert(key, entry, false); - } -} - -const CatalogEntry *SOEntityCatalog::Table::lookup(const StringC &key, - Boolean overrideOnly) const -{ - if (!overrideOnly) { - const CatalogEntry *e = normalEntries_.lookup(key); - if (e) - return e; - } - return overrideEntries_.lookup(key); -} - -const CatalogEntry * -SOEntityCatalog::Table::lookup(const StringC &name, - const SubstTable &substTable, - Boolean overrideOnly) const -{ - HashTableIter iter1(overrideEntries_); - HashTableIter iter2(normalEntries_); - HashTableIter *iters[2]; - int nIter = 0; - iters[nIter++] = &iter1; - if (!overrideOnly) - iters[nIter++] = &iter2; - const CatalogEntry *entry = 0; - for (int i = 0; i < nIter; i++) { - HashTableIter &iter = *iters[i]; - const StringC *key; - const CatalogEntry *value; - StringC buffer; - while (iter.next(key, value)) { - buffer = *key; - for (size_t j = 0; j < buffer.size(); j++) - substTable.subst(buffer[j]); - if (buffer == name) { - if (!entry || value->serial < entry->serial) - entry = value; - } - } - } - return entry; -} - -size_t SOEntityCatalog::Table::count() const -{ - return normalEntries_.count() + overrideEntries_.count(); -} - -CatalogParser::CatalogParser(const CharsetInfo &charset) -: categoryTable_(data), - entityKey_(charset.execToDesc("ENTITY")), - publicKey_(charset.execToDesc("PUBLIC")), - systemKey_(charset.execToDesc("SYSTEM")), - doctypeKey_(charset.execToDesc("DOCTYPE")), - linktypeKey_(charset.execToDesc("LINKTYPE")), - notationKey_(charset.execToDesc("NOTATION")), - overrideKey_(charset.execToDesc("OVERRIDE")), - sgmlDeclKey_(charset.execToDesc("SGMLDECL")), - documentKey_(charset.execToDesc("DOCUMENT")), - catalogKey_(charset.execToDesc("CATALOG")), - yesKey_(charset.execToDesc("YES")), - noKey_(charset.execToDesc("NO")), - baseKey_(charset.execToDesc("BASE")), - delegateKey_(charset.execToDesc("DELEGATE")) -{ - static const char lcletters[] = "abcdefghijklmnopqrstuvwxyz"; - static const char ucletters[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; - // minimum data other than lcletter, ucletter - static const char minChars[] = "0123456789-.'()+,/:=?"; - static const char sChars[] = " \n\r\t"; - categoryTable_.setChar(0, nul); - const char *p; - const char *q; - for (p = lcletters, q = ucletters; *p; p++, q++) { - Char lc = charset.execToDesc(*p); - Char uc = charset.execToDesc(*q); - substTable_.addSubst(lc, uc); - categoryTable_.setChar(lc, min); - categoryTable_.setChar(uc, min); - } - for (p = sChars; *p; p++) - categoryTable_.setChar(charset.execToDesc(*p), s); - for (p = minChars; *p; p++) - categoryTable_.setChar(charset.execToDesc(*p), min); - categoryTable_.setChar(charset.execToDesc('\''), lita); - categoryTable_.setChar(charset.execToDesc('"'), lit); - minus_ = charset.execToDesc('-'); - categoryTable_.setChar(minus_, minus); - tab_ = charset.execToDesc('\t'); - re_ = charset.execToDesc('\r'); - rs_ = charset.execToDesc('\n'); - space_ = charset.execToDesc(' '); - categoryTable_.setEe(eof); -} - -void CatalogParser::parseCatalog(const StringC &sysid, - Boolean mustExist, - const CharsetInfo &sysidCharset, - const CharsetInfo &catalogCharset, - InputSourceOrigin *origin, - SOEntityCatalog *catalog, - Messenger &mgr) -{ - const Ptr &em = catalog->entityManager(); - in_ = (mustExist - ? em->open(sysid, sysidCharset, origin, 0, mgr) - : em->openIfExists(sysid, sysidCharset, origin, 0, mgr)); - if (!in_) - return; - catalog_ = catalog; - mgr_ = &mgr; - override_ = 0; - Boolean recovering = false; - Vector subSysids; - Vector subSysidLocs; - for (;;) { - Param parm = parseParam(); - if (parm == nameParam) { - upcase(param_); - recovering = false; - if (param_ == publicKey_) - parsePublic(); - else if (param_ == systemKey_) - parseSystem(); - else if (param_ == entityKey_) - parseNameMap(EntityDecl::generalEntity); - else if (param_ == doctypeKey_) - parseNameMap(EntityDecl::doctype); - else if (param_ == linktypeKey_) - parseNameMap(EntityDecl::linktype); - else if (param_ == notationKey_) - parseNameMap(EntityDecl::notation); - else if (param_ == sgmlDeclKey_) { - if (parseArg()) - catalog_->setSgmlDecl(param_, paramLoc_); - } - else if (param_ == documentKey_) { - if (parseArg()) - catalog_->setDocument(param_, paramLoc_); - } - else if (param_ == overrideKey_) - parseOverride(); - else if (param_ == catalogKey_) { - if (parseArg()) { - if (inLoop(paramLoc_)) - break; - subSysids.resize(subSysids.size() + 1); - param_.swap(subSysids.back()); - subSysidLocs.push_back(paramLoc_); - } - } - else if (param_ == baseKey_) { - if (parseArg()) { - StringC tem; - if (em->expandSystemId(param_, - paramLoc_, - 0, - catalogCharset, - 0, - mgr, - tem)) { - InputSource *in = em->open(tem, - catalogCharset, - new InputSourceOrigin(paramLoc_), - 0, - mgr); - if (in) - catalog->setBase(in->currentLocation()); - } - } - } - else if (param_ == delegateKey_) - parseDelegate(); - else { - if (parseParam() == eofParam) - break; - recovering = true; - } - } - else if (parm == eofParam) - break; - else if (!recovering) { - recovering = true; - message(CatalogMessages::nameExpected); - } - } - delete in_; - catalog->endCatalog(); - for (size_t i = 0; i < subSysids.size(); i++) { - StringC tem; - if (em->expandSystemId(subSysids[i], subSysidLocs[i], 0, catalogCharset, - 0, mgr, tem)) - parseCatalog(tem, 1, catalogCharset, catalogCharset, - new InputSourceOrigin(subSysidLocs[i]), catalog, mgr); - } -} - -Boolean CatalogParser::inLoop(const Location &loc) -{ - const InputSourceOrigin *origin = paramLoc_.origin()->asInputSourceOrigin(); - if (!origin) - return 0; - const ExternalInfo *info = origin->externalInfo(); - if (!info) - return 0; - StorageObjectLocation soLoc; - if (!ExtendEntityManager::externalize(info, - origin->startOffset(paramLoc_.index()), - soLoc)) - return 0; - for (;;) { - const Location &parent = origin->parent(); - if (parent.origin().isNull()) - break; - origin = parent.origin()->asInputSourceOrigin(); - if (!origin) - break; - const ExternalInfo *info1 = origin->externalInfo(); - if (info1) { - StorageObjectLocation soLoc1; - if (ExtendEntityManager::externalize(info1, - origin->startOffset(parent.index()), - soLoc1)) { - const StorageObjectSpec *sos = soLoc.storageObjectSpec; - const StorageObjectSpec *sos1 = soLoc1.storageObjectSpec; - if (sos->storageManager == sos1->storageManager - && sos->id == sos1->id) { - setNextLocation(loc.origin()->parent()); - message(CatalogMessages::inLoop); - return 1; - } - } - } - } - return 0; -} - -void CatalogParser::parseOverride() -{ - if (parseParam() != nameParam) { - message(CatalogMessages::overrideYesOrNo); - return; - } - upcase(param_); - if (param_ == yesKey_) - override_ = 1; - else if (param_ == noKey_) - override_ = 0; - else - message(CatalogMessages::overrideYesOrNo); -} - -void CatalogParser::parsePublic() -{ - if (parseParam(minimumLiteral) != literalParam) { - message(CatalogMessages::literalExpected); - return; - } - StringC publicId; - param_.swap(publicId); - if (!parseArg()) - return; - catalog_->addPublicId(publicId, param_, paramLoc_, override_); -} - -void CatalogParser::parseDelegate() -{ - if (parseParam(minimumLiteral) != literalParam) { - message(CatalogMessages::literalExpected); - return; - } - StringC publicId; - param_.swap(publicId); - if (!parseArg()) - return; - catalog_->addDelegate(publicId, param_, paramLoc_, override_); -} - -void CatalogParser::parseSystem() -{ - if (!parseArg()) - return; - StringC systemId; - param_.swap(systemId); - Param parm = parseParam(); - if (parm == nameParam) - message(CatalogMessages::systemShouldQuote); - else if (parm != literalParam) { - message(CatalogMessages::literalExpected); - return; - } - catalog_->addSystemId(systemId, param_, paramLoc_); -} - -void CatalogParser::parseNameMap(EntityDecl::DeclType declType) -{ - if (!parseArg()) - return; - StringC name; - param_.swap(name); - if (!parseArg()) - return; - catalog_->addName(name, declType, param_, paramLoc_, override_); -} - -Boolean CatalogParser::parseArg() -{ - Param parm = parseParam(); - if (parm != nameParam && parm != literalParam) { - message(CatalogMessages::nameOrLiteralExpected); - return false; - } - return true; -} - -CatalogParser::Param CatalogParser::parseParam(unsigned flags) -{ - for (;;) { - Xchar c = get(); - switch (categoryTable_[c]) { - case eof: - return eofParam; - case lit: - case lita: - parseLiteral(c, flags); - return literalParam; - case s: - break; - case nul: - message(CatalogMessages::nulChar); - break; - case minus: - c = get(); - if (c == minus_) { - skipComment(); - break; - } - unget(); - // fall through - default: - parseName(); - return nameParam; - } - } -} - -void CatalogParser::skipComment() -{ - for (;;) { - Xchar c = get(); - if (c == minus_) { - c = get(); - if (c == minus_) - break; - } - if (c == InputSource::eE) { - message(CatalogMessages::eofInComment); - break; - } - } -} - -void CatalogParser::parseLiteral(Char delim, unsigned flags) -{ - paramLoc_ = in_->currentLocation(); - enum { no, yesBegin, yesMiddle } skipping = yesBegin; - param_.resize(0); - for (;;) { - Xchar c = get(); - if (c == InputSource::eE) { - message(CatalogMessages::eofInLiteral); - break; - } - if (Char(c) == delim) - break; - if (flags & minimumLiteral) { - if (!isMinimumData(c)) - message(CatalogMessages::minimumData); - if (c == rs_) - ; - else if (c == space_ || c == re_) { - if (skipping == no) { - param_ += space_; - skipping = yesMiddle; - } - } - else { - skipping = no; - param_ += Char(c); - } - } - else - param_ += Char(c); - } - if (skipping == yesMiddle) - param_.resize(param_.size() - 1); -} - -void CatalogParser::parseName() -{ - paramLoc_ = in_->currentLocation(); - size_t length; - for (length = 1;; length++) { - Xchar c = in_->tokenChar(messenger()); - int cat = categoryTable_[c]; - if (cat == eof || cat == s) - break; - // FIXME maybe check for LIT or LITA - if (cat == nul) - message(CatalogMessages::nulChar); - } - in_->endToken(length); - param_.assign(in_->currentTokenStart(), in_->currentTokenLength()); -} - -void CatalogParser::upcase(StringC &str) -{ - for (size_t i = 0; i < str.size(); i++) - substTable_.subst(str[i]); -} - -void CatalogParser::dispatchMessage(const Message &msg) -{ - mgr_->dispatchMessage(msg); -} - -void CatalogParser::dispatchMessage(Message &msg) -{ - mgr_->dispatchMessage(msg); -} - -void CatalogParser::initMessage(Message &msg) -{ - msg.loc = in_->currentLocation(); -} - -#ifdef SP_NAMESPACE -} -#endif diff --git a/cde/programs/nsgmls/SOEntityCatalog.h b/cde/programs/nsgmls/SOEntityCatalog.h deleted file mode 100644 index df66e51a3..000000000 --- a/cde/programs/nsgmls/SOEntityCatalog.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: SOEntityCatalog.h /main/1 1996/07/29 17:03:35 cde-hp $ */ -// Copyright (c) 1994, 1995 James Clark -// See the file COPYING for copying permission. - -#ifndef SOEntityCatalog_INCLUDED -#define SOEntityCatalog_INCLUDED 1 - -#ifdef __GNUG__ -#pragma interface -#endif - -#include "ExtendEntityManager.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -class SP_API SOCatalogManager : public ExtendEntityManager::CatalogManager { -public: - static ExtendEntityManager::CatalogManager * - make(const Vector &sysids, - size_t nSysidsMustExist, - const CharsetInfo &sysidCharset, - const CharsetInfo &catalogCharset); -}; - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* not SOEntityCatalog_INCLUDED */ diff --git a/cde/programs/nsgmls/Sd.C b/cde/programs/nsgmls/Sd.C deleted file mode 100644 index d9917256e..000000000 --- a/cde/programs/nsgmls/Sd.C +++ /dev/null @@ -1,244 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: Sd.C /main/1 1996/07/29 17:03:39 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#ifdef __GNUG__ -#pragma implementation -#endif -#include "splib.h" -#include "Sd.h" -#include "macros.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -Sd::Sd() -: scopeInstance_(0) -{ - int i; - for (i = 0; i < nBooleanFeature; i++) - booleanFeature_[i] = 0; - for (i = 0; i < nNumberFeature; i++) - numberFeature_[i] = 0; - for (i = 0; i < nCapacity; i++) - capacity_[i] = 35000; -} - -void Sd::setDocCharsetDesc(const UnivCharsetDesc &desc) -{ - docCharset_.set(desc); -} - -const char *const Sd::reservedName_[] = { - "APPINFO", - "BASESET", - "CAPACITY", - "CHARSET", - "CONCUR", - "CONTROLS", - "DATATAG", - "DELIM", - "DESCSET", - "DOCUMENT", - "ENTITY", - "EXPLICIT", - "FEATURES", - "FORMAL", - "FUNCHAR", - "FUNCTION", - "GENERAL", - "IMPLICIT", - "INSTANCE", - "LCNMCHAR", - "LCNMSTRT", - "LINK", - "MINIMIZE", - "MSICHAR", - "MSOCHAR", - "MSSCHAR", - "NAMECASE", - "NAMES", - "NAMING", - "NO", - "NONE", - "OMITTAG", - "OTHER", - "PUBLIC", - "QUANTITY", - "RANK", - "RE", - "RS", - "SCOPE", - "SEPCHAR", - "SGML", - "SGMLREF", - "SHORTREF", - "SHORTTAG", - "SHUNCHAR", - "SIMPLE", - "SPACE", - "SUBDOC", - "SWITCHES", - "SYNTAX", - "UCNMCHAR", - "UCNMSTRT", - "UNUSED", - "YES" -}; - -const char *const Sd::capacityName_[] = { - "TOTALCAP", - "ENTCAP", - "ENTCHCAP", - "ELEMCAP", - "GRPCAP", - "EXGRPCAP", - "EXNMCAP", - "ATTCAP", - "ATTCHCAP", - "AVGRPCAP", - "NOTCAP", - "NOTCHCAP", - "IDCAP", - "IDREFCAP", - "MAPCAP", - "LKSETCAP", - "LKNMCAP" -}; - - -const char *const Sd::quantityName_[] = { - "ATTCNT", - "ATTSPLEN", - "BSEQLEN", - "DTAGLEN", - "DTEMPLEN", - "ENTLVL", - "GRPCNT", - "GRPGTCNT", - "GRPLVL", - "LITLEN", - "NAMELEN", - "NORMSEP", - "PILEN", - "TAGLEN", - "TAGLVL" -}; - -const char *const Sd::generalDelimiterName_[] = { - "AND", - "COM", - "CRO", - "DSC", - "DSO", - "DTGC", - "DTGO", - "ERO", - "ETAGO", - "GRPC", - "GRPO", - "LIT", - "LITA", - "MDC", - "MDO", - "MINUS", - "MSC", - "NET", - "OPT", - "OR", - "PERO", - "PIC", - "PIO", - "PLUS", - "REFC", - "REP", - "RNI", - "SEQ", - "STAGO", - "TAGC", - "VI" -}; - -Boolean Sd::lookupQuantityName(const StringC &name, Syntax::Quantity &quantity) - const -{ - for (size_t i = 0; i < SIZEOF(quantityName_); i++) - if (execToDoc(quantityName_[i]) == name) { - quantity = Syntax::Quantity(i); - return 1; - } - return 0; -} - -Boolean Sd::lookupCapacityName(const StringC &name, Sd::Capacity &capacity) - const -{ - for (size_t i = 0; i < SIZEOF(capacityName_); i++) - if (execToDoc(capacityName_[i]) == name) { - capacity = Sd::Capacity(i); - return 1; - } - return 0; -} - -Boolean Sd::lookupGeneralDelimiterName(const StringC &name, - Syntax::DelimGeneral &delimGeneral) - const -{ - for (size_t i = 0; i < SIZEOF(generalDelimiterName_); i++) - if (execToDoc(generalDelimiterName_[i]) == name) { - delimGeneral = Syntax::DelimGeneral(i); - return 1; - } - return 0; -} - -StringC Sd::quantityName(Syntax::Quantity q) const -{ - return execToDoc(quantityName_[q]); -} - -StringC Sd::generalDelimiterName(Syntax::DelimGeneral d) const -{ - return execToDoc(generalDelimiterName_[d]); -} - -UnivChar Sd::nameToUniv(const StringC &name) -{ - const int *p = namedCharTable_.lookup(name); - int n; - if (p) - n = *p; - else { - n = int(namedCharTable_.count()); - namedCharTable_.insert(name, n); - } - return n + 0x60000000; // 10646 private use group -} - -#ifdef SP_NAMESPACE -} -#endif diff --git a/cde/programs/nsgmls/Sd.h b/cde/programs/nsgmls/Sd.h deleted file mode 100644 index 7f274e439..000000000 --- a/cde/programs/nsgmls/Sd.h +++ /dev/null @@ -1,354 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: Sd.h /main/1 1996/07/29 17:03:44 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#ifndef Sd_INCLUDED -#define Sd_INCLUDED 1 -#ifdef __GNUG__ -#pragma interface -#endif - -#include "types.h" -#include "Boolean.h" -#include "Resource.h" -#include "CharsetInfo.h" -#include "ExternalId.h" -#include "ISet.h" -#include "Syntax.h" -#include "CharsetDecl.h" -#include "HashTable.h" - -// Information about the SGML declaration that is not syntax specific. - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -class SP_API Sd : public Resource { -public: - // These must be in the same order as in the SGML declaration. - enum BooleanFeature { - fDATATAG, - fOMITTAG, - fRANK, - fSHORTTAG, - fIMPLICIT, - fFORMAL - }; - enum { nBooleanFeature = fFORMAL + 1 }; - // These must be in the same order as in the SGML declaration. - enum NumberFeature { - fSIMPLE, - fEXPLICIT, - fCONCUR, - fSUBDOC - }; - enum { nNumberFeature = fSUBDOC + 1 }; - // These are names used only in the SGML declaration. - enum ReservedName { - rAPPINFO, - rBASESET, - rCAPACITY, - rCHARSET, - rCONCUR, - rCONTROLS, - rDATATAG, - rDELIM, - rDESCSET, - rDOCUMENT, - rENTITY, - rEXPLICIT, - rFEATURES, - rFORMAL, - rFUNCHAR, - rFUNCTION, - rGENERAL, - rIMPLICIT, - rINSTANCE, - rLCNMCHAR, - rLCNMSTRT, - rLINK, - rMINIMIZE, - rMSICHAR, - rMSOCHAR, - rMSSCHAR, - rNAMECASE, - rNAMES, - rNAMING, - rNO, - rNONE, - rOMITTAG, - rOTHER, - rPUBLIC, - rQUANTITY, - rRANK, - rRE, - rRS, - rSCOPE, - rSEPCHAR, - rSGML, - rSGMLREF, - rSHORTREF, - rSHORTTAG, - rSHUNCHAR, - rSIMPLE, - rSPACE, - rSUBDOC, - rSWITCHES, - rSYNTAX, - rUCNMCHAR, - rUCNMSTRT, - rUNUSED, - rYES - }; - enum Capacity { - TOTALCAP, - ENTCAP, - ENTCHCAP, - ELEMCAP, - GRPCAP, - EXGRPCAP, - EXNMCAP, - ATTCAP, - ATTCHCAP, - AVGRPCAP, - NOTCAP, - NOTCHCAP, - IDCAP, - IDREFCAP, - MAPCAP, - LKSETCAP, - LKNMCAP - }; - enum { nCapacity = LKNMCAP + 1 }; - Sd(); - void setDocCharsetDesc(const UnivCharsetDesc &); - void setSgmlChar(const ISet &); - Boolean matchesReservedName(const StringC &, ReservedName) const; - int digitWeight(Char) const; - Boolean link() const; - Number simpleLink() const; - Boolean implicitLink() const; - Number explicitLink() const; - Boolean shorttag() const; - Number concur() const; - Boolean omittag() const; - Boolean rank() const; - Boolean datatag() const; - Boolean formal() const; - Number subdoc() const; - StringC reservedName(int) const; - Boolean lookupQuantityName(const StringC &, Syntax::Quantity &) const; - Boolean lookupGeneralDelimiterName(const StringC &, Syntax::DelimGeneral &) - const; - Boolean lookupCapacityName(const StringC &, Sd::Capacity &) const; - StringC quantityName(Syntax::Quantity) const; - const CharsetInfo &docCharset() const; - Char execToDoc(char) const; - StringC execToDoc(const char *) const; - Number capacity(int) const; - void setCapacity(int, Number); - StringC capacityName(int) const; - Boolean scopeInstance() const; - void setScopeInstance(); - void setDocCharsetDecl(CharsetDecl &); - const CharsetDecl &docCharsetDecl() const; - void setBooleanFeature(BooleanFeature, Boolean); - void setNumberFeature(NumberFeature, Number); - StringC generalDelimiterName(Syntax::DelimGeneral) const; - UnivChar nameToUniv(const StringC &); -private: - enum { nFeature = fFORMAL + 1 }; - PackedBoolean booleanFeature_[nBooleanFeature]; - Number numberFeature_[nNumberFeature]; - Number capacity_[nCapacity]; - CharsetInfo docCharset_; - CharsetDecl docCharsetDecl_; - Boolean scopeInstance_; - HashTable namedCharTable_; - static const char *const reservedName_[]; - static const char *const generalDelimiterName_[]; - static const char *const capacityName_[]; - static const char *const quantityName_[]; -}; - -inline -Boolean Sd::link() const -{ - return (numberFeature_[fSIMPLE] - || booleanFeature_[fIMPLICIT] - || numberFeature_[fEXPLICIT]); -} - -inline -Number Sd::explicitLink() const -{ - return numberFeature_[fEXPLICIT]; -} - -inline -Boolean Sd::implicitLink() const -{ - return booleanFeature_[fIMPLICIT]; -} - -inline -Number Sd::simpleLink() const -{ - return numberFeature_[fSIMPLE]; -} - -inline -Boolean Sd::shorttag() const -{ - return booleanFeature_[fSHORTTAG]; -} - -inline -Number Sd::concur() const -{ - return numberFeature_[fCONCUR]; -} - -inline -Number Sd::subdoc() const -{ - return numberFeature_[fSUBDOC]; -} - - -inline -Boolean Sd::omittag() const -{ - return booleanFeature_[fOMITTAG]; -} - -inline -Boolean Sd::rank() const -{ - return booleanFeature_[fRANK]; -} - -inline -Boolean Sd::datatag() const -{ - return booleanFeature_[fDATATAG]; -} - -inline -Boolean Sd::formal() const -{ - return booleanFeature_[fFORMAL]; -} - -inline -Char Sd::execToDoc(char c) const -{ - return docCharset_.execToDesc(c); -} - -inline -StringC Sd::execToDoc(const char *s) const -{ - return docCharset_.execToDesc(s); -} - -inline -StringC Sd::reservedName(int i) const -{ - return execToDoc(reservedName_[i]); -} - -inline -const CharsetInfo &Sd::docCharset() const -{ - return docCharset_; -} - -inline -int Sd::digitWeight(Char c) const -{ - return docCharset_.digitWeight(c); -} - -inline -Number Sd::capacity(int i) const -{ - return capacity_[i]; -} - -inline -void Sd::setCapacity(int i, Number n) -{ - capacity_[i] = n; -} - -inline -StringC Sd::capacityName(int i) const -{ - return execToDoc(capacityName_[i]); -} - -inline -Boolean Sd::scopeInstance() const -{ - return scopeInstance_; -} - -inline -void Sd::setScopeInstance() -{ - scopeInstance_ = 1; -} - -inline -void Sd::setDocCharsetDecl(CharsetDecl &decl) -{ - decl.swap(docCharsetDecl_); -} - -inline -const CharsetDecl &Sd::docCharsetDecl() const -{ - return docCharsetDecl_; -} - -inline -void Sd::setBooleanFeature(BooleanFeature i, Boolean b) -{ - booleanFeature_[i] = b; -} - -inline -void Sd::setNumberFeature(NumberFeature i, Number n) -{ - numberFeature_[i] = n; -} - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* Sd_INCLUDED */ diff --git a/cde/programs/nsgmls/SdFormalError.h b/cde/programs/nsgmls/SdFormalError.h deleted file mode 100644 index 6392c09c9..000000000 --- a/cde/programs/nsgmls/SdFormalError.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: SdFormalError.h /main/1 1996/07/29 17:03:49 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#ifndef SdFormalError_INCLUDED -#define SdFormalError_INCLUDED 1 - -#include "Link.h" -#include "StringC.h" -#include "Message.h" -#include "Location.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -class ParserState; - -class SdFormalError : public Link { -public: - SdFormalError(const Location &, const MessageType1 &, const StringC &); - void send(ParserState &); -private: - const MessageType1 *message_; - Location location_; - StringC id_; -}; - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* not SdFormalError_INCLUDED */ diff --git a/cde/programs/nsgmls/SdText.C b/cde/programs/nsgmls/SdText.C deleted file mode 100644 index e9c10f5a4..000000000 --- a/cde/programs/nsgmls/SdText.C +++ /dev/null @@ -1,111 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: SdText.C /main/1 1996/07/29 17:03:53 cde-hp $ */ -// Copyright (c) 1995 James Clark -// See the file COPYING for copying permission. - -#ifdef __GNUG__ -#pragma implementation -#endif -#include "splib.h" -#include "SdText.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -SdText::SdText() -: lita_(false) -{ -} - -SdText::SdText(const Location &loc, Boolean lita) -: lita_(lita) -{ - items_.resize(items_.size() + 1); - items_.back().loc = loc; - items_.back().index = 0; -} - -void SdText::addChar(SyntaxChar c, const Location &loc) -{ - if (items_.size() == 0 - || loc.origin().pointer() != items_.back().loc.origin().pointer() - || loc.index() != (items_.back().loc.index() - + (chars_.size() - items_.back().index))) { - items_.resize(items_.size() + 1); - items_.back().loc = loc; - items_.back().index = chars_.size(); - } - chars_ += c; -} - -void SdText::swap(SdText &to) -{ - items_.swap(to.items_); - chars_.swap(to.chars_); - { - Boolean tem = to.lita_; - to.lita_ = lita_; - lita_ = tem; - } -} - -Location SdText::endDelimLocation() const -{ - Location loc(items_.back().loc); - loc += chars_.size() - items_.back().index; - return loc; -} - -SdTextItem::SdTextItem() -: index(0) -{ -} - -SdTextIter::SdTextIter(const SdText &text) -: ptr_(&text), - itemIndex_(0) -{ -} - -Boolean SdTextIter::next(const SyntaxChar *&ptr, size_t &length, Location &loc) -{ - const Vector &items = ptr_->items_; - if (itemIndex_ >= items.size()) - return 0; - loc = items[itemIndex_].loc; - const String &chars = ptr_->chars_; - size_t charsIndex = items[itemIndex_].index; - ptr = chars.data() + charsIndex; - if (itemIndex_ + 1 < items.size()) - length = items[itemIndex_ + 1].index - charsIndex; - else - length = chars.size() - charsIndex; - itemIndex_++; - return 1; -} - -#ifdef SP_NAMESPACE -} -#endif diff --git a/cde/programs/nsgmls/SdText.h b/cde/programs/nsgmls/SdText.h deleted file mode 100644 index 38542321d..000000000 --- a/cde/programs/nsgmls/SdText.h +++ /dev/null @@ -1,91 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: SdText.h /main/1 1996/07/29 17:03:58 cde-hp $ */ -// Copyright (c) 1995 James Clark -// See the file COPYING for copying permission. - -#ifndef SdText_INCLUDED -#define SdText_INCLUDED 1 - -#ifdef __GNUG__ -#pragma interface -#endif - -#include "types.h" -#include "StringOf.h" -#include "Vector.h" -#include "Location.h" -#include - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -struct SP_API SdTextItem { - SdTextItem(); - Location loc; - size_t index; -}; - -class SP_API SdText { -public: - SdText(); - SdText(const Location &loc, Boolean lita); - void swap(SdText &); - void addChar(SyntaxChar, const Location &); - const String &string() const; - Boolean lita() const; - Location endDelimLocation() const; -private: - Boolean lita_; - String chars_; - Vector items_; - friend class SdTextIter; -}; - -class SP_API SdTextIter { -public: - SdTextIter(const SdText &); - Boolean next(const SyntaxChar *&, size_t &, Location &); -private: - const SdText *ptr_; - size_t itemIndex_; -}; - -inline -Boolean SdText::lita() const -{ - return lita_; -} - -inline -const String &SdText::string() const -{ - return chars_; -} - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* not SdText_INCLUDED */ diff --git a/cde/programs/nsgmls/SearchResultMessageArg.C b/cde/programs/nsgmls/SearchResultMessageArg.C deleted file mode 100644 index 69d219ed9..000000000 --- a/cde/programs/nsgmls/SearchResultMessageArg.C +++ /dev/null @@ -1,58 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: SearchResultMessageArg.C /main/1 1996/07/29 17:04:02 cde-hp $ */ -// Copyright (c) 1995 James Clark -// See the file COPYING for copying permission. - -#ifdef __GNUG__ -#pragma implementation -#endif - -#include "splib.h" -#include "SearchResultMessageArg.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -RTTI_DEF1(SearchResultMessageArg, OtherMessageArg); - -SearchResultMessageArg::SearchResultMessageArg() -{ -} - -MessageArg *SearchResultMessageArg::copy() const -{ - return new SearchResultMessageArg(*this); -} - -void SearchResultMessageArg::add(StringC &str, int n) -{ - filename_.resize(filename_.size() + 1); - str.swap(filename_.back()); - errno_.push_back(n); -} - -#ifdef SP_NAMESPACE -} -#endif diff --git a/cde/programs/nsgmls/SearchResultMessageArg.h b/cde/programs/nsgmls/SearchResultMessageArg.h deleted file mode 100644 index 951b00409..000000000 --- a/cde/programs/nsgmls/SearchResultMessageArg.h +++ /dev/null @@ -1,80 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: SearchResultMessageArg.h /main/1 1996/07/29 17:04:07 cde-hp $ */ -// Copyright (c) 1995 James Clark -// See the file COPYING for copying permission. - -#ifndef SearchResultMessageArg_INCLUDED -#define SearchResultMessageArg_INCLUDED 1 - -#ifdef __GNUG__ -#pragma interface -#endif - -#include "MessageArg.h" -#include "StringC.h" -#include "Vector.h" -#include "Vector.h" -#include "rtti.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -class SP_API SearchResultMessageArg : public OtherMessageArg { - RTTI_CLASS -public: - SearchResultMessageArg(); - void add(StringC &, int); - MessageArg *copy() const; - size_t nTried() const; - const StringC &filename(size_t) const; - int errnum(size_t) const; -private: - Vector filename_; - Vector errno_; -}; - -inline -size_t SearchResultMessageArg::nTried() const -{ - return filename_.size(); -} - -inline -const StringC &SearchResultMessageArg::filename(size_t i) const -{ - return filename_[i]; -} - -inline -int SearchResultMessageArg::errnum(size_t i) const -{ - return errno_[i]; -} - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* not SearchResultMessageArg_INCLUDED */ diff --git a/cde/programs/nsgmls/SgmlParser.C b/cde/programs/nsgmls/SgmlParser.C deleted file mode 100644 index 1286234b0..000000000 --- a/cde/programs/nsgmls/SgmlParser.C +++ /dev/null @@ -1,136 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: SgmlParser.C /main/1 1996/07/29 17:04:11 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#ifdef __GNUG__ -#pragma implementation -#endif - -#include "splib.h" -#include "SgmlParser.h" -#include "Parser.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -SgmlParser::SgmlParser() -: parser_(0) -{ -} - -SgmlParser::SgmlParser(const Params ¶ms) -: parser_(new Parser(params)) -{ -} - -void SgmlParser::init(const Params ¶ms) -{ - delete parser_; - parser_ = new Parser(params); -} - -SgmlParser::~SgmlParser() -{ - delete parser_; -} - -Event *SgmlParser::nextEvent() -{ - return parser_->nextEvent(); -} - -void SgmlParser::parseAll(EventHandler &handler, - SP_CONST SP_VOLATILE sig_atomic_t *cancelPtr) -{ - parser_->parseAll(handler, cancelPtr); -} - -ConstPtr SgmlParser::sd() const -{ - return parser_->sdPointer(); -} - -ConstPtr SgmlParser::instanceSyntax() const -{ - return parser_->instanceSyntaxPointer(); -} - -ConstPtr SgmlParser::prologSyntax() const -{ - return parser_->prologSyntaxPointer(); -} - -const EntityManager &SgmlParser::entityManager() const -{ - return parser_->entityManager(); -} - -const EntityCatalog &SgmlParser::entityCatalog() const -{ - return parser_->entityCatalog(); -} - -void SgmlParser::activateLinkType(const StringC &name) -{ - parser_->activateLinkType(name); -} - -void SgmlParser::allLinkTypesActivated() -{ - parser_->allLinkTypesActivated(); -} - -void SgmlParser::swap(SgmlParser &s) -{ - Parser *tem = parser_; - parser_ = s.parser_; - s.parser_ = tem; -} - -Ptr SgmlParser::baseDtd() -{ - return parser_->baseDtd(); -} - -const ParserOptions &SgmlParser::options() const -{ - return parser_->options(); -} - -SgmlParser::Params::Params() -: entityType(document), - initialCharset(0), - parent(0), - options(0), - subdocInheritActiveLinkTypes(0), - subdocReferenced(0), - subdocLevel(0) -{ -} - -#ifdef SP_NAMESPACE -} -#endif diff --git a/cde/programs/nsgmls/SgmlParser.h b/cde/programs/nsgmls/SgmlParser.h deleted file mode 100644 index 34e6c17cd..000000000 --- a/cde/programs/nsgmls/SgmlParser.h +++ /dev/null @@ -1,111 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: SgmlParser.h /main/1 1996/07/29 17:04:16 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#ifndef SgmlParser_INCLUDED -#define SgmlParser_INCLUDED 1 - -#ifdef __GNUG__ -#pragma interface -#endif - -#include "StringC.h" -#include "Ptr.h" -#include "Location.h" -#include "EntityManager.h" - -#include - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -class Event; -class Parser; -class UnivCharsetDesc; -class EventHandler; -struct ParserOptions; -template class Ptr; -template class ConstPtr; -class InputSourceOrigin; -class Sd; -class Syntax; -class Dtd; - -class SP_API SgmlParser { -public: - struct SP_API Params { - enum EntityType { - document, - subdoc, - dtd - }; - Params(); - EntityType entityType; // defaults to document - StringC sysid; // must be specified - Ptr origin; - Ptr entityManager; - const UnivCharsetDesc *initialCharset; - const SgmlParser *parent; - ConstPtr sd; - ConstPtr prologSyntax; - ConstPtr instanceSyntax; - unsigned subdocLevel; - const ParserOptions *options; - PackedBoolean subdocInheritActiveLinkTypes; - // referenced subdocs count against SUBDOC limit in SGML declaration - PackedBoolean subdocReferenced; - StringC doctypeName; - }; - SgmlParser(); // must call init - SgmlParser(const Params ¶ms); - void init(const Params ¶ms); - ~SgmlParser(); - Event *nextEvent(); - void parseAll(EventHandler &, - SP_CONST SP_VOLATILE sig_atomic_t *cancelPtr = 0); - ConstPtr sd() const; - ConstPtr instanceSyntax() const; - ConstPtr prologSyntax() const; - const EntityManager &entityManager() const; - const EntityCatalog &entityCatalog() const; - const ParserOptions &options() const; - // Only to be called after the parse has ended. - Ptr baseDtd(); - void activateLinkType(const StringC &); - void allLinkTypesActivated(); - void swap(SgmlParser &); - friend class Parser; -private: - SgmlParser(const SgmlParser &); - void operator=(const SgmlParser &); - Parser *parser_; -}; - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* not SgmlParser_INCLUDED */ diff --git a/cde/programs/nsgmls/SgmlsEventHandler.C b/cde/programs/nsgmls/SgmlsEventHandler.C deleted file mode 100644 index bdf45974a..000000000 --- a/cde/programs/nsgmls/SgmlsEventHandler.C +++ /dev/null @@ -1,631 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: SgmlsEventHandler.C /main/1 1996/07/29 17:04:20 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#include "config.h" -#include "SgmlsEventHandler.h" -#include "SgmlParser.h" -#include "ParserOptions.h" -#include "Entity.h" -#include "Notation.h" -#include "Attribute.h" -#include "ExtendEntityManager.h" -#include "StorageManager.h" -#include "macros.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -const char dataCode = '-'; -const char piCode = '?'; -const char conformingCode = 'C'; -const char appinfoCode = '#'; -const char startElementCode = '('; -const char endElementCode = ')'; -const char referenceEntityCode = '&'; -const char attributeCode = 'A'; -const char dataAttributeCode = 'D'; -const char linkAttributeCode = 'a'; -const char defineNotationCode = 'N'; -const char defineExternalEntityCode = 'E'; -const char defineInternalEntityCode = 'I'; -const char defineSubdocEntityCode = 'S'; -const char defineExternalTextEntityCode = 'T'; -const char pubidCode = 'p'; -const char sysidCode = 's'; -const char startSubdocCode = '{'; -const char endSubdocCode = '}'; -const char fileCode = 'f'; -const char locationCode = 'L'; -const char includedElementCode = 'i'; - -const OutputCharStream::Newline nl = OutputCharStream::newline; - -const char space = ' '; -const Char re = '\r'; - -inline -void SgmlsEventHandler::startData() -{ - if (!haveData_) { - os() << dataCode; - haveData_ = 1; - } -} - -inline -void SgmlsEventHandler::flushData() -{ - if (haveData_) { - os() << nl; - haveData_ = 0; - } -} - -inline -void SgmlsEventHandler::outputLocation(const Location &loc) -{ - if (outputLine_) - outputLocation1(loc); -} - -SgmlsEventHandler::SgmlsEventHandler(const SgmlParser *parser, - OutputCharStream *os, - Messenger *messenger, - unsigned outputFlags) -: SgmlsSubdocState(parser), os_(os), messenger_(messenger), - outputLine_((outputFlags & outputLine) != 0), - outputEntity_((outputFlags & outputEntity) != 0), - outputId_((outputFlags & outputId) != 0), - outputNotationSysid_((outputFlags & outputNotationSysid) != 0), - outputIncluded_((outputFlags & outputIncluded) != 0), - haveData_(0), lastSos_(0), lastLineno_(0) -{ - os_->setEscaper(escape); -} - -SgmlsEventHandler::~SgmlsEventHandler() -{ - flushData(); - if (errorCount() == 0) - os() << conformingCode << nl; - delete os_; -} - -void SgmlsEventHandler::message(MessageEvent *event) -{ - messenger_->dispatchMessage(event->message()); - ErrorCountEventHandler::message(event); -} - -void SgmlsEventHandler::appinfo(AppinfoEvent *event) -{ - const StringC *str; - if (event->literal(str)) { - outputLocation(event->location()); - flushData(); - os() << appinfoCode; - outputString(*str); - os() << nl; - } - delete event; -} - -void SgmlsEventHandler::endProlog(EndPrologEvent *event) -{ - if (outputEntity_) { - flushData(); - const Dtd &dtd = event->dtd(); - Dtd::ConstEntityIter iter(dtd.generalEntityIter()); - for (;;) { - const Entity *entity = iter.next().pointer(); - if (!entity) - break; - defineEntity(entity); - } - } - if (!event->lpdPointer().isNull()) { - linkProcess_.init(event->lpdPointer()); - haveLinkProcess_ = 1; - flushData(); - } - for (size_t i = 0; i < event->simpleLinkNames().size(); i++) { - flushData(); - attributes(event->simpleLinkAttributes()[i], - linkAttributeCode, - &event->simpleLinkNames()[i]); - } - delete event; -} - -void SgmlsEventHandler::entityDefaulted(EntityDefaultedEvent *event) -{ - if (outputEntity_) { - flushData(); - defineEntity(event->entityPointer().pointer()); - } - delete event; -} - -void SgmlsEventHandler::uselink(UselinkEvent *event) -{ - linkProcess_.uselink(event->linkSet(), - event->restore(), - event->lpd().pointer()); - delete event; -} - -void SgmlsEventHandler::sgmlDecl(SgmlDeclEvent *event) -{ - sd_ = event->sdPointer(); - syntax_ = event->instanceSyntaxPointer(); // FIXME which syntax? - delete event; -} - -void SgmlsEventHandler::data(DataEvent *event) -{ - outputLocation(event->location()); - startData(); - outputString(event->data(), event->dataLength()); - delete event; -} - -void SgmlsEventHandler::sdataEntity(SdataEntityEvent *event) -{ - outputLocation(event->location()); - startData(); - os() << "\\|"; - outputString(event->data(), event->dataLength()); - os() << "\\|"; - delete event; -} - -void SgmlsEventHandler::pi(PiEvent *event) -{ - outputLocation(event->location()); - flushData(); - os() << piCode; - outputString(event->data(), event->dataLength()); - os() << nl; - delete event; -} - -void SgmlsEventHandler::startElement(StartElementEvent *event) -{ - flushData(); - currentLocation_ = event->location(); - if (haveLinkProcess_) { - const AttributeList *linkAttributes; - const ResultElementSpec *resultElementSpec; - linkProcess_.startElement(event->elementType(), - event->attributes(), - event->location(), - *this, // Messenger & - linkAttributes, - resultElementSpec); - if (linkAttributes) - attributes(*linkAttributes, linkAttributeCode, &linkProcess_.name()); - } - attributes(event->attributes(), attributeCode, 0); - currentLocation_.clear(); - if (outputIncluded_ && event->included()) - os() << includedElementCode << nl; - outputLocation(event->location()); - os() << startElementCode << event->name() << nl; - delete event; -} - -void SgmlsEventHandler::attributes(const AttributeList &attributes, - char code, - const StringC *ownerName) -{ - size_t nAttributes = attributes.size(); - for (size_t i = 0; i < nAttributes; i++) { - const Text *text; - const StringC *string; - const AttributeValue *value = attributes.value(i); - if (value) { - switch (value->info(text, string)) { - case AttributeValue::implied: - startAttribute(attributes.name(i), code, ownerName); - os() << "IMPLIED" << nl; - break; - case AttributeValue::tokenized: - { - const char *typeString = "TOKEN"; - const AttributeSemantics *semantics = attributes.semantics(i); - if (semantics) { - ConstPtr notation - = semantics->notation(); - if (!notation.isNull()) { - defineNotation(notation.pointer()); - typeString = "NOTATION"; - } - else { - size_t nEntities = semantics->nEntities(); - if (nEntities) { - typeString = "ENTITY"; - if (!outputEntity_) - for (size_t i = 0; i < nEntities; i++) { - const Entity *entity = semantics->entity(i).pointer(); - if (!markEntity(entity)) - defineEntity(entity); - } - } - } - } - if (outputId_ && attributes.id(i)) - typeString = "ID"; - startAttribute(attributes.name(i), code, ownerName); - os() << typeString << space << *string << nl; - } - break; - case AttributeValue::cdata: - { - startAttribute(attributes.name(i), code, ownerName); - os() << "CDATA "; - TextIter iter(*text); - TextItem::Type type; - const Char *p; - size_t length; - const Location *loc; - while (iter.next(type, p, length, loc)) - switch (type) { - case TextItem::data: - case TextItem::cdata: - outputString(p, length); - break; - case TextItem::sdata: - os() << "\\|"; - outputString(p, length); - os() << "\\|"; - break; - default: - break; - } - os() << nl; - } - break; - } - } - } -} - -void SgmlsEventHandler::startAttribute(const StringC &name, - char code, - const StringC *ownerName) -{ - os() << code; - if (ownerName) - os() << *ownerName << space; - os() << name << space; -} - -void SgmlsEventHandler::endElement(EndElementEvent *event) -{ - flushData(); - if (haveLinkProcess_) - linkProcess_.endElement(); - outputLocation(event->location()); - os() << endElementCode << event->name() << nl; - delete event; -} - -void SgmlsEventHandler::externalDataEntity(ExternalDataEntityEvent *event) -{ - currentLocation_ = event->location(); - outputLocation(event->location()); - flushData(); - if (!outputEntity_ && !markEntity(event->entity())) - defineExternalDataEntity(event->entity()); - currentLocation_.clear(); - os() << referenceEntityCode << event->entity()->name() << nl; - delete event; -} - -void SgmlsEventHandler::subdocEntity(SubdocEntityEvent *event) -{ - currentLocation_ = event->location(); - outputLocation(event->location()); - flushData(); - const SubdocEntity *entity = event->entity(); - if (!outputEntity_ && !markEntity(entity)) - defineSubdocEntity(entity); - currentLocation_.clear(); - os() << startSubdocCode << entity->name() << nl; - SgmlParser::Params params; - params.subdocInheritActiveLinkTypes = 1; - params.subdocReferenced = 1; - params.origin = event->entityOrigin()->copy(); - params.parent = parser_; - params.sysid = entity->externalId().effectiveSystemId(); - params.entityType = SgmlParser::Params::subdoc; - SgmlParser parser(params); - SgmlsSubdocState oldState; - SgmlsSubdocState::swap(oldState); - SgmlsSubdocState::init(&parser); - parser.parseAll(*this); - oldState.swap(*this); - os() << endSubdocCode << entity->name() << nl; - delete event; -} - -void SgmlsEventHandler::defineEntity(const Entity *entity) -{ - const InternalEntity *internalEntity = entity->asInternalEntity(); - if (internalEntity) - defineInternalEntity(internalEntity); - else { - switch (entity->dataType()) { - case Entity::cdata: - case Entity::sdata: - case Entity::ndata: - defineExternalDataEntity(entity->asExternalDataEntity()); - break; - case Entity::subdoc: - defineSubdocEntity(entity->asSubdocEntity()); - break; - case Entity::sgmlText: - defineExternalTextEntity(entity->asExternalEntity()); - break; - default: - CANNOT_HAPPEN(); - } - } -} - -void SgmlsEventHandler::defineExternalDataEntity(const ExternalDataEntity *entity) -{ - const Notation *notation = entity->notation(); - defineNotation(notation); - externalId(entity->externalId()); - const char *typeString; - switch (entity->dataType()) { - case Entity::cdata: - typeString = "CDATA"; - break; - case Entity::sdata: - typeString = "SDATA"; - break; - case Entity::ndata: - typeString = "NDATA"; - break; - default: - CANNOT_HAPPEN(); - } - os() << defineExternalEntityCode << entity->name() - << space << typeString - << space << notation->name() - << nl; - attributes(entity->attributes(), dataAttributeCode, &entity->name()); -} - -void SgmlsEventHandler::defineSubdocEntity(const SubdocEntity *entity) -{ - externalId(entity->externalId()); - os() << defineSubdocEntityCode << entity->name() << nl; -} - -void SgmlsEventHandler::defineExternalTextEntity(const ExternalEntity *entity) -{ - externalId(entity->externalId()); - os() << defineExternalTextEntityCode << entity->name() << nl; -} - -void SgmlsEventHandler::defineInternalEntity(const InternalEntity *entity) -{ - os() << defineInternalEntityCode << entity->name() << space; - const char *s; - switch (entity->dataType()) { - case Entity::sdata: - s = "SDATA"; - break; - case Entity::cdata: - s = "CDATA"; - break; - case Entity::sgmlText: - s = "TEXT"; - break; - case Entity::pi: - s = "PI"; - break; - default: - CANNOT_HAPPEN(); - } - os() << s << space; - outputString(entity->string()); - os() << nl; -} - -void SgmlsEventHandler::defineNotation(const Notation *notation) -{ - if (markNotation(notation)) - return; - externalId(notation->externalId(), outputNotationSysid_); - os() << defineNotationCode << notation->name() << nl; -} - -void SgmlsEventHandler::externalId(const ExternalId &id, Boolean outputFile) -{ - const StringC *str = id.publicIdString(); - if (str) { - os() << pubidCode; - outputString(*str); - os() << nl; - } - str = id.systemIdString(); - if (str) { - os() << sysidCode; - outputString(*str); - os() << nl; - } - if (outputFile && id.effectiveSystemId().size()) { - os() << fileCode; - outputString(id.effectiveSystemId()); - os() << nl; - } -} - -Boolean SgmlsEventHandler::markEntity(const Entity *entity) -{ - return definedEntities_.add(entity->name()); -} - -Boolean SgmlsEventHandler::markNotation(const Notation *notation) -{ - return definedNotations_.add(notation->name()); -} - -void SgmlsEventHandler::outputString(const Char *p, size_t n) -{ - for (; n > 0; p++, n--) { - switch (*p) { - case '\\': // FIXME we're punning Chars and chars - os() << "\\\\"; - break; - case re: - os() << "\\n"; - if (outputLine_ && haveData_) - lastLineno_++; - break; - default: - // FIXME not clear what to do here given possibility of wide characters - if (*p < 040) { - static const char digits[] = "0123456789"; - os() << "\\0" << digits[*p / 8] << digits[*p % 8]; - } - else - os().put(*p); - break; - } - } -} - -void SgmlsEventHandler::escape(OutputCharStream &s, Char c) -{ - s << "\\#" << (unsigned long)c << ";"; -} - -void SgmlsEventHandler::outputLocation1(const Location &loc) -{ - const Origin *origin = loc.origin().pointer(); - const InputSourceOrigin *inputSourceOrigin; - const ExternalInfo *info; - Index index = loc.index(); - for (;;) { - if (!origin) - return; - inputSourceOrigin = origin->asInputSourceOrigin(); - if (inputSourceOrigin) { - info = inputSourceOrigin->externalInfo(); - if (info) - break; - } - const Location &loc = origin->parent(); - index = loc.index(); - origin = loc.origin().pointer(); - } - Offset off = inputSourceOrigin->startOffset(index); - StorageObjectLocation soLoc; - if (!ExtendEntityManager::externalize(info, off, soLoc)) - return; - if (soLoc.lineNumber == (unsigned long)-1) - return; - if (soLoc.storageObjectSpec == lastSos_) { - if (soLoc.lineNumber == lastLineno_) - return; - flushData(); - os() << locationCode << soLoc.lineNumber << nl; - lastLineno_ = soLoc.lineNumber; - } - else { - flushData(); - os() << locationCode << soLoc.lineNumber << space; - outputString(soLoc.storageObjectSpec->id); - os() << nl; - lastLineno_ = soLoc.lineNumber; - lastSos_ = soLoc.storageObjectSpec; - lastLoc_ = loc; // make sure lastSos_ doesn't get freed - } -} - -void SgmlsEventHandler::dispatchMessage(Message &msg) -{ - dispatchMessage((const Message &) msg); -} - -void SgmlsEventHandler::dispatchMessage(const Message &msg) -{ - if (!cancelled()) { - noteMessage(msg); - messenger_->dispatchMessage(msg); - } -} - -void SgmlsEventHandler::initMessage(Message &msg) -{ - msg.loc = currentLocation_; -} - -SgmlsSubdocState::SgmlsSubdocState() -: haveLinkProcess_(0), parser_(0) -{ -} - -SgmlsSubdocState::SgmlsSubdocState(const SgmlParser *parser) -: haveLinkProcess_(0), parser_(parser) -{ -} - -void SgmlsSubdocState::init(const SgmlParser *parser) -{ - parser_ = parser; - definedNotations_.clear(); - definedEntities_.clear(); - haveLinkProcess_ = 0; - linkProcess_.clear(); -} - -void SgmlsSubdocState::swap(SgmlsSubdocState &to) -{ - { - const SgmlParser *tem = to.parser_; - to.parser_ = parser_; - parser_ = tem; - } - { - Boolean tem = to.haveLinkProcess_; - to.haveLinkProcess_ = haveLinkProcess_; - haveLinkProcess_ = tem; - } - linkProcess_.swap(to.linkProcess_); - definedNotations_.swap(to.definedNotations_); - definedEntities_.swap(to.definedEntities_); -} - -#ifdef SP_NAMESPACE -} -#endif diff --git a/cde/programs/nsgmls/SgmlsEventHandler.h b/cde/programs/nsgmls/SgmlsEventHandler.h deleted file mode 100644 index 8e3f82132..000000000 --- a/cde/programs/nsgmls/SgmlsEventHandler.h +++ /dev/null @@ -1,161 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: SgmlsEventHandler.h /main/1 1996/07/29 17:04:25 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#ifndef SgmlsEventHandler_INCLUDED -#define SgmlsEventHandler_INCLUDED 1 - -#include -#include "Event.h" -#include "Boolean.h" -#include "StringC.h" -#include "OutputCharStream.h" -#include "StringSet.h" -#include "Location.h" -#include "Syntax.h" -#include "Sd.h" -#include "Ptr.h" -#include "LinkProcess.h" -#include "Message.h" -#include "ErrorCountEventHandler.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -class SgmlParser; -struct StorageObjectSpec; - -class SgmlsSubdocState { -public: - SgmlsSubdocState(); - SgmlsSubdocState(const SgmlParser *); - void init(const SgmlParser *); - void swap(SgmlsSubdocState &); -protected: - const SgmlParser *parser_; - StringSet definedEntities_; - StringSet definedNotations_; - Boolean haveLinkProcess_; - LinkProcess linkProcess_; -private: - SgmlsSubdocState(const SgmlsSubdocState &); // undefined - void operator=(const SgmlsSubdocState &); // undefined -}; - -class SgmlsEventHandler : public ErrorCountEventHandler, - private SgmlsSubdocState, private Messenger { -public: - enum { - outputLine = 01, - outputEntity = 02, - outputId = 04, - outputIncluded = 010, - outputNotationSysid = 020 - }; - - SgmlsEventHandler(const SgmlParser *, - OutputCharStream *, - Messenger *, - unsigned outputFlags); - ~SgmlsEventHandler(); - void data(DataEvent *); - void startElement(StartElementEvent *); - void endElement(EndElementEvent *); - void pi(PiEvent *); - void sdataEntity(SdataEntityEvent *); - void externalDataEntity(ExternalDataEntityEvent *); - void subdocEntity(SubdocEntityEvent *); - void appinfo(AppinfoEvent *); - void uselink(UselinkEvent *); - void sgmlDecl(SgmlDeclEvent *); - void endProlog(EndPrologEvent *); - void message(MessageEvent *); - void entityDefaulted(EntityDefaultedEvent *event); -protected: - void dispatchMessage(const Message &); - void dispatchMessage(Message &); - void initMessage(Message &); -private: - SgmlsEventHandler(const SgmlsEventHandler &); // undefined - void operator=(const SgmlsEventHandler &); // undefined - - void attributes(const AttributeList &attributes, char code, - const StringC *ownerName); - void startAttribute(const StringC &name, char code, - const StringC *ownerName); - void defineEntity(const Entity *entity); - void defineExternalDataEntity(const ExternalDataEntity *entity); - void defineSubdocEntity(const SubdocEntity *entity); - void defineExternalTextEntity(const ExternalEntity *entity); - void defineInternalEntity(const InternalEntity *entity); - void defineNotation(const Notation *notation); - void externalId(const ExternalId &id, Boolean outputFile = 1); - Boolean markEntity(const Entity *); - Boolean markNotation(const Notation *); - void startData(); - void flushData(); - - void outputLocation(const Location &loc); - void outputLocation1(const Location &loc); - void outputString(const StringC &str); - void outputString(const Char *, size_t); - static void escape(OutputCharStream &, Char); - - OutputCharStream &os(); - - Messenger *messenger_; - Location currentLocation_; - OutputCharStream *os_; - Boolean haveData_; - ConstPtr sd_; - ConstPtr syntax_; - const StorageObjectSpec *lastSos_; - unsigned long lastLineno_; - Location lastLoc_; - PackedBoolean outputLine_; - PackedBoolean outputIncluded_; - PackedBoolean outputEntity_; - PackedBoolean outputId_; - PackedBoolean outputNotationSysid_; -}; - -inline -void SgmlsEventHandler::outputString(const StringC &str) -{ - outputString(str.data(), str.size()); -} - -inline -OutputCharStream &SgmlsEventHandler::os() -{ - return *os_; -} - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* not SgmlsEventHandler_INCLUDED */ diff --git a/cde/programs/nsgmls/ShortReferenceMap.C b/cde/programs/nsgmls/ShortReferenceMap.C deleted file mode 100644 index 59cda8add..000000000 --- a/cde/programs/nsgmls/ShortReferenceMap.C +++ /dev/null @@ -1,58 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: ShortReferenceMap.C /main/1 1996/07/29 17:04:29 cde-hp $ */ -// Copyright (c) 1995 James Clark -// See the file COPYING for copying permission. - -#ifdef __GNUG__ -#pragma implementation -#endif - -#include "splib.h" -#include "ShortReferenceMap.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -ShortReferenceMap::ShortReferenceMap() -: Named(StringC()), used_(0) -{ -} - -ShortReferenceMap::ShortReferenceMap(const StringC &name) -: Named(name), used_(false) -{ -} - -void ShortReferenceMap::setNameMap(Vector &map) -{ - map.swap(nameMap_); - // Make sure we know it's defined. - if (nameMap_.size() == 0) - nameMap_.resize(1); -} - -#ifdef SP_NAMESPACE -} -#endif diff --git a/cde/programs/nsgmls/ShortReferenceMap.h b/cde/programs/nsgmls/ShortReferenceMap.h deleted file mode 100644 index d37e02806..000000000 --- a/cde/programs/nsgmls/ShortReferenceMap.h +++ /dev/null @@ -1,127 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: ShortReferenceMap.h /main/1 1996/07/29 17:04:33 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#ifndef ShortReferenceMap_INCLUDED -#define ShortReferenceMap_INCLUDED 1 -#ifdef __GNUG__ -#pragma interface -#endif - -#include "Vector.h" -#include "Vector.h" -#include "StringC.h" -#include "Named.h" -#include "Boolean.h" -#include "Entity.h" -#include "Ptr.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -class SP_API ShortReferenceMap : public Named { -public: - ShortReferenceMap(); - ShortReferenceMap(const StringC &); - Boolean defined() const; - void setNameMap(Vector &map); - void setEntityMap(Vector > &map); - Boolean lookup(int i, const StringC *&) const; - const StringC *entityName(size_t i) const; - const ConstPtr &entity(size_t i) const; - Boolean used() const; - void setUsed(); - const Location &defLocation() const; - void setDefLocation(const Location &); -private: - ShortReferenceMap(const ShortReferenceMap &); // undefined - void operator=(const ShortReferenceMap &); // undefined - Vector nameMap_; - Vector > entityMap_; - ConstPtr nullEntity_; - Boolean used_; - Location defLocation_; -}; - -inline -Boolean ShortReferenceMap::defined() const -{ - return nameMap_.size() > 0; -} - -inline -const StringC *ShortReferenceMap::entityName(size_t i) const -{ - if (i < nameMap_.size() && nameMap_[i].size() != 0) - return &nameMap_[i]; - else - return 0; -} - -inline -const ConstPtr &ShortReferenceMap::entity(size_t i) const -{ - if (i < entityMap_.size()) - return entityMap_[i]; - else - return nullEntity_; -} - -inline -void ShortReferenceMap::setEntityMap(Vector > &map) -{ - map.swap(entityMap_); -} - -inline -Boolean ShortReferenceMap::used() const -{ - return used_; -} - -inline -void ShortReferenceMap::setUsed() -{ - used_ = 1; -} - -inline -void ShortReferenceMap::setDefLocation(const Location &loc) -{ - defLocation_ = loc; -} - -inline -const Location &ShortReferenceMap::defLocation() const -{ - return defLocation_; -} - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* not ShortReferenceMap_INCLUDED */ diff --git a/cde/programs/nsgmls/SrInfo.h b/cde/programs/nsgmls/SrInfo.h deleted file mode 100644 index 15661b62c..000000000 --- a/cde/programs/nsgmls/SrInfo.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: SrInfo.h /main/1 1996/07/29 17:04:38 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#ifndef SrInfo_INCLUDED -#define SrInfo_INCLUDED - -#include "types.h" -#include "StringOf.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -struct SrInfo { - String chars; - int bSequenceLength; - String chars2; -}; - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* not SrInfo_INCLUDED */ diff --git a/cde/programs/nsgmls/StdioStorage.C b/cde/programs/nsgmls/StdioStorage.C deleted file mode 100644 index 0b4cbdc04..000000000 --- a/cde/programs/nsgmls/StdioStorage.C +++ /dev/null @@ -1,179 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: StdioStorage.C /main/1 1996/07/29 17:04:42 cde-hp $ */ -// Copyright (c) 1994, 1995 James Clark -// See the file COPYING for copying permission. - -#ifdef __GNUG__ -#pragma implementation -#endif - -#include "splib.h" -#include "StdioStorage.h" -#include "Message.h" -#include "types.h" -#include "ErrnoMessageArg.h" -#include "StringOf.h" -#include "StringC.h" -#include "CodingSystem.h" - -#include "StdioStorageMessages.h" - -#include -#include -#include -#include - -#ifndef SEEK_SET -#define SEEK_SET 0 -#endif - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -class StdioStorageObject : public StorageObject { -public: - StdioStorageObject(FILE *fp, const StringC &filename); - ~StdioStorageObject(); - Boolean read(char *buf, size_t bufSize, Messenger &mgr, size_t &nread); - Boolean rewind(Messenger &mgr); - size_t getBlockSize() const; -private: - enum ErrorIndex { - invalidErrorIndex, - fopenFailed, - readError, - seekError - }; - void error(Messenger &mgr, const MessageType2 &, int err); - - FILE *fp_; - StringC filename_; - String filenameBytes_; -}; - -StdioStorageManager::StdioStorageManager(const char *type, - const UnivCharsetDesc &filenameCharset, - const OutputCodingSystem *filenameCodingSystem) -: IdStorageManager(filenameCharset), - type_(type), - filenameCodingSystem_(filenameCodingSystem) -{ -} - -StorageObject *StdioStorageManager::makeStorageObject(const StringC &str, - const StringC &, - Boolean, - Boolean, - Messenger &mgr, - StringC &filename) -{ - filename = str; - String filenameBytes = filenameCodingSystem_->convertOut(filename); - errno = 0; - FILE *fp = fopen(filenameBytes.data(), "r"); - if (!fp) { - ParentLocationMessenger(mgr).message(StdioStorageMessages::openFailed, - StringMessageArg(filename), - ErrnoMessageArg(errno)); - - return 0; - } - return new StdioStorageObject(fp, filename); -} - -const char *StdioStorageManager::type() const -{ - return type_; -} - -StdioStorageObject::StdioStorageObject(FILE *fp, const StringC &filename) -: fp_(fp), filename_(filename) -{ -} - -StdioStorageObject::~StdioStorageObject() -{ - if (fp_) { - fclose(fp_); - fp_ = 0; - } -} - -Boolean StdioStorageObject::rewind(Messenger &mgr) -{ - if (fp_) { - errno = 0; - if (fseek(fp_, 0L, SEEK_SET) < 0) { - error(mgr, StdioStorageMessages::seekFailed, errno); - return 0; - } - return 1; - } - return 1; -} - -size_t StdioStorageObject::getBlockSize() const -{ - return BUFSIZ; -} - -Boolean StdioStorageObject::read(char *buf, size_t bufSize, Messenger &mgr, - size_t &nread) -{ - if (!fp_) - return 0; - errno = 0; - size_t n = 0; - FILE *fp = fp_; - while (n < bufSize) { - int c = getc(fp); - if (c == EOF) { - if (ferror(fp)) { - error(mgr, StdioStorageMessages::readFailed, errno); - (void)fclose(fp); - return 0; - } - fclose(fp); - fp_ = 0; - break; - } - buf[n++] = c; - } - nread = n; - return n > 0; -} - -void StdioStorageObject::error(Messenger &mgr, - const MessageType2 &msg, - int err) -{ - ParentLocationMessenger(mgr).message(msg, - StringMessageArg(filename_), - ErrnoMessageArg(err)); -} - -#ifdef SP_NAMESPACE -} -#endif diff --git a/cde/programs/nsgmls/StdioStorage.h b/cde/programs/nsgmls/StdioStorage.h deleted file mode 100644 index 2319007dc..000000000 --- a/cde/programs/nsgmls/StdioStorage.h +++ /dev/null @@ -1,70 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: StdioStorage.h /main/1 1996/07/29 17:04:47 cde-hp $ */ -// Copyright (c) 1994, 1995 James Clark -// See the file COPYING for copying permission. - -#ifndef StdioStorage_INCLUDED -#define StdioStorage_INCLUDED 1 -#ifdef __GNUG__ -#pragma interface -#endif - -#include "StorageManager.h" -#include "DescriptorManager.h" -#include "StringC.h" -#include "CharsetInfo.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -class Messenger; -class CharsetInfo; -class UnivCharsetDesc; -class OutputCodingSystem; - -class SP_API StdioStorageManager : public IdStorageManager { -public: - StdioStorageManager(const char *type, - const UnivCharsetDesc &filenameCharset, - const OutputCodingSystem *filenameCodingSystem); - StorageObject *makeStorageObject(const StringC &id, - const StringC &baseId, - Boolean, - Boolean mayRewind, - Messenger &, - StringC &foundId); - const char *type() const; -private: - StdioStorageManager(const StdioStorageManager &); // undefined - void operator=(const StdioStorageManager &); // undefined - const OutputCodingSystem *filenameCodingSystem_; - const char *type_; -}; - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* not StdioStorage_INCLUDED */ diff --git a/cde/programs/nsgmls/StdioStorageMessages.h b/cde/programs/nsgmls/StdioStorageMessages.h deleted file mode 100644 index 1eafe892b..000000000 --- a/cde/programs/nsgmls/StdioStorageMessages.h +++ /dev/null @@ -1,77 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: StdioStorageMessages.h /main/1 1996/07/29 17:04:53 cde-hp $ */ -// This file was automatically generated from StdioStorageMessages.msg by msggen.pl. -#include "Message.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -struct StdioStorageMessages { - // 2400 - static const MessageType2 openFailed; - // 2401 - static const MessageType2 readFailed; - // 2402 - static const MessageType2 seekFailed; -}; -const MessageType2 StdioStorageMessages::openFailed( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -2400 -#ifndef SP_NO_MESSAGE_TEXT -,"cannot open %1 (%2)" -#endif -); -const MessageType2 StdioStorageMessages::readFailed( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -2401 -#ifndef SP_NO_MESSAGE_TEXT -,"\"error reading %1 (%2)" -#endif -); -const MessageType2 StdioStorageMessages::seekFailed( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -2402 -#ifndef SP_NO_MESSAGE_TEXT -,"error seeking %1 (%2)" -#endif -); -#ifdef SP_NAMESPACE -} -#endif diff --git a/cde/programs/nsgmls/StorageManager.C b/cde/programs/nsgmls/StorageManager.C deleted file mode 100644 index 2079bfe02..000000000 --- a/cde/programs/nsgmls/StorageManager.C +++ /dev/null @@ -1,122 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: StorageManager.C /main/1 1996/07/29 17:04:57 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#ifdef __GNUG__ -#pragma implementation -#endif -#include "splib.h" -#include "StorageManager.h" -#define DEFAULT_BLOCK_SIZE 1024 - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -StorageObject::StorageObject() -{ -} - -StorageObject::~StorageObject() -{ -} - -void StorageObject::willNotRewind() -{ -} - -size_t StorageObject::getBlockSize() const -{ - return DEFAULT_BLOCK_SIZE; -} - -StorageManager::StorageManager() -{ -} - -StorageManager::~StorageManager() -{ -} - -Boolean StorageManager::inheritable() const -{ - return 1; -} - -Boolean StorageManager::resolveRelative(const StringC &, StringC &, - Boolean) const -{ - return 1; -} - -Boolean StorageManager::guessIsId(const StringC &, const CharsetInfo &) const -{ - return 0; -} - -Boolean StorageManager::transformNeutral(StringC &, Boolean, Messenger &) const -{ - return 0; -} - -const InputCodingSystem *StorageManager::requiredCodingSystem() const -{ - return 0; -} - -Boolean StorageManager::requiresCr() const -{ - return 0; -} - -const CharsetInfo *StorageManager::idCharset() const -{ - return 0; -} - -const StringC *StorageManager::reString() const -{ - return 0; -} - -IdStorageManager::IdStorageManager(const UnivCharsetDesc &idCharset) -: idCharset_(idCharset) -{ -} - -const CharsetInfo *IdStorageManager::idCharset() const -{ - return &idCharset_; -} - -const StringC *IdStorageManager::reString() const -{ - return &reString_; -} - - -#ifdef SP_NAMESPACE -} -#endif diff --git a/cde/programs/nsgmls/StorageManager.h b/cde/programs/nsgmls/StorageManager.h deleted file mode 100644 index 6e8321805..000000000 --- a/cde/programs/nsgmls/StorageManager.h +++ /dev/null @@ -1,112 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: StorageManager.h /main/1 1996/07/29 17:05:01 cde-hp $ */ -// Copyright (c) 1994, 1995 James Clark -// See the file COPYING for copying permission. - -#ifndef StorageManager_INCLUDED -#define StorageManager_INCLUDED 1 -#ifdef __GNUG__ -#pragma interface -#endif - -#include "StringC.h" -#include "types.h" -#include "CharsetInfo.h" -#include - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -class StorageManager; -class CharsetInfo; -class Messenger; -class InputCodingSystem; - -class SP_API StorageObject { -public: - StorageObject(); - virtual ~StorageObject(); - virtual Boolean read(char *buf, size_t bufSize, Messenger &, - size_t &nread) = 0; - virtual Boolean rewind(Messenger &) = 0; - virtual void willNotRewind(); - virtual size_t getBlockSize() const; -private: - StorageObject(const StorageObject &); // undefined - void operator=(const StorageObject &); // undefined -}; - -class SP_API StorageManager { -public: - StorageManager(); - virtual StorageObject *makeStorageObject(const StringC &specId, - const StringC &baseId, - Boolean search, - Boolean mayRewind, - Messenger &mgr, - StringC &actualId) = 0; - virtual const char *type() const = 0; - virtual Boolean inheritable() const; - virtual Boolean transformNeutral(StringC &, Boolean fold, Messenger &) const; - // Resolve a possibly relative ID by examining the base and specified IDs. - // Put the resolved ID in specID. - // Return 0 if it cannot be resolved yet becase the specified ID is relative - // and physical searching is required to resolve it and search is true; - // in this case the base will be passed to makeStorageObject. - // Otherwise return 1; in this case the base will be discarded, and the - // resolved ID will be passed to makeStorageObject. - virtual Boolean resolveRelative(const StringC &base, - StringC &specId, - Boolean search) const; - virtual Boolean guessIsId(const StringC &, const CharsetInfo &) const; - virtual const InputCodingSystem *requiredCodingSystem() const; - virtual Boolean requiresCr() const; - virtual ~StorageManager(); - virtual const CharsetInfo *idCharset() const; - virtual const StringC *reString() const; -private: - StorageManager(const StorageManager &); // undefined - void operator=(const StorageManager &); // undefined -}; - -class SP_API IdStorageManager : public StorageManager { -public: - IdStorageManager(const UnivCharsetDesc &idCharset); - const CharsetInfo *idCharset() const; - const StringC *reString() const; -protected: - StringC reString_; -private: - IdStorageManager(const IdStorageManager &); // undefined - void operator=(const IdStorageManager &); // undefined - - CharsetInfo idCharset_; -}; - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* not StorageManager_INCLUDED */ diff --git a/cde/programs/nsgmls/StorageObjectPosition.h b/cde/programs/nsgmls/StorageObjectPosition.h deleted file mode 100644 index 2f8028fc3..000000000 --- a/cde/programs/nsgmls/StorageObjectPosition.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: StorageObjectPosition.h /main/1 1996/07/29 17:05:06 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#ifndef StorageObjectPosition_INCLUDED -#define StorageObjectPosition_INCLUDED 1 - -#include "Boolean.h" -#include "types.h" -#include "Owner.h" -#include "CodingSystem.h" -#include - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -struct StorageObjectPosition { - StorageObjectPosition(); - // the number of RSs preceding line 1 of this storage object - // or -1 if this hasn't been computed yet. - size_t line1RS; - Owner decoder; - // Does the storage object start with an RS? - PackedBoolean startsWithRS; - // Were the RSs other than the first in the storage object inserted? - PackedBoolean insertedRSs; - Offset endOffset; -}; - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* not StorageObjectPosition_INCLUDED */ diff --git a/cde/programs/nsgmls/StringC.h b/cde/programs/nsgmls/StringC.h deleted file mode 100644 index 2c72637d4..000000000 --- a/cde/programs/nsgmls/StringC.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: StringC.h /main/1 1996/07/29 17:05:10 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#ifndef StringC_INCLUDED -#define StringC_INCLUDED 1 - -#include "types.h" -#include "StringOf.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -typedef String StringC; - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* not StringC_INCLUDED */ diff --git a/cde/programs/nsgmls/StringOf.C b/cde/programs/nsgmls/StringOf.C deleted file mode 100644 index 5b088021f..000000000 --- a/cde/programs/nsgmls/StringOf.C +++ /dev/null @@ -1,169 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: StringOf.C /main/1 1996/07/29 17:05:16 cde-hp $ */ -// Copyright (c) 1994, 1996 James Clark -// See the file COPYING for copying permission. - -#ifndef StringOf_DEF_INCLUDED -#define StringOf_DEF_INCLUDED 1 - -#include -#include - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -template -String::String(const T *ptr, size_t length) -: length_(length), alloc_(length) -{ - if (length) { - ptr_ = new T[length]; - memcpy(ptr_, ptr, length*sizeof(T)); - } - else - ptr_ = 0; -} - -template -String::String() -: ptr_(0), length_(0), alloc_(0) -{ -} - -template -String::String(const String &s) -: length_(s.length_), alloc_(s.length_) -{ - if (length_) { - ptr_ = new T[length_]; - memcpy(ptr_, s.ptr_, length_*sizeof(T)); - } - else - ptr_ = 0; -} - -template -String &String::operator=(const String &s) -{ - if (&s != this) { - if (s.length_ > alloc_) { - if (ptr_) - delete [] ptr_; - ptr_ = new T[alloc_ = s.length_]; - } - memcpy(ptr_, s.ptr_, s.length_*sizeof(T)); - length_ = s.length_; - } - return *this; -} - -template -String &String::insert(size_t i, const String &s) -{ - if (length_ + s.length_ > alloc_) - grow(s.length_); - for (size_t n = length_ - i; n > 0; n--) - ptr_[i + n - 1 + s.length_] = ptr_[i + n - 1]; - length_ += s.length_; - memcpy(ptr_ + i, s.ptr_, s.length_*sizeof(T)); - return *this; -} - -template -String &String::append(const T *p, size_t length) -{ - if (length_ + length > alloc_) - grow(length); - memcpy(ptr_ + length_, p, length*sizeof(T)); - length_ += length; - return *this; -} - -template -void String::grow(size_t n) -{ - if (alloc_ < n) - alloc_ += n + 16; - else - alloc_ += alloc_; - T *s = new T[alloc_]; - memcpy(s, ptr_, length_*sizeof(T)); - delete [] ptr_; - ptr_ = s; -} - -template -void String::swap(String &to) -{ - { - T *tem = to.ptr_; - to.ptr_ = ptr_; - ptr_ = tem; - } - { - size_t tem = to.length_; - to.length_ = length_; - length_ = tem; - } - { - size_t tem = to.alloc_; - to.alloc_ = alloc_; - alloc_ = tem; - } -} - -template -String &String::assign(const T *p, size_t n) -{ - if (alloc_ < n) { - if (ptr_) - delete [] ptr_; - ptr_ = new T[alloc_ = n]; - } - length_ = n; - for(T *to = ptr_; n > 0; n--, to++, p++) - *to = *p; - return *this; -} - -template -void String::resize(size_t n) -{ - if (alloc_ < n) { - T *oldPtr_ = ptr_; - ptr_ = new T[alloc_ = n]; - if (length_ > 0) { - memcpy(ptr_, oldPtr_, length_*sizeof(T)); - delete [] oldPtr_; - } - } - length_ = n; -} - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* not StringOf_DEF_INCLUDED */ diff --git a/cde/programs/nsgmls/StringOf.h b/cde/programs/nsgmls/StringOf.h deleted file mode 100644 index 49f0d6b6e..000000000 --- a/cde/programs/nsgmls/StringOf.h +++ /dev/null @@ -1,102 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: StringOf.h /main/1 1996/07/29 17:05:21 cde-hp $ */ -// Copyright (c) 1994, 1996 James Clark -// See the file COPYING for copying permission. - -#ifndef StringOf_INCLUDED -#define StringOf_INCLUDED 1 - -// The file is called StringOf to distinguish it from string.h on -// case-insensitive file systems. - -// This offers a subset of the interface offered by the standard C++ -// basic_string class as defined in the Jan 96 WP. -// Code in SP currently assumes that size_type is size_t. - -#include -#include -#include "Boolean.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -template -class String { -public: - typedef size_t size_type; - typedef T *iterator; - typedef const T *const_iterator; - String(); - ~String() { if (ptr_) delete [] ptr_; } - String(const T *, size_t); - String(const String &); - String &operator=(const String &); - size_t size() const { return length_; } - String &assign(const T *, size_t); - String &insert(size_t i, const String &s); - void swap(String &str); - T operator[](size_t i) const { return ptr_[i]; } - T &operator[](size_t i) { return ptr_[i]; } - iterator begin() { return ptr_; } - const_iterator begin() const { return ptr_; } - const T *data() const { return ptr_; } - String &operator+=(T c) { - if (length_ >= alloc_) - grow(1); - ptr_[length_++] = c; - return *this; - } - String &operator+=(const String &s) { - append(s.ptr_, s.length_); - return *this; - } - String &append(const T *, size_t); - Boolean operator==(const String &s) const { - return (length_ == s.length_ - && (length_ == 0 - || (*ptr_ == *s.ptr_ - && (memcmp(ptr_ + 1, s.ptr_ + 1, (length_ - 1)*sizeof(T)) - == 0)))); - } - Boolean operator!=(const String &str) const { - return !(*this == str); - } - void resize(size_t n); -private: - void grow(size_t); - T *ptr_; - size_t length_; - size_t alloc_; -}; - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* not StringOf_INCLUDED */ - -#ifdef SP_DEFINE_TEMPLATES -#include "StringOf.C" -#endif diff --git a/cde/programs/nsgmls/StringResource.h b/cde/programs/nsgmls/StringResource.h deleted file mode 100644 index 204e7c1b5..000000000 --- a/cde/programs/nsgmls/StringResource.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: StringResource.h /main/1 1996/07/29 17:05:26 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#ifndef StringResource_INCLUDED -#define StringResource_INCLUDED 1 - -#include "StringOf.h" -#include "Resource.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -template -class StringResource : public String, public Resource { -public: - StringResource(const String &s) : String(s) { } -}; - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* not StringResource_INCLUDED */ diff --git a/cde/programs/nsgmls/StringSet.C b/cde/programs/nsgmls/StringSet.C deleted file mode 100644 index d931e175e..000000000 --- a/cde/programs/nsgmls/StringSet.C +++ /dev/null @@ -1,56 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: StringSet.C /main/1 1996/07/29 17:05:31 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#include "config.h" -#include "StringSet.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -StringSet::StringSet() -{ -} - -Boolean StringSet::add(const StringC &str) -{ - StringC *p = table_.lookup(str); - if (p) - return 1; - p = new StringC(str); - table_.insert(p); - return 0; -} - -void StringSet::swap(StringSet &to) -{ - table_.swap(to.table_); -} - - -#ifdef SP_NAMESPACE -} -#endif diff --git a/cde/programs/nsgmls/StringSet.h b/cde/programs/nsgmls/StringSet.h deleted file mode 100644 index f2b537b3c..000000000 --- a/cde/programs/nsgmls/StringSet.h +++ /dev/null @@ -1,66 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: StringSet.h /main/1 1996/07/29 17:05:35 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#ifndef StringSet_INCLUDED -#define StringSet_INCLUDED 1 - -#include "StringC.h" -#include "Hash.h" -#include "Boolean.h" -#include "OwnerTable.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -class StringSetKey { -public: - static inline const StringC &key(const StringC &str) { return str; } -}; - -class StringSet { -public: - StringSet(); - Boolean add(const StringC &); // return 1 if already there - void swap(StringSet &); - void clear(); -private: - StringSet(const StringSet &); // undefined - void operator=(const StringSet &); // undefined - OwnerTable table_; -}; - -inline -void StringSet::clear() -{ - table_.clear(); -} - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* not StringSet_INCLUDED */ diff --git a/cde/programs/nsgmls/StringVectorMessageArg.C b/cde/programs/nsgmls/StringVectorMessageArg.C deleted file mode 100644 index bbb574963..000000000 --- a/cde/programs/nsgmls/StringVectorMessageArg.C +++ /dev/null @@ -1,60 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: StringVectorMessageArg.C /main/1 1996/07/29 17:05:39 cde-hp $ */ -// Copyright (c) 1996 James Clark -// See the file COPYING for copying permission. - -#ifdef __GNUG__ -#pragma implementation -#endif -#include "splib.h" -#include "StringVectorMessageArg.h" -#include "MessageBuilder.h" -#include "ParserMessages.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -StringVectorMessageArg::StringVectorMessageArg(const Vector &v) -: v_(v) -{ -} - -MessageArg *StringVectorMessageArg::copy() const -{ - return new StringVectorMessageArg(*this); -} - -void StringVectorMessageArg::append(MessageBuilder &builder) const -{ - for (size_t i = 0; i < v_.size(); i++) { - if (i > 0) - builder.appendFragment(ParserMessages::listSep); - builder.appendChars(v_[i].data(), v_[i].size()); - } -} - -#ifdef SP_NAMESPACE -} -#endif diff --git a/cde/programs/nsgmls/StringVectorMessageArg.h b/cde/programs/nsgmls/StringVectorMessageArg.h deleted file mode 100644 index 852d26df2..000000000 --- a/cde/programs/nsgmls/StringVectorMessageArg.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: StringVectorMessageArg.h /main/1 1996/07/29 17:05:44 cde-hp $ */ -// Copyright (c) 1996 James Clark -// See the file COPYING for copying permission. - -#ifndef StringVectorMessageArg_INCLUDED -#define StringVectorMessageArg_INCLUDED 1 - -#ifdef __GNUG__ -#pragma interface -#endif - -#include "MessageArg.h" -#include "StringC.h" -#include "Vector.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -class StringVectorMessageArg : public MessageArg { -public: - StringVectorMessageArg(const Vector &); - MessageArg *copy() const; - void append(MessageBuilder &) const; -private: - Vector v_; -}; - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* not StringVectorMessageArg_INCLUDED */ diff --git a/cde/programs/nsgmls/SubstTable.C b/cde/programs/nsgmls/SubstTable.C deleted file mode 100644 index ed48e0982..000000000 --- a/cde/programs/nsgmls/SubstTable.C +++ /dev/null @@ -1,112 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: SubstTable.C /main/1 1996/07/29 17:05:48 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#ifndef SubstTable_DEF_INCLUDED -#define SubstTable_DEF_INCLUDED 1 - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -template -SubstTable::SubstTable() -: pairsValid_(1) -{ -} - -template -void SubstTable::addSubst(T from, T to) -{ - if (table_.size() == 0) { - table_.resize(T(-1) + 1); - for (int i = 0; i < T(-1) + 1; i++) - table_[i] = i; - } - if (table_[from] != to) - pairsValid_ = 0; - table_[from] = to; -} - -template -String SubstTable::inverse(T ch) const -{ - if (!pairsValid_) { - const T *p = table_.data(); - size_t length = table_.size(); - for (size_t i = 0; i < length; i++) - if (p[i] != i) { - // FIXME use mutable if available - ((SubstTable *)this)->pairs_ += T(i); - ((SubstTable *)this)->pairs_ += p[i]; - } - ((SubstTable *)this)->pairsValid_ = 1; - } - const T *p = pairs_.data(); - if (!p) - return String(&ch, 1); - String result; - if (table_[ch] == ch) - result += ch; - for (size_t n = pairs_.size(); n > 0; n -= 2, p += 2) - if (p[1] == ch) - result += p[0]; - return result; -} - -template -void SubstTable::inverseTable(SubstTable &inv) const -{ - if (table_.size() == 0) { - inv.table_.resize(0); - inv.pairs_.resize(0); - inv.pairsValid_ = 1; - } - else { - if (inv.table_.size() == 0) - inv.table_.resize(T(-1) + 1); - int i; - for (i = 0; i < T(-1) + 1; i++) - inv.table_[i] = i; - inv.pairs_.resize(0); - inv.pairsValid_ = 0; - for (i = 0; i < T(-1) + 1; i++) - if (table_[i] != i) - inv.table_[table_[i]] = i; - } -} - -template -void SubstTable::subst(String &str) const -{ - for (size_t i = 0; i < str.size(); i++) - subst(str[i]); -} - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* not SubstTable_DEF_INCLUDED */ diff --git a/cde/programs/nsgmls/SubstTable.h b/cde/programs/nsgmls/SubstTable.h deleted file mode 100644 index 4ab70c0f7..000000000 --- a/cde/programs/nsgmls/SubstTable.h +++ /dev/null @@ -1,62 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: SubstTable.h /main/1 1996/07/29 17:05:53 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#ifndef SubstTable_INCLUDED -#define SubstTable_INCLUDED - -#include -#include "StringOf.h" -#include "Boolean.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -template -class SubstTable { -public: - SubstTable(); - void addSubst(T from, T to); - void subst(T &c) const { if (table_.size() > 0) c = table_[c]; } - void subst(String &) const; - T operator[](T c) const { return table_.size() > 0 ? table_[c] : c; } - String inverse(T) const; - void inverseTable(SubstTable &) const; -private: - String table_; - String pairs_; // mutable - Boolean pairsValid_; // mutable -}; - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* SubstTable_INCLUDED */ - -#ifdef SP_DEFINE_TEMPLATES -#include "SubstTable.C" -#endif diff --git a/cde/programs/nsgmls/Syntax.C b/cde/programs/nsgmls/Syntax.C deleted file mode 100644 index 22a0ad586..000000000 --- a/cde/programs/nsgmls/Syntax.C +++ /dev/null @@ -1,444 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: Syntax.C /main/2 1996/08/12 13:22:19 mgreess $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#ifdef __GNUG__ -#pragma implementation -#endif -#include "splib.h" -#include "Syntax.h" -#include "Sd.h" -#include "CharsetInfo.h" -#include "ISetIter.h" -#include "macros.h" -#include "MarkupScan.h" -#include "constant.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -const int Syntax::referenceQuantity_[] = { - 40, - 960, - 960, - 16, - 16, - 16, - 32, - 96, - 16, - 240, - 8, - 2, - 240, - 960, - 24 -}; - -Syntax::Syntax(const Sd &sd) -: generalSubst_(0), - entitySubst_(0), - categoryTable_(otherCategory), - shuncharControls_(0), - multicode_(0), - markupScanTable_(MarkupScan::normal), - namecaseGeneral_(false), - namecaseEntity_(false) -{ - static const char lcletter[] = "abcdefghijklmnopqrstuvwxyz"; - static const char ucletter[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; - int i; - for (i = 0; i < 26; i++) { - Char lc = sd.execToDoc(lcletter[i]); - Char uc = sd.execToDoc(ucletter[i]); - set_[nameStart] += lc; - set_[nameStart] += uc; - set_[minimumData] += lc; - set_[minimumData] += uc; - set_[significant] += lc; - set_[significant] += uc; - categoryTable_.setChar(lc, nameStartCategory); - categoryTable_.setChar(uc, nameStartCategory); - subst(lc, uc); - } - static const char digits[] = "0123456789"; - for (i = 0; i < 10; i++) { - Char c = sd.execToDoc(digits[i]); - set_[digit] += c; - set_[minimumData] += c; - set_[significant] += c; - categoryTable_.setChar(c, digitCategory); - } - static const char special[] = "'()+,-./:=?"; - for (i = 0; special[i] != '\0'; i++) { - Char c = sd.execToDoc(special[i]); - set_[minimumData] += c; - set_[significant] += c; - } - for (i = 0; i < nQuantity; i++) - quantity_[i] = referenceQuantity_[i]; - for (i = 0; i < 3; i++) - standardFunctionValid_[i] = 0; -} - - -Syntax::Syntax(const Syntax & syn) - : generalSubst_(syn.generalSubst_), - entitySubst_(syn.entitySubst_), - shunchar_(syn.shunchar_), - shuncharControls_(syn.shuncharControls_), - namecaseGeneral_(syn.namecaseGeneral_), - namecaseEntity_(syn.namecaseEntity_), - delimShortrefComplex_(syn.delimShortrefComplex_), - delimShortrefSimple_(syn.delimShortrefSimple_), - nameTable_(syn.nameTable_), - functionTable_(syn.functionTable_), - upperSubst_(syn.upperSubst_), - identitySubst_(syn.identitySubst_), - categoryTable_(syn.categoryTable_), - multicode_(syn.multicode_), - markupScanTable_(syn.markupScanTable_) -{ - int i; - - for (i = 0; i < nSet; i++) - set_[i] = syn.set_[i]; - - for (i = 0; i < 3; i++) { - standardFunction_[i] = syn.standardFunction_[i]; - standardFunctionValid_[i] = syn.standardFunctionValid_[i]; - } - - for (i = 0; i < nDelimGeneral; i++) - delimGeneral_[i] = syn.delimGeneral_[i]; - - for (i = 0; i < nNames; i++) - names_[i] = syn.names_[i]; - - for (i = 0; i < nQuantity; i++) - quantity_[i] = syn.quantity_[i]; -} - -void Syntax::addNameCharacters(const ISet &set) -{ - ISetIter iter(set); - Char min, max; - while (iter.next(min, max)) { - set_[nmchar].addRange(min, max); - set_[significant].addRange(min, max); - categoryTable_.setRange(min, max, otherNameCategory); - } -} - -void Syntax::addNameStartCharacters(const ISet &set) -{ - ISetIter iter(set); - Char min, max; - while (iter.next(min, max)) { - set_[nameStart].addRange(min, max); - set_[significant].addRange(min, max); - categoryTable_.setRange(min, max, nameStartCategory); - } -} - -void Syntax::addSubst(Char lc, Char uc) -{ - subst(lc, uc); -} - -void Syntax::setStandardFunction(StandardFunction f, Char c) -{ - standardFunction_[f] = c; - standardFunctionValid_[f] = 1; - set_[minimumData] += c; - set_[s] += c; - categoryTable_.setChar(c, sCategory); - set_[functionChar] += c; - set_[significant] += c; - switch (f) { - case fSPACE: - set_[blank] += c; - break; - case fRE: - case fRS: - break; - } -} - -void Syntax::enterStandardFunctionNames() -{ - static ReservedName name[3] = { - rRE, rRS, rSPACE - }; - for (int i = 0; i < 3; i++) - if (standardFunctionValid_[i]) - functionTable_.insert(reservedName(name[i]), standardFunction_[i]); -} - -void Syntax::setDelimGeneral(int i, const StringC &str) -{ - delimGeneral_[i] = str; - for (size_t j = 0; j < str.size(); j++) - set_[significant] += str[j]; -} - -void Syntax::addDelimShortref(const StringC &str, const CharsetInfo &charset) -{ - if (str.size() == 1 && str[0] != charset.execToDesc('B') && !isB(str[0])) - delimShortrefSimple_.add(str[0]); - else - delimShortrefComplex_.push_back(str); - for (size_t i = 0; i < str.size(); i++) - set_[significant] += str[i]; -} - -void Syntax::addDelimShortrefs(const ISet &shortrefChars, - const CharsetInfo &charset) -{ - ISetIter blankIter(set_[blank]); - Char min, max; - StringC specialChars; - while (blankIter.next(min, max)) { - do { - specialChars += min; - } while (min++ != max); - } - specialChars += charset.execToDesc('B'); - const ISet *simpleCharsPtr = &shortrefChars; - ISet simpleChars; - for (size_t i = 0; i < specialChars.size(); i++) - if (shortrefChars.contains(specialChars[i])) { - if (simpleCharsPtr != &simpleChars) { - simpleChars = shortrefChars; - simpleCharsPtr = &simpleChars; - } - simpleChars.remove(specialChars[i]); - } - ISetIter iter(*simpleCharsPtr); - while (iter.next(min, max)) { - delimShortrefSimple_.addRange(min, max); - set_[significant].addRange(min, max); - } -} - -void Syntax::addFunctionChar(const StringC &str, FunctionClass fun, Char c) -{ - switch (fun) { - case cFUNCHAR: - break; - case cSEPCHAR: - set_[s] += c; - categoryTable_.setChar(c, sCategory); - set_[blank] += c; - set_[sepchar] += c; - break; - case cMSOCHAR: - multicode_ = 1; - markupScanTable_.setChar(c, MarkupScan::out); - break; - case cMSICHAR: - // don't need to do anything special if we just have MSICHARs - markupScanTable_.setChar(c, MarkupScan::in); - break; - case cMSSCHAR: - multicode_ = 1; - markupScanTable_.setChar(c, MarkupScan::suppress); - break; - } - set_[functionChar] += c; - set_[significant] += c; - functionTable_.insert(str, c); -} - -void Syntax::setName(int i, const StringC &str) -{ - names_[i] = str; - nameTable_.insert(str, i); -} - -void Syntax::setNamecaseGeneral(Boolean b) -{ - namecaseGeneral_ = b; - generalSubst_ = b ? &upperSubst_ : &identitySubst_; -} - -void Syntax::setNamecaseEntity(Boolean b) -{ - namecaseEntity_ = b; - entitySubst_ = b ? &upperSubst_ : &identitySubst_; -} - -void Syntax::subst(Char from, Char to) -{ - upperSubst_.addSubst(from, to); -} - -void Syntax::addShunchar(Char c) -{ - shunchar_.add(c); -} - -Boolean Syntax::lookupReservedName(const StringC &str, - ReservedName *result) const -{ - const int *tem = nameTable_.lookup(str); - if (tem) { - *result = ReservedName(*tem); - return 1; - } - else - return 0; -} - -Boolean Syntax::lookupFunctionChar(const StringC &name, Char *result) const -{ - const Char *p = functionTable_.lookup(name); - if (p) { - *result = *p; - return 1; - } - else - return 0; -} - -#ifdef __GNUG__ -typedef HashTableIter Dummy_HashTableIter_StringC_Char; -#endif - -Boolean Syntax::charFunctionName(Char c, const StringC *&name) const -{ - HashTableIter iter(functionTable_); - const Char *cp; - while (iter.next(name, cp)) - if (*cp == c) - return 1; - return 0; -} - -Boolean Syntax::isValidShortref(const StringC &str) const -{ - if (str.size() == 1 && delimShortrefSimple_.contains(str[0])) - return 1; - for (size_t i = 0; i < delimShortrefComplex_.size(); i++) - if (str == delimShortrefComplex_[i]) - return 1; - return 0; -} - -void Syntax::implySgmlChar(const CharsetInfo &docCharset) -{ - docCharset.getDescSet(set_[sgmlChar]); - ISet invalid; - checkSgmlChar(docCharset, 0, invalid); - ISetIter iter(invalid); - WideChar min, max; - while (iter.next(min, max)) { - do { - if (min <= charMax) - set_[sgmlChar].remove(Char(min)); - } while (min++ != max); - } -} - -void Syntax::checkSgmlChar(const CharsetInfo &docCharset, - const ::SP_NAMESPACE_SCOPE Syntax *otherSyntax, - ISet &invalid) const -{ - ISetIter iter(shunchar_); - Char min, max; - while (iter.next(min, max)) { - if (min <= max) { - do { - if (!set_[significant].contains(min) - && (!otherSyntax || !otherSyntax->set_[significant].contains(min)) - && set_[sgmlChar].contains(min)) - invalid += min; - } while (min++ != max); - } - } - if (shuncharControls_) { - UnivChar i; - for (i = 0; i < 32; i++) - checkUnivControlChar(i, docCharset, otherSyntax, invalid); - for (i = 127; i < 160; i++) - checkUnivControlChar(i, docCharset, otherSyntax, invalid); - } -} - -void Syntax::checkUnivControlChar(UnivChar univChar, - const CharsetInfo &docCharset, - const ::SP_NAMESPACE_SCOPE Syntax *otherSyntax, - ISet &invalid) const -{ - WideChar c; - ISet set; - switch (docCharset.univToDesc(univChar, c, set)) { - case 0: - break; - case 1: - set += c; - // fall through - default: - { - ISetIter iter(set); - WideChar min, max; - while (iter.next(min, max)) { - do { - if (min > charMax) - break; - Char ch = Char(min); - if (!set_[significant].contains(ch) - && (!otherSyntax - || !otherSyntax->set_[significant].contains(ch)) - && set_[sgmlChar].contains(ch)) - invalid += ch; - } while (min++ != max); - } - } - } -} - -StringC Syntax::rniReservedName(ReservedName i) const -{ - StringC result = delimGeneral(dRNI); - result += reservedName(i); - return result; -} - -const SubstTable &Syntax::upperSubstTable() const -{ - return upperSubst_; -} - -const StringC &Syntax::peroDelim() const -{ - return delimGeneral(dPERO); -} - - -#ifdef SP_NAMESPACE -} -#endif diff --git a/cde/programs/nsgmls/Syntax.h b/cde/programs/nsgmls/Syntax.h deleted file mode 100644 index cf3cfaa70..000000000 --- a/cde/programs/nsgmls/Syntax.h +++ /dev/null @@ -1,521 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: Syntax.h /main/1 1996/07/29 17:06:04 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#ifndef Syntax_INCLUDED -#define Syntax_INCLUDED 1 -#ifdef __GNUG__ -#pragma interface -#endif - -#include "types.h" -#include "Boolean.h" -#include "ISet.h" -#include "StringC.h" -#include "SubstTable.h" -#include "HashTable.h" -#include "Vector.h" -#include "Resource.h" -#include "XcharMap.h" -#include "EntityCatalog.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -class Sd; -class CharsetInfo; - -class SP_API Syntax : public Resource, public EntityCatalog::Syntax { -public: - enum ReservedName { - rANY, - rATTLIST, - rCDATA, - rCONREF, - rCURRENT, - rDEFAULT, - rDOCTYPE, - rELEMENT, - rEMPTY, - rENDTAG, - rENTITIES, - rENTITY, - rFIXED, - rID, - rIDLINK, - rIDREF, - rIDREFS, - rIGNORE, - rIMPLIED, - rINCLUDE, - rINITIAL, - rLINK, - rLINKTYPE, - rMD, - rMS, - rNAME, - rNAMES, - rNDATA, - rNMTOKEN, - rNMTOKENS, - rNOTATION, - rNUMBER, - rNUMBERS, - rNUTOKEN, - rNUTOKENS, - rO, - rPCDATA, - rPI, - rPOSTLINK, - rPUBLIC, - rRCDATA, - rRE, - rREQUIRED, - rRESTORE, - rRS, - rSDATA, - rSHORTREF, - rSIMPLE, - rSPACE, - rSTARTTAG, - rSUBDOC, - rSYSTEM, - rTEMP, - rUSELINK, - rUSEMAP - }; - enum { nNames = rUSEMAP + 1 }; - enum Quantity { - qATTCNT, - qATTSPLEN, - qBSEQLEN, - qDTAGLEN, - qDTEMPLEN, - qENTLVL, - qGRPCNT, - qGRPGTCNT, - qGRPLVL, - qLITLEN, - qNAMELEN, - qNORMSEP, - qPILEN, - qTAGLEN, - qTAGLVL - }; - enum { nQuantity = qTAGLVL + 1 }; - enum DelimGeneral { - dAND, - dCOM, - dCRO, - dDSC, - dDSO, - dDTGC, - dDTGO, - dERO, - dETAGO, - dGRPC, - dGRPO, - dLIT, - dLITA, - dMDC, - dMDO, - dMINUS, - dMSC, - dNET, - dOPT, - dOR, - dPERO, - dPIC, - dPIO, - dPLUS, - dREFC, - dREP, - dRNI, - dSEQ, - dSTAGO, - dTAGC, - dVI - }; - enum { nDelimGeneral = dVI + 1 }; - enum StandardFunction { - fRE, - fRS, - fSPACE - }; - enum FunctionClass { - cFUNCHAR, - cSEPCHAR, - cMSOCHAR, - cMSICHAR, - cMSSCHAR - }; - enum Set { - nameStart, - digit, - nmchar, // LCNMCHAR or UCNMCHAR - s, - blank, - sepchar, - minimumData, - significant, - functionChar, // function character - sgmlChar - }; - enum { nSet = sgmlChar + 1 }; - enum Category { - otherCategory = 0, - sCategory = 01, - nameStartCategory = 02, - digitCategory = 04, - otherNameCategory = 010 - }; - - Syntax(const Sd &); - Syntax(const Syntax &); - Boolean lookupFunctionChar(const StringC &, Char *) const; - Boolean charFunctionName(Char c, const StringC *&name) const; - Boolean lookupReservedName(const StringC &, ReservedName *) const; - const StringC &reservedName(ReservedName) const; - StringC rniReservedName(ReservedName) const; - Number quantity(Quantity) const; - Char standardFunction(int) const; - Boolean getStandardFunction(int, Char &) const; - const StringC &delim() const; - const ISet *charSet(int i) const; - const SubstTable *generalSubstTable() const; - const SubstTable *entitySubstTable() const; - const SubstTable &upperSubstTable() const; - Boolean namecaseGeneral() const; - Boolean namecaseEntity() const; - const StringC &peroDelim() const; - const StringC &delimGeneral(int) const; - const StringC &delimShortrefComplex(size_t) const; - const ISet &delimShortrefSimple() const; - int nDelimShortrefComplex() const; - Boolean isValidShortref(const StringC &) const; - Boolean hasShortrefs() const; - Boolean isNameCharacter(Xchar) const; - Boolean isNameStartCharacter(Xchar) const; - Boolean isDigit(Xchar) const; - Boolean isS(Xchar) const; - Boolean isB(Xchar c) const; - Category charCategory(Xchar) const; - Boolean isSgmlChar(Xchar) const; - size_t attcnt() const; - size_t attsplen() const; - size_t namelen() const; - size_t penamelen() const; - size_t litlen() const; - size_t normsep() const; - size_t dtemplen() const; - size_t grpcnt() const; - size_t grpgtcnt() const; - size_t grplvl() const; - size_t taglvl() const; - size_t taglen() const; - size_t entlvl() const; - size_t pilen() const; - Char space() const; - - void setStandardFunction(StandardFunction, Char); - void enterStandardFunctionNames(); - void addFunctionChar(const StringC &, FunctionClass, Char); - void setNamecaseGeneral(Boolean); - void setNamecaseEntity(Boolean); - void setDelimGeneral(int, const StringC &); - void addDelimShortref(const StringC &, const CharsetInfo &); - void addDelimShortrefs(const ISet &shortrefChars, - const CharsetInfo &charset); - void addNameCharacters(const ISet &); - void addNameStartCharacters(const ISet &); - void addSubst(Char lc, Char uc); - void addShunchar(Char); - void setShuncharControls(); - void setQuantity(int, Number); - void setName(int, const StringC &); - void setSgmlChar(const ISet &); - void implySgmlChar(const CharsetInfo &docCharset); - // :: is for Watcom 10.0a - void checkSgmlChar(const CharsetInfo &docCharset, - const /* ::SP_NAMESPACE_SCOPE */ Syntax *otherSyntax, - ISet &invalid) - const; - static int referenceQuantity(Quantity); - const XcharMap &markupScanTable() const; - Boolean multicode() const; -private: - void subst(Char, Char); - void checkUnivControlChar(UnivChar univChar, - const CharsetInfo &docCharset, - const /* ::SP_NAMESPACE_SCOPE */ Syntax *otherSyntax, - ISet &invalid) const; - - ISet shunchar_; - PackedBoolean shuncharControls_; - ISet set_[nSet]; - Char standardFunction_[3]; - PackedBoolean standardFunctionValid_[3]; - Boolean namecaseGeneral_; - Boolean namecaseEntity_; - StringC delimGeneral_[nDelimGeneral]; - Vector delimShortrefComplex_; - ISet delimShortrefSimple_; - StringC names_[nNames]; - Number quantity_[nQuantity]; - HashTable nameTable_; - HashTable functionTable_; - SubstTable upperSubst_; - SubstTable identitySubst_; - const SubstTable *generalSubst_; - const SubstTable *entitySubst_; - XcharMap categoryTable_; - Boolean multicode_; - XcharMap markupScanTable_; - static const int referenceQuantity_[]; -}; - -inline Number Syntax::quantity(Quantity q) const -{ - return quantity_[q]; -} - -inline void Syntax::setQuantity(int i, Number n) -{ - quantity_[i] = n; -} - -inline const SubstTable *Syntax::generalSubstTable() const -{ - return generalSubst_; -} - -inline const SubstTable *Syntax::entitySubstTable() const -{ - return entitySubst_; -} - -inline int Syntax::nDelimShortrefComplex() const -{ - return int(delimShortrefComplex_.size()); -} - -inline const StringC &Syntax::delimGeneral(int i) const -{ - return delimGeneral_[i]; -} - -inline const StringC &Syntax::delimShortrefComplex(size_t i) const -{ - return delimShortrefComplex_[i]; -} - -inline const ISet &Syntax::delimShortrefSimple() const -{ - return delimShortrefSimple_; -} - -inline Boolean Syntax::hasShortrefs() const -{ - return delimShortrefComplex_.size() > 0 || !delimShortrefSimple_.isEmpty(); -} - -inline Char Syntax::standardFunction(int i) const -{ - return standardFunction_[i]; -} - -inline Boolean Syntax::getStandardFunction(int i, Char &result) const -{ - if (standardFunctionValid_[i]) { - result = standardFunction_[i]; - return 1; - } - else - return 0; -} - -inline const ISet *Syntax::charSet(int i) const -{ - return &set_[i]; -} - -inline Boolean Syntax::isNameCharacter(Xchar c) const -{ - return categoryTable_[c] >= nameStartCategory; -} - -inline Boolean Syntax::isNameStartCharacter(Xchar c) const -{ - return categoryTable_[c] == nameStartCategory; -} - -inline Boolean Syntax::isDigit(Xchar c) const -{ - return categoryTable_[c] == digitCategory; -} - -inline Boolean Syntax::isS(Xchar c) const -{ - return categoryTable_[c] == sCategory; -} - -inline Boolean Syntax::isB(Xchar c) const -{ - return (categoryTable_[c] == sCategory - && !(standardFunctionValid_[fRE] && c == standardFunction_[fRE]) - && !(standardFunctionValid_[fRS] && c == standardFunction_[fRS])); -} - -inline Syntax::Category Syntax::charCategory(Xchar c) const -{ - return Category(categoryTable_[c]); -} - -inline Boolean Syntax::isSgmlChar(Xchar c) const -{ - return c >= 0 && set_[sgmlChar].contains(Char(c)); -} - -inline const StringC &Syntax::reservedName(ReservedName i) const -{ - return names_[i]; -} - -inline size_t Syntax::attcnt() const -{ - return quantity(qATTCNT); -} - -inline size_t Syntax::attsplen() const -{ - return quantity(qATTSPLEN); -} - -inline size_t Syntax::namelen() const -{ - return quantity(qNAMELEN); -} - -inline size_t Syntax::penamelen() const -{ - return quantity(qNAMELEN) - delimGeneral(dPERO).size(); -} - -inline size_t Syntax::litlen() const -{ - return quantity(qLITLEN); -} - -inline size_t Syntax::normsep() const -{ - return quantity(qNORMSEP); -} - -inline size_t Syntax::dtemplen() const -{ - return quantity(qDTEMPLEN); -} - -inline size_t Syntax::grpcnt() const -{ - return quantity(qGRPCNT); -} - -inline size_t Syntax::grpgtcnt() const -{ - return quantity(qGRPGTCNT); -} - -inline size_t Syntax::grplvl() const -{ - return quantity(qGRPLVL); -} - -inline size_t Syntax::taglvl() const -{ - return quantity(qTAGLVL); -} - -inline size_t Syntax::taglen() const -{ - return quantity(qTAGLEN); -} - -inline size_t Syntax::entlvl() const -{ - return quantity(qENTLVL); -} - -inline size_t Syntax::pilen() const -{ - return quantity(qPILEN); -} - -inline Char Syntax::space() const -{ - return standardFunction(fSPACE); -} - -inline void Syntax::setSgmlChar(const ISet &set) -{ - set_[sgmlChar] = set; -} - -inline int Syntax::referenceQuantity(Quantity i) -{ - return referenceQuantity_[i]; -} - -inline void Syntax::setShuncharControls() -{ - shuncharControls_ = 1; -} - -inline const XcharMap &Syntax::markupScanTable() const -{ - return markupScanTable_; -} - -inline Boolean Syntax::multicode() const -{ - return multicode_; -} - -inline Boolean Syntax::namecaseGeneral() const -{ - return namecaseGeneral_; -} - -inline Boolean Syntax::namecaseEntity() const -{ - return namecaseEntity_; -} - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* Syntax_INCLUDED */ diff --git a/cde/programs/nsgmls/Text.C b/cde/programs/nsgmls/Text.C deleted file mode 100644 index f629a8f8f..000000000 --- a/cde/programs/nsgmls/Text.C +++ /dev/null @@ -1,408 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: Text.C /main/1 1996/07/29 17:06:09 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#ifdef __GNUG__ -#pragma implementation -#endif -#include "splib.h" -#include "Text.h" -#include "Entity.h" -// for memcmp() -#include - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -Text::Text() -{ -} - -void Text::addChar(Char c, const Location &loc) -{ - if (items_.size() == 0 - || items_.back().type != TextItem::data - || loc.origin().pointer() != items_.back().loc.origin().pointer() - || loc.index() != (items_.back().loc.index() - + (chars_.size() - items_.back().index))) { - items_.resize(items_.size() + 1); - items_.back().loc = loc; - items_.back().type = TextItem::data; - items_.back().index = chars_.size(); - } - chars_ += c; -} - -void Text::addChars(const Char *p, size_t length, const Location &loc) -{ - if (items_.size() == 0 - || items_.back().type != TextItem::data - || loc.origin().pointer() != items_.back().loc.origin().pointer() - || loc.index() != (items_.back().loc.index() - + (chars_.size() - items_.back().index))) { - items_.resize(items_.size() + 1); - items_.back().loc = loc; - items_.back().type = TextItem::data; - items_.back().index = chars_.size(); - } - chars_.append(p, length); -} - -void Text::addCdata(const InternalEntity *entity, - const ConstPtr &origin) -{ - addSimple(TextItem::cdata, Location(origin, 0)); - chars_.append(entity->string().data(), entity->string().size()); -} - -void Text::addSdata(const InternalEntity *entity, - const ConstPtr &origin) -{ - addSimple(TextItem::sdata, Location(origin, 0)); - chars_.append(entity->string().data(), entity->string().size()); -} - -void Text::addCharsTokenize(const Char *str, size_t n, const Location &loc, - Char space) -{ - Location loci(loc); - // FIXME speed this up - for (size_t i = 0; i < n; loci += 1, i++) { - if (str[i] == space && (size() == 0 || lastChar() == space)) - ignoreChar(str[i], loci); - else - addChar(str[i], loci); - } -} - -void Text::tokenize(Char space, Text &text) const -{ - TextIter iter(*this); - TextItem::Type type; - const Char *p; - size_t n; - const Location *loc; - while (iter.next(type, p, n, loc)) { - switch (type) { - case TextItem::data: - text.addCharsTokenize(p, n, *loc, space); - break; - case TextItem::sdata: - case TextItem::cdata: - { - text.addEntityStart(*loc); - text.addCharsTokenize(p, n, *loc, space); - Location tem(*loc); - tem += n; - text.addEntityEnd(tem); - } - break; - case TextItem::ignore: - text.ignoreChar(*p, *loc); - break; - default: - text.addSimple(type, *loc); - break; - } - } - if (text.size() > 0 && text.lastChar() == space) - text.ignoreLastChar(); -} - -void Text::addSimple(TextItem::Type type, const Location &loc) -{ - items_.resize(items_.size() + 1); - items_.back().loc = loc; - items_.back().type = type; - items_.back().index = chars_.size(); -} - -void Text::ignoreChar(Char c, const Location &loc) -{ - items_.resize(items_.size() + 1); - items_.back().loc = loc; - items_.back().type = TextItem::ignore; - items_.back().c = c; - items_.back().index = chars_.size(); -} - -void Text::ignoreLastChar() -{ - size_t lastIndex = chars_.size() - 1; - size_t i; - for (i = items_.size() - 1; items_[i].index > lastIndex; i--) - ; - // lastIndex >= items_[i].index - if (items_[i].index != lastIndex) { - items_.resize(items_.size() + 1); - i++; - for (size_t j = items_.size() - 1; j > i; j--) - items_[j] = items_[j - 1]; - items_[i].index = lastIndex; - items_[i].loc = items_[i - 1].loc; - items_[i].loc += lastIndex - items_[i - 1].index; - } - - items_[i].c = chars_[chars_.size() - 1]; - items_[i].type = TextItem::ignore; - for (size_t j = i + 1; j < items_.size(); j++) - items_[j].index = lastIndex; - chars_.resize(chars_.size() - 1); -} - -// All characters other than spaces are substed. - -void Text::subst(const SubstTable &table, Char space) -{ - for (size_t i = 0; i < items_.size(); i++) - if (items_[i].type == TextItem::data) { - size_t lim = (i + 1 < items_.size() - ? items_[i + 1].index - : chars_.size()); - size_t j; - for (j = items_[i].index; j < lim; j++) { - Char c = chars_[j]; - if (c != space && c != table[c]) - break; - } - if (j < lim) { - size_t start = items_[i].index; - StringC origChars(chars_.data() + start, lim - start); - for (; j < lim; j++) - if (chars_[j] != space) - table.subst(chars_[j]); - items_[i].loc = Location(new MultiReplacementOrigin(items_[i].loc, - origChars), - 0); - } - } -} - -void Text::clear() -{ - chars_.resize(0); - items_.clear(); -} - -Boolean Text::startDelimLocation(Location &loc) const -{ - if (items_.size() == 0 || items_[0].type != TextItem::startDelim) - return 0; - loc = items_[0].loc; - return 1; -} - -Boolean Text::endDelimLocation(Location &loc) const -{ - if (items_.size() == 0) - return 0; - switch (items_.back().type) { - case TextItem::endDelim: - case TextItem::endDelimA: - break; - default: - return 0; - } - loc = items_.back().loc; - return 1; -} - -Boolean Text::delimType(Boolean &lita) const -{ - if (items_.size() == 0) - return 0; - switch (items_.back().type) { - case TextItem::endDelim: - lita = 0; - return 1; - case TextItem::endDelimA: - lita = 1; - return 1; - default: - break; - } - return 0; -} - -TextItem::TextItem() -: type(data), c(0), index(0) -{ -} - -void Text::swap(Text &to) -{ - items_.swap(to.items_); - chars_.swap(to.chars_); -} - -TextIter::TextIter(const Text &text) -: ptr_(text.items_.begin()), text_(&text) -{ -} - -const Char *TextIter::chars(size_t &length) const -{ - if (ptr_->type == TextItem::ignore) { - length = 1; - return &ptr_->c; - } - else { - const StringC &chars = text_->chars_; - size_t charsIndex = ptr_->index; - if (ptr_ + 1 != text_->items_.begin() + text_->items_.size()) - length = ptr_[1].index - charsIndex; - else - length = chars.size() - charsIndex; - return chars.data() + charsIndex; - } -} - -Boolean TextIter::next(TextItem::Type &type, const Char *&str, size_t &length, - const Location *&loc) -{ - const TextItem *end = text_->items_.begin() + text_->items_.size(); - if (ptr_ == end) - return 0; - type = ptr_->type; - loc = &ptr_->loc; - if (type == TextItem::ignore) { - str = &ptr_->c; - length = 1; - } - else { - const StringC &chars = text_->chars_; - size_t charsIndex = ptr_->index; - str = chars.data() + charsIndex; - if (ptr_ + 1 != end) - length = ptr_[1].index - charsIndex; - else - length = chars.size() - charsIndex; - } - ptr_++; - return 1; -} - -void Text::insertChars(const StringC &s, const Location &loc) -{ - chars_.insert(0, s); - items_.resize(items_.size() + 1); - for (size_t i = items_.size() - 1; i > 0; i--) { - items_[i] = items_[i - 1]; - items_[i].index += s.size(); - } - items_[0].loc = loc; - items_[0].type = TextItem::data; - items_[0].index = 0; -} - -size_t Text::nDataEntities() const -{ - size_t n = 0; - for (size_t i = 0; i < items_.size(); i++) - switch (items_[i].type) { - case TextItem::sdata: - case TextItem::cdata: - n++; - break; - default: - break; - } - return n; -} - -// This is used to determine for a FIXED CDATA attribute -// whether a specified value if equal to the default value. - -Boolean Text::fixedEqual(const Text &text) const -{ - if (string() != text.string()) - return 0; - size_t j = 0; - for (size_t i = 0; i < items_.size(); i++) - switch (items_[i].type) { - case TextItem::cdata: - case TextItem::sdata: - for (;;) { - if (j >= text.items_.size()) - return 0; - if (text.items_[j].type == TextItem::cdata - || text.items_[j].type == TextItem::sdata) - break; - j++; - } - if (text.items_[j].index != items_[i].index - || (text.items_[j].loc.origin()->asEntityOrigin()->entity() - != items_[i].loc.origin()->asEntityOrigin()->entity())) - return 0; - break; - default: - break; - } - for (; j < text.items_.size(); j++) - switch (text.items_[j].type) { - case TextItem::cdata: - case TextItem::sdata: - return 0; - default: - break; - } - return 1; -} - -Location Text::charLocation(size_t ind) const -{ - // Find the last item whose index <= ind. - // Invariant: - // indexes < i implies index <= ind - // indexes >= lim implies index > ind - // The first item will always have index 0. - size_t i = 1; - size_t lim = items_.size(); - while (i < lim) { - size_t mid = i + (lim - i)/2; - if (items_[mid].index > ind) - lim = mid; - else - i = mid + 1; - } -#if 0 - for (size_t i = 1; i < items_.size(); i++) - if (items_[i].index > ind) - break; -#endif - i--; - Location loc; - // If items_.size() == 0, then i == lim. - if (i < lim) { - loc = items_[i].loc; - loc += ind - items_[i].index; - } - return loc; -} - -#ifdef SP_NAMESPACE -} -#endif diff --git a/cde/programs/nsgmls/Text.h b/cde/programs/nsgmls/Text.h deleted file mode 100644 index 2cb01e130..000000000 --- a/cde/programs/nsgmls/Text.h +++ /dev/null @@ -1,223 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: Text.h /main/1 1996/07/29 17:06:13 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#ifndef Text_INCLUDED -#define Text_INCLUDED 1 -#ifdef __GNUG__ -#pragma interface -#endif - -#include "types.h" -#include "StringC.h" -#include "Vector.h" -#include "Location.h" -#include "SubstTable.h" -#include - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -class InternalEntity; - -struct SP_API TextItem { - TextItem(); - enum Type { - data, - cdata, - sdata, - entityStart, - entityEnd, - startDelim, - endDelim, - endDelimA, - ignore - }; - Type type; - // char that was ignored - Char c; - // location of this item - // data - location of first char - // (c/sdata)entityStart - location of first char of entity - // (c/sdata)entityEnd - location of entity end in entity - // ignore - location of ignored character - // startDelim - location of first char of delimiter - // endDelim(A) - location of first char of delimiter - Location loc; - // index of character in chars_ to which this applies - size_t index; -}; - -// This is used to represent literals and attribute values. - -class SP_API Text { -public: - Text(); - void clear(); - void swap(Text &to); - void addChar(Char c, const Location &); - void addChars(const StringC &, const Location &); - void addChars(const Char *, size_t, const Location &); - void insertChars(const StringC &, const Location &); - void ignoreChar(Char, const Location &); - void ignoreLastChar(); - void addEntityStart(const Location &); - void addEntityEnd(const Location &); - void addCdata(const InternalEntity *, const ConstPtr &); - void addSdata(const InternalEntity *, const ConstPtr &); - void addStartDelim(const Location &loc); - void addEndDelim(const Location &loc, Boolean lita); - void subst(const SubstTable &, Char space); - void addCharsTokenize(const Char *, size_t, const Location &loc, Char space); - void addCharsTokenize(const StringC &, const Location &loc, Char space); - void tokenize(Char space, Text &text) const; - Location charLocation(size_t i) const; - size_t size() const; - Char lastChar() const; - const StringC &string() const; - size_t nDataEntities() const; - Boolean fixedEqual(const Text &) const; - // Location of first char of start delimiter. - Boolean startDelimLocation(Location &) const; - // Location of first char of end delimiter - Boolean endDelimLocation(Location &) const; - // Is delimiter a lit or lita? - Boolean delimType(Boolean &lita) const; -private: - void addSimple(TextItem::Type, const Location &); - StringC chars_; - Vector items_; - friend class TextIter; -}; - -class SP_API TextIter { -public: - TextIter(const Text &); - void rewind(); - Boolean next(TextItem::Type &, const Char *&, size_t &, - const Location *&); - // Alternative interface to next() - Boolean valid() const; - void advance(); - TextItem::Type type() const; - const Location &location() const; - const Char *chars(size_t &length) const; -private: - const TextItem *ptr_; - const Text *text_; -}; - -inline -size_t Text::size() const -{ - return chars_.size(); -} - -inline -Char Text::lastChar() const -{ - return chars_[chars_.size() - 1]; -} - -inline -const StringC &Text::string() const -{ - return chars_; -} - -inline -void Text::addEntityStart(const Location &loc) -{ - addSimple(TextItem::entityStart, loc); -} - -inline -void Text::addEntityEnd(const Location &loc) -{ - addSimple(TextItem::entityEnd, loc); -} - -inline -void Text::addChars(const StringC &s, const Location &loc) -{ - addChars(s.data(), s.size(), loc); -} - -inline -void Text::addStartDelim(const Location &loc) -{ - addSimple(TextItem::startDelim, loc); -} - -inline -void Text::addEndDelim(const Location &loc, Boolean lita) -{ - addSimple(lita ? TextItem::endDelimA : TextItem::endDelim, - loc); -} - -inline -void Text::addCharsTokenize(const StringC &str, const Location &loc, - Char space) -{ - addCharsTokenize(str.data(), str.size(), loc, space); -} - -inline -void TextIter::rewind() -{ - ptr_ = text_->items_.begin(); -} - -inline -void TextIter::advance() -{ - ptr_++; -} - -inline -Boolean TextIter::valid() const -{ - return ptr_ != (text_->items_.begin() + text_->items_.size()); -} - -inline -const Location &TextIter::location() const -{ - return ptr_->loc; -} - -inline -TextItem::Type TextIter::type() const -{ - return ptr_->type; -} - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* not Text_INCLUDED */ diff --git a/cde/programs/nsgmls/TokenMessageArg.C b/cde/programs/nsgmls/TokenMessageArg.C deleted file mode 100644 index 11803b024..000000000 --- a/cde/programs/nsgmls/TokenMessageArg.C +++ /dev/null @@ -1,135 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: TokenMessageArg.C /main/1 1996/07/29 17:06:18 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#ifdef __GNUG__ -#pragma implementation -#endif -#include "splib.h" -#include "TokenMessageArg.h" -#include "MessageBuilder.h" -#include "token.h" -#include "ParserMessages.h" -#include "Mode.h" -#include "ModeInfo.h" -#include "macros.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -TokenMessageArg::TokenMessageArg(Token token, Mode mode, - const ConstPtr &syntax, - const ConstPtr &sd) -: token_(token), mode_(mode), syntax_(syntax), sd_(sd) -{ -} - -MessageArg *TokenMessageArg::copy() const -{ - return new TokenMessageArg(*this); -} - -void TokenMessageArg::append(MessageBuilder &builder) const -{ - // FIXME translate function characters in delimiters into - // &#NAME; form. - if (token_ >= tokenFirstShortref) { - builder.appendFragment(ParserMessages::shortrefDelim); - return; - } - if (token_ == tokenEe) { - builder.appendFragment(ParserMessages::entityEnd); - return; - } - ModeInfo iter(mode_, *sd_); - TokenInfo info; - const MessageFragment *fragment = 0; - while (iter.nextToken(&info)) - if (info.token == token_) { - switch (info.type) { - case TokenInfo::delimType: - case TokenInfo::delimDelimType: - case TokenInfo::delimSetType: - { - const StringC &delim = syntax_->delimGeneral(info.delim1); - builder.appendFragment(ParserMessages::delimStart); - builder.appendChars(delim.data(), delim.size()); - fragment = &ParserMessages::delimEnd; - } - break; - case TokenInfo::setType: - switch (info.set) { - case Syntax::digit: - fragment = &ParserMessages::digit; - break; - case Syntax::nameStart: - fragment = &ParserMessages::nameStartCharacter; - break; - case Syntax::sepchar: - fragment = &ParserMessages::sepchar; - break; - case Syntax::s: - fragment = &ParserMessages::separator; - break; - case Syntax::nmchar: - fragment = &ParserMessages::nameCharacter; - break; - case Syntax::sgmlChar: - fragment = &ParserMessages::dataCharacter; - break; - case Syntax::minimumData: - fragment = &ParserMessages::minimumDataCharacter; - break; - case Syntax::significant: - fragment = &ParserMessages::significantCharacter; - break; - default: - CANNOT_HAPPEN(); - } - break; - case TokenInfo::functionType: - switch (info.function) { - case Syntax::fRE: - fragment = &ParserMessages::recordEnd; - break; - case Syntax::fRS: - fragment = &ParserMessages::recordStart; - break; - case Syntax::fSPACE: - fragment = &ParserMessages::space; - break; - } - break; - } - break; - } - if (fragment) - builder.appendFragment(*fragment); -} - -#ifdef SP_NAMESPACE -} -#endif diff --git a/cde/programs/nsgmls/TokenMessageArg.h b/cde/programs/nsgmls/TokenMessageArg.h deleted file mode 100644 index a76f43191..000000000 --- a/cde/programs/nsgmls/TokenMessageArg.h +++ /dev/null @@ -1,62 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: TokenMessageArg.h /main/1 1996/07/29 17:06:23 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#ifndef TokenMessageArg_INCLUDED -#define TokenMessageArg_INCLUDED 1 -#ifdef __GNUG__ -#pragma interface -#endif - -#include "MessageArg.h" -#include "types.h" -#include "Mode.h" -#include "Syntax.h" -#include "Sd.h" -#include "Ptr.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -class TokenMessageArg : public MessageArg { -public: - TokenMessageArg(Token token, Mode mode, - const ConstPtr &syntax, - const ConstPtr &sd); - MessageArg *copy() const; - void append(MessageBuilder &) const; -private: - Token token_; - Mode mode_; - ConstPtr syntax_; - ConstPtr sd_; -}; - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* not TokenMessageArg_INCLUDED */ diff --git a/cde/programs/nsgmls/TranslateInputCodingSystem.C b/cde/programs/nsgmls/TranslateInputCodingSystem.C deleted file mode 100644 index 73d0a127d..000000000 --- a/cde/programs/nsgmls/TranslateInputCodingSystem.C +++ /dev/null @@ -1,76 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: TranslateInputCodingSystem.C /main/1 1996/07/29 17:06:28 cde-hp $ */ -// Copyright (c) 1995 James Clark -// See the file COPYING for copying permission. - -#include "splib.h" -#include "TranslateInputCodingSystem.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -class TranslateDecoder : public Decoder { -public: - TranslateDecoder(const Char *table); - size_t decode(Char *to, const char *from, size_t fromLen, - const char **rest); - Boolean convertOffset(unsigned long &offset) const; -private: - const Char *table_; -}; - -TranslateInputCodingSystem::TranslateInputCodingSystem(const Char *table) -: table_(table) -{ -} - -Decoder *TranslateInputCodingSystem::makeDecoder() const -{ - return new TranslateDecoder(table_); -} - -TranslateDecoder::TranslateDecoder(const Char *table) -: table_(table) -{ -} - -size_t TranslateDecoder::decode(Char *to, const char *from, size_t fromLen, - const char **rest) -{ - for (size_t n = fromLen; n > 0; n--) - *to++ = table_[(unsigned char)*from++]; // zero extend - *rest = from; - return fromLen; -} - -Boolean TranslateDecoder::convertOffset(unsigned long &) const -{ - return true; -} - - -#ifdef SP_NAMESPACE -} -#endif diff --git a/cde/programs/nsgmls/TranslateInputCodingSystem.h b/cde/programs/nsgmls/TranslateInputCodingSystem.h deleted file mode 100644 index 2acfdd488..000000000 --- a/cde/programs/nsgmls/TranslateInputCodingSystem.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: TranslateInputCodingSystem.h /main/1 1996/07/29 17:06:33 cde-hp $ */ -// Copyright (c) 1995 James Clark -// See the file COPYING for copying permission. - -#ifndef TranslateInputCodingSystem_INCLUDED -#define TranslateInputCodingSystem_INCLUDED 1 - -#include "CodingSystem.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -class SP_API TranslateInputCodingSystem : public InputCodingSystem { -public: - TranslateInputCodingSystem(const Char *table); - Decoder *makeDecoder() const; -private: - const Char *table_; -}; - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* not TranslateInputCodingSystem_INCLUDED */ diff --git a/cde/programs/nsgmls/Trie.h b/cde/programs/nsgmls/Trie.h deleted file mode 100644 index 13c0bdf28..000000000 --- a/cde/programs/nsgmls/Trie.h +++ /dev/null @@ -1,93 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: Trie.h /main/1 1996/07/29 17:06:38 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#ifndef Trie_INCLUDED -#define Trie_INCLUDED 1 - -#include -#include "types.h" -#include "Boolean.h" -#include "Vector.h" -#include "CopyOwner.h" -#include "Priority.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -class BlankTrie; - -class Trie { -public: - Trie() : next_(0), nCodes_(0), token_(0), tokenLength_(0), priority_(Priority::data) { } - Trie(const Trie &); - ~Trie(); - Trie &operator=(const Trie &); - const Trie *next(int i) const { return &next_[i]; } - Boolean hasNext() const { return next_ != 0; } - Token token() const { return token_; } - int tokenLength() const { return tokenLength_; } - const BlankTrie *blank() const; - Boolean includeBlanks() const { - return Priority::isBlank(priority_); - } - friend class TrieBuilder; -private: - Trie *next_; - int nCodes_; - unsigned short token_; - unsigned char tokenLength_; - Priority::Type priority_; - CopyOwner blank_; -}; - -class BlankTrie : public Trie { -public: - BlankTrie() : additionalLength_(0), maxBlanksToScan_(0) { } - Boolean codeIsBlank(EquivCode c) const { return codeIsBlank_[c]; } - // maximum number of blanks to scan (minimum is 0) - size_t maxBlanksToScan() const { return maxBlanksToScan_; } - // length to add to tokenLengths in this trie (for those > 0). - int additionalLength() const { return additionalLength_; } - BlankTrie *copy() const { return new BlankTrie(*this); } -private: - unsigned char additionalLength_; - size_t maxBlanksToScan_; - Vector codeIsBlank_; - friend class TrieBuilder; -}; - -inline -const BlankTrie *Trie::blank() const -{ - return blank_.pointer(); -} - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* not Trie_INCLUDED */ diff --git a/cde/programs/nsgmls/TrieBuilder.C b/cde/programs/nsgmls/TrieBuilder.C deleted file mode 100644 index 66f59cd20..000000000 --- a/cde/programs/nsgmls/TrieBuilder.C +++ /dev/null @@ -1,275 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: TrieBuilder.C /main/1 1996/07/29 17:06:43 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#ifdef __GNUG__ -#pragma implementation -#endif -#include "splib.h" -#include "types.h" -#include "macros.h" -#include "StringOf.h" -#include "Trie.h" -#include "TrieBuilder.h" -#include "Priority.h" -#include - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -Trie::~Trie() -{ - if (next_) - delete [] next_; -} - -Trie::Trie(const Trie &t) -: nCodes_(t.nCodes_), - token_(t.token_), - tokenLength_(t.tokenLength_), - priority_(t.priority_), - blank_(t.blank_) -{ - if (t.next_) { - next_ = new Trie[nCodes_]; - for (int i = 0; i < nCodes_; i++) - next_[i] = t.next_[i]; - } - else - next_ = 0; -} - -Trie &Trie::operator=(const Trie &t) -{ - if (next_) - delete [] next_; - nCodes_ = t.nCodes_; - token_ = t.token_; - tokenLength_ = t.tokenLength_; - priority_ = t.priority_; - blank_ = t.blank_; - if (t.next_) { - next_ = new Trie[nCodes_]; - for (int i = 0; i < nCodes_; i++) - next_[i] = t.next_[i]; - } - else - next_ = 0; - return *this; -} - -TrieBuilder::TrieBuilder(int nCodes) -: nCodes_(nCodes), root_(new Trie) -{ - root_->token_ = 0; - root_->tokenLength_ = 0; - root_->priority_ = Priority::data; - root_->nCodes_ = nCodes; -} - -void TrieBuilder::recognize(const String &chars, - Token t, - Priority::Type priority, - TokenVector &ambiguities) -{ - setToken(extendTrie(root_.pointer(), chars), chars.size(), t, priority, - ambiguities); -} - -void TrieBuilder::recognize(const String &chars, - const String &set, - Token t, - Priority::Type priority, - TokenVector &ambiguities) -{ - Trie *trie = extendTrie(root_.pointer(), chars); - - for (size_t i = 0; i < set.size(); i++) - setToken(forceNext(trie, set[i]), chars.size() + 1, t, priority, - ambiguities); -} - -void TrieBuilder::recognizeB(const String &chars, - int bSequenceLength, - size_t maxBlankSequence, - const String &blankCodes, - const String &chars2, - Token token, - TokenVector &ambiguities) -{ - doB(extendTrie(root_.pointer(), chars), - chars.size(), - bSequenceLength, - maxBlankSequence, - blankCodes, - chars2, - token, - Priority::blank(bSequenceLength), - ambiguities); -} - -void TrieBuilder::recognizeEE(EquivCode code, Token t) -{ - Trie *trie = forceNext(root_.pointer(), code); - trie->tokenLength_ = 0; // it has length 0 in the buffer - trie->token_ = t; - trie->priority_ = Priority::data; -} - -void TrieBuilder::doB(Trie *trie, - int tokenLength, - int minBLength, - size_t maxLength, - const String &blankCodes, - const String &chars2, - Token token, - Priority::Type pri, - TokenVector &ambiguities) -{ - if (minBLength == 0 && trie->next_ == 0) { - if (!trie->blank_) { - BlankTrie *b = new BlankTrie; - trie->blank_ = b; - b->maxBlanksToScan_ = maxLength; - b->additionalLength_ = tokenLength; - b->codeIsBlank_.assign(nCodes_, 0); - for (size_t i = 0; i < blankCodes.size(); i++) - b->codeIsBlank_[blankCodes[i]] = 1; - b->tokenLength_ = 0; - b->token_ = 0; - b->priority_ = Priority::data; - b->nCodes_ = nCodes_; - } - else { - // A B sequence is not allowed to be adjacent to a character - // that can occur in a blank sequence, so maxLength will be - // the same at a node, no matter how we got there. - ASSERT(trie->blank_->maxBlanksToScan_ == maxLength); - ASSERT(trie->blank_->additionalLength_ == tokenLength); - } - if (chars2.size() == 0) - setToken(trie, tokenLength, token, pri, ambiguities); - else - setToken(extendTrie(trie->blank_.pointer(), chars2), - chars2.size(), - token, - pri, - ambiguities); - } - else { - if (minBLength == 0) - setToken(extendTrie(trie, chars2), tokenLength + chars2.size(), - token, pri, ambiguities); - for (size_t i = 0; i < blankCodes.size(); i++) - doB(forceNext(trie, blankCodes[i]), - tokenLength + 1, - minBLength == 0 ? 0 : minBLength - 1, - maxLength - 1, - blankCodes, - chars2, - token, - pri, - ambiguities); - } -} - -Trie *TrieBuilder::extendTrie(Trie *trie, const String &s) -{ - for (size_t i = 0; i < s.size(); i++) - trie = forceNext(trie, s[i]); - return trie; -} - -void TrieBuilder::setToken(Trie *trie, - int tokenLength, - Token token, - Priority::Type pri, - TokenVector &ambiguities) -{ - if (tokenLength > trie->tokenLength_ - || (tokenLength == trie->tokenLength_ - && pri > trie->priority_)) { - trie->tokenLength_ = tokenLength; - trie->token_ = token; - trie->priority_ = pri; - } - else if (trie->tokenLength_ == tokenLength - && trie->priority_ == pri - && trie->token_ != token - && trie->token_ != 0) { - ambiguities.push_back(Token(trie->token_)); - ambiguities.push_back(token); - } - if (trie->hasNext()) { - for (int i = 0; i < nCodes_; i++) - setToken(&trie->next_[i], tokenLength, token, pri, ambiguities); - } -} - -void TrieBuilder::copyInto(Trie *into, const Trie *from, int additionalLength) -{ - if (from->token_ != 0) { - TokenVector ambiguities; - setToken(into, from->tokenLength_ + additionalLength, from->token_, - from->priority_, ambiguities); - ASSERT(ambiguities.size() == 0); - } - if (from->hasNext()) - for (int i = 0; i < nCodes_; i++) - copyInto(forceNext(into, i), &from->next_[i], additionalLength); -} - -Trie *TrieBuilder::forceNext(Trie *trie, EquivCode c) -{ - if (!trie->hasNext()) { - trie->next_ = new Trie[nCodes_]; - if (trie->blank_) { - trie->blank_->additionalLength_ += 1; - trie->blank_->maxBlanksToScan_ -= 1; - } - Owner blankOwner(trie->blank_.extract()); - const BlankTrie *b = blankOwner.pointer(); - for (int i = 0; i < nCodes_; i++) { - Trie *p = &trie->next_[i]; - if (b && b->codeIsBlank(i)) - trie->next_[i].blank_ = (blankOwner - ? blankOwner.extract() - : new BlankTrie(*b)); - p->token_ = trie->token_; - p->tokenLength_ = trie->tokenLength_; - p->priority_ = trie->priority_; - p->nCodes_ = nCodes_; - } - if (b) - // -1 because 1 was added above - copyInto(trie, b, b->additionalLength_ - 1); - } - return &trie->next_[c]; -} - -#ifdef SP_NAMESPACE -} -#endif diff --git a/cde/programs/nsgmls/TrieBuilder.h b/cde/programs/nsgmls/TrieBuilder.h deleted file mode 100644 index abbb908da..000000000 --- a/cde/programs/nsgmls/TrieBuilder.h +++ /dev/null @@ -1,93 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: TrieBuilder.h /main/1 1996/07/29 17:06:48 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#ifndef TrieBuilder_INCLUDED -#define TrieBuilder_INCLUDED 1 -#ifdef __GNUG__ -#pragma interface -#endif - -#include "types.h" -#include "StringOf.h" -#include "Owner.h" -#include "Trie.h" -#include "Vector.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -class TrieBuilder { -public: - typedef Vector TokenVector; - TrieBuilder(int nCodes); - void recognize(const String &chars, - Token t, - Priority::Type pri, - TokenVector &ambiguities); - void recognize(const String &chars, - const String &set, - Token t, - Priority::Type pri, - TokenVector &ambiguities); - // recognize a delimiter with a blank sequence - void recognizeB(const String &chars, - int bSequenceLength, // >= 1 - size_t maxBlankSequenceLength, - const String &blankCodes, - const String &chars2, - Token t, - TokenVector &ambiguities); - void recognizeEE(EquivCode code, Token t); - Trie *extractTrie() { return root_.extract(); } -private: - TrieBuilder(const TrieBuilder &); // undefined - void operator=(const TrieBuilder &); // undefined - void doB(Trie *trie, - int tokenLength, - int minBLength, - size_t maxLength, - const String &blankCodes, - const String &chars2, - Token token, - Priority::Type pri, - TokenVector &ambiguities); - Trie *extendTrie(Trie *, const String &); - void setToken(Trie *trie, int tokenLength, Token token, Priority::Type pri, - TokenVector &ambiguities); - - Trie *forceNext(Trie *trie, EquivCode); - void copyInto(Trie *, const Trie *, int); - - int nCodes_; - Owner root_; -}; - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* not TrieBuilder_INCLUDED */ diff --git a/cde/programs/nsgmls/TypeId.C b/cde/programs/nsgmls/TypeId.C deleted file mode 100644 index 7949a01c5..000000000 --- a/cde/programs/nsgmls/TypeId.C +++ /dev/null @@ -1,51 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: TypeId.C /main/1 1996/07/29 17:06:52 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#include "splib.h" -#include "TypeId.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -int TypeId::isA(TypeId ti) const -{ - if (*this == ti) - return 1; - for (const void *const *p = bases_; *p; p++) - if (TypeId((const void *const *)*p).isA(ti)) - return 1; - return 0; -} - -int TypeId::canCast(TypeId to, TypeId from) const -{ - return isA(to) && to.isA(from); -} - -#ifdef SP_NAMESPACE -} -#endif diff --git a/cde/programs/nsgmls/TypeId.h b/cde/programs/nsgmls/TypeId.h deleted file mode 100644 index 7d0c5682f..000000000 --- a/cde/programs/nsgmls/TypeId.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: TypeId.h /main/1 1996/07/29 17:06:57 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#ifndef TypeId_INCLUDED -#define TypeId_INCLUDED 1 - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -#ifndef SP_API -#define SP_API /* as nothing */ -#endif - -class SP_API TypeId { -public: - TypeId(const void *const *bases) : bases_(bases) { } - // Is this object of type ti? - int isA(TypeId ti) const; - // Can an object with this dynamic type be cast from a static type FROM - // to a static type TO? - int canCast(TypeId to, TypeId from) const; - int operator==(TypeId ti) const { return bases_ == ti.bases_; } - int operator!=(TypeId ti) const { return bases_ != ti.bases_; } -private: - const void *const *bases_; -}; - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* not TypeId_INCLUDED */ diff --git a/cde/programs/nsgmls/URLStorage.C b/cde/programs/nsgmls/URLStorage.C deleted file mode 100644 index 2757b5395..000000000 --- a/cde/programs/nsgmls/URLStorage.C +++ /dev/null @@ -1,677 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: URLStorage.C /main/1 1996/07/29 17:07:01 cde-hp $ */ -// Copyright (c) 1995 James Clark -// See the file COPYING for copying permission. - -#ifdef __GNUG__ -#pragma implementation -#endif - -// FIXME This implementation won't work on an EBCDIC machine. - -#include "splib.h" -#ifdef WINSOCK -#include -#define readsocket(s, p, n) ::recv(s, p, n, 0) -#define writesocket(s, p, n) ::send(s, p, n, 0) -#define errnosocket (WSAGetLastError()) -#define SocketMessageArg(n) WinsockMessageArg(n) -#define SOCKET_EINTR (WSAEINTR) -#define SP_HAVE_SOCKET -#else -#ifdef SP_HAVE_SOCKET -#include -#include -#include -#include -#include -#ifdef SP_INCLUDE_UNISTD_H -#include -#endif - -#ifdef SP_INCLUDE_OSFCN_H -#include -#endif - -typedef int SOCKET; -#define SOCKET_ERROR (-1) -#define INVALID_SOCKET (-1) -#define SOCKET_EINTR (EINTR) -#define closesocket(s) close(s) -#define writesocket(fd, p, n) ::write(fd, p, n) -#define readsocket(s, p, n) ::read(s, p, n) -#define errnosocket (errno) -#define SocketMessageArg(n) ErrnoMessageArg(n) -#include "ErrnoMessageArg.h" - -#endif /* SP_HAVE_SOCKET */ - -#endif /* not WINSOCK */ - -#include "URLStorage.h" -#include "URLStorageMessages.h" -#include "RewindStorageObject.h" -#include "UnivCharsetDesc.h" -#include "MessageArg.h" -#include "MessageBuilder.h" -#include "macros.h" - -#include -#include -#include -#include -#include -#include - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -static UnivCharsetDesc::Range range = { 0, 128, 0 }; -static UnivCharsetDesc iso646Charset(&range, 1); - -#ifdef SP_HAVE_SOCKET - -class HttpSocketStorageObject : public RewindStorageObject { -public: - HttpSocketStorageObject(SOCKET fd, Boolean mayRewind, const StringC &hostStr); - ~HttpSocketStorageObject(); - Boolean open(const String &path, Messenger &); - Boolean read(char *buf, size_t bufSize, Messenger &mgr, size_t &nread); - Boolean seekToStart(Messenger &); - static SOCKET openHttp(const String &host, - unsigned short port, - const StringC &hostStr, - Messenger &mgr); -private: - HttpSocketStorageObject(const HttpSocketStorageObject &); // undefined - void operator=(const HttpSocketStorageObject &); // undefined - Boolean readHeader(Messenger &); - Boolean readLine(Messenger &mgr, String &line, String &leftOver); - StringC hostStr_; - String path_; - Boolean eof_; - SOCKET fd_; -}; - -#ifdef WINSOCK - -class WinsockMessageArg : public MessageArg { -public: - WinsockMessageArg(int n) : n_(n) { } - MessageArg *copy() const { return new WinsockMessageArg(*this); } - void append(MessageBuilder &) const; -private: - int n_; -}; - -void WinsockMessageArg::append(MessageBuilder &builder) const -{ - // I can't figure out how to get a string associated - // with this error number. FormatMessage() doesn't seem - // to work. - builder.appendFragment(URLStorageMessages::winsockErrorNumber); - builder.appendNumber(n_); -} - -class WinsockIniter { -public: - WinsockIniter(); - ~WinsockIniter(); - Boolean init(Messenger &mgr); -private: - Boolean inited_; - Boolean initSuccess_; -}; - -static WinsockIniter winsockIniter; - -WinsockIniter::WinsockIniter() -: inited_(0) -{ -} - -WinsockIniter::~WinsockIniter() -{ - if (inited_ && initSuccess_) - (void)WSACleanup(); -} - -Boolean WinsockIniter::init(Messenger &mgr) -{ - if (!inited_) { - inited_ = 1; - initSuccess_ = 0; - WORD version = MAKEWORD(1, 1); - WSADATA wsaData; - int err = WSAStartup(version, &wsaData); - if (err) - mgr.message(URLStorageMessages::winsockInitialize, - WinsockMessageArg(err)); - else if (LOBYTE(wsaData.wVersion) != 1 - || HIBYTE(wsaData.wVersion) != 1) { - mgr.message(URLStorageMessages::winsockVersion); - WSACleanup(); - } - else - initSuccess_ = 1; - } - return initSuccess_; -} - -#endif /* WINSOCK */ - -#endif /* SP_HAVE_SOCKET */ - -URLStorageManager::URLStorageManager(const char *type) -: type_(type), IdStorageManager(iso646Charset) -{ -} - -const char *URLStorageManager::type() const -{ - return type_; -} - -Boolean URLStorageManager::guessIsId(const StringC &id, - const CharsetInfo &charset) const -{ - if (id.size() < 8) - return 0; - size_t i = 0; - for (const char *s = "http://"; *s; s++, i++) - if (id[i] != charset.execToDesc(*s) - && (!islower(*s) || id[i] != charset.execToDesc(toupper(*s)))) - return 0; - return 1; -} - -StorageObject *URLStorageManager::makeStorageObject(const StringC &specId, - const StringC &baseId, - Boolean, - Boolean mayRewind, - Messenger &mgr, - StringC &id) -{ -#ifdef SP_HAVE_SOCKET - id = specId; - resolveRelative(baseId, id, 0); - if (id.size() < 5 - || (id[0] != 'h' && id[0] != 'H') - || (id[1] != 't' && id[1] != 'T') - || (id[2] != 't' && id[2] != 'T') - || (id[3] != 'p' && id[3] != 'P') - || id[4] != ':') { - mgr.message(URLStorageMessages::onlyHTTP); - return 0; - } - if (id.size() < 7 || id[5] != '/' || id[6] != '/') { - mgr.message(URLStorageMessages::badRelative, - StringMessageArg(id)); - return 0; - } - size_t i = 7; - String host; - while (i < id.size()) { - if (id[i] == '/') - break; - if (id[i] == ':') - break; - host += char(id[i]); - i++; - } - if (host.size() == 0) { - mgr.message(URLStorageMessages::emptyHost, - StringMessageArg(id)); - return 0; - } - unsigned short port; - if (i < id.size() && id[i] == ':') { - i++; - String digits; - while (i < id.size() && id[i] != '/') { - digits += char(id[i]); - i++; - } - if (digits.size() == 0) { - mgr.message(URLStorageMessages::emptyPort, - StringMessageArg(id)); - return 0; - } - digits += '\0'; - char *endptr; - long n = strtol(digits.data(), &endptr, 10); - if (endptr != digits.data() + digits.size() - 1 - || n < 0 - || n > 65535L) { - mgr.message(URLStorageMessages::invalidPort, - StringMessageArg(id)); - return 0; - } - port = (unsigned short)n; - } - else - port = 80; - String path; - if (i < id.size()) { - while (i < id.size() && id[i] != '#') { - path += char(id[i]); - i++; - } - } - if (path.size() == 0) - path += '/'; - - StringC hostStr; - for (i = 0; i < host.size(); i++) - hostStr += host[i]; - host += '\0'; - SOCKET fd = HttpSocketStorageObject::openHttp(host, port, hostStr, mgr); - if (fd == INVALID_SOCKET) - return 0; - HttpSocketStorageObject *p - = new HttpSocketStorageObject(fd, mayRewind, hostStr); - if (!p->open(path, mgr)) { - delete p; - return 0; - } - return p; -#else /* not SP_HAVE_SOCKET */ - ParentLocationMessenger(mgr).message(URLStorageMessages::notSupported); - return 0; -#endif /* not SP_HAVE_SOCKET */ -} - -Boolean URLStorageManager::resolveRelative(const StringC &baseId, - StringC &id, - Boolean) const -{ - static const char schemeChars[] = - "abcdefghijklmnopqrstuvwxyz" - "ABCDEFGHIJKLMNOPQRSTUVWXYZ" - "01234567879" - "+-."; - size_t i; - // If it has a scheme, it is absolute. - for (i = 0; i < id.size(); i++) { - if (id[i] == ':') { - if (i == 0) - break; - else - return 1; - } - else if (!strchr(schemeChars, id[i])) - break; - } - for (i = 0; i < id.size(); i++) { - if (id[i] != '/') - break; - } - size_t slashCount = i; - if (slashCount > 0) { - Boolean foundSameSlash = 0; - size_t sameSlashPos; - for (size_t j = 0; j < baseId.size(); j++) { - size_t thisSlashCount = 0; - for (size_t k = j; k < baseId.size() && baseId[k] == '/'; k++) - thisSlashCount++; - if (thisSlashCount == slashCount && !foundSameSlash) { - foundSameSlash = 1; - sameSlashPos = j; - } - else if (thisSlashCount > slashCount) - foundSameSlash = 0; - } - if (foundSameSlash) { - StringC tem(baseId.data(), sameSlashPos); - tem += id; - tem.swap(id); - } - } - else { - size_t j; - for (j = baseId.size(); j > 0; j--) - if (baseId[j - 1] == '/') - break; - if (j > 0) { - StringC tem(baseId.data(), j); - tem += id; - tem.swap(id); - } - } - // FIXME remove xxx/../, and /. - return 1; -} - -Boolean URLStorageManager::transformNeutral(StringC &str, Boolean fold, - Messenger &) const -{ - if (fold) - for (size_t i = 0; i < str.size(); i++) { - Char c = str[i]; - if (c <= (unsigned char)-1) - str[i] = tolower(str[i]); - } - return 1; -} - -#ifdef SP_HAVE_SOCKET - -SOCKET HttpSocketStorageObject::openHttp(const String &host, - unsigned short port, - const StringC &hostStr, - Messenger &mgr) -{ -#ifdef WINSOCK - if (!winsockIniter.init(mgr)) - return INVALID_SOCKET; -#endif - struct sockaddr_in sock; - sock.sin_family = AF_INET; - sock.sin_port = htons(port); - if (isdigit((unsigned char)host[0])) { - unsigned long n = inet_addr(host.data()); - if (n == (unsigned long)-1) { - ParentLocationMessenger(mgr).message(URLStorageMessages::invalidHostNumber, - StringMessageArg(hostStr)); - return INVALID_SOCKET; - } - sock.sin_addr.s_addr = n; - } - else { - struct hostent *hp = gethostbyname(host.data()); - if (!hp) { - const MessageType1 *message; - switch (h_errno) { - case HOST_NOT_FOUND: - message = &URLStorageMessages::hostNotFound; - break; - case TRY_AGAIN: - message = &URLStorageMessages::hostTryAgain; - break; - case NO_RECOVERY: - message = &URLStorageMessages::hostNoRecovery; - break; - case NO_DATA: -#ifdef NO_ADDRESS -#if NO_ADDRESS != NO_DATA - case NO_ADDRESS: -#endif -#endif - message = &URLStorageMessages::hostNoData; - break; - default: -#ifdef WINSOCK - ParentLocationMessenger(mgr).message(URLStorageMessages::hostOtherError, - StringMessageArg(hostStr), - WinsockMessageArg(h_errno)); - return INVALID_SOCKET; -#else - message = &URLStorageMessages::hostUnknownError; - break; -#endif - } - ParentLocationMessenger(mgr).message(*message, - StringMessageArg(hostStr)); - return INVALID_SOCKET; - } - memcpy(&sock.sin_addr, hp->h_addr, hp->h_length); - } - SOCKET fd = socket(PF_INET, SOCK_STREAM, 0); - if (fd == INVALID_SOCKET) { - ParentLocationMessenger(mgr).message(URLStorageMessages::cannotCreateSocket, - SocketMessageArg(errnosocket)); - return INVALID_SOCKET; - } - if (connect(fd, (struct sockaddr *)&sock, sizeof(sock)) == SOCKET_ERROR) { - ParentLocationMessenger(mgr).message(URLStorageMessages::cannotConnect, - StringMessageArg(hostStr), - SocketMessageArg(errnosocket)); - (void)closesocket(fd); - return INVALID_SOCKET; - } - return fd; -} - -HttpSocketStorageObject::HttpSocketStorageObject(SOCKET fd, - Boolean mayRewind, - const StringC &hostStr) - -: RewindStorageObject(mayRewind, 0), hostStr_(hostStr), fd_(fd), eof_(0) -{ -} - -HttpSocketStorageObject::~HttpSocketStorageObject() -{ - if (fd_ != INVALID_SOCKET) - (void)closesocket(fd_); -} - -Boolean HttpSocketStorageObject::open(const String &path, Messenger &mgr) -{ - path_ = path; - String request; - request.append("GET ", 4); - request += path_; - request += ' '; - request.append("HTTP/1.0\r\n\r\n", 12); - // FIXME check length of write - if (writesocket(fd_, request.data(), request.size()) == SOCKET_ERROR) { - ParentLocationMessenger(mgr).message(URLStorageMessages::writeError, - StringMessageArg(hostStr_), - SocketMessageArg(errnosocket)); - (void)closesocket(fd_); - fd_ = INVALID_SOCKET; - return 0; - } - if (!readHeader(mgr)) { - (void)closesocket(fd_); - fd_ = INVALID_SOCKET; - return 0; - } - return 1; -} - -Boolean HttpSocketStorageObject::readHeader(Messenger &mgr) -{ - String buf; - String leftOver; - if (!readLine(mgr, buf, leftOver)) - return 0; - buf += '\0'; - static const char ver[] = "HTTP/1.0"; - int i; - for (i = 0; ver[i]; i++) - if (ver[i] != buf[i]) - break; - if (ver[i]) { - if (buf.size() > 0) - unread(buf.data(), buf.size() - 1); - return 1; - } - const char *ptr = &buf[i]; - while (isspace((unsigned char)*ptr)) - ptr++; - int val = 0; - while (isdigit((unsigned char)*ptr)) { - val = val*10 + *ptr - '0'; - ptr++; - } - while (isspace((unsigned char)*ptr)) - ptr++; - if (val < 200 || val >= 300) { - StringC reason; - while (*ptr && *ptr != '\n' && *ptr != '\r') { - reason += Char(*ptr); - ptr++; - } - StringC pathStr; - for (size_t i = 0; i < path_.size(); i++) - pathStr += path_[i]; - ParentLocationMessenger(mgr).message(URLStorageMessages::getFailed, - StringMessageArg(hostStr_), - StringMessageArg(pathStr), - StringMessageArg(reason)); - return 0; - } - - for (;;) { - if (!readLine(mgr, buf, leftOver)) - return 0; - if (buf.size() == 0 || buf[0] == '\r' || buf[0] == '\n') - break; - } - if (leftOver.size()) - unread(leftOver.data(), leftOver.size()); - return 1; -} - -// True will be returned for an empty line. - -Boolean HttpSocketStorageObject::readLine(Messenger &mgr, - String &line, - String &leftOver) -{ - line.resize(0); - Boolean hadCr = 0; - Boolean gotLine = 0; - size_t li; - for (li = 0; li < leftOver.size(); li++) { - if (leftOver[li] == '\r') { - if (hadCr) { - gotLine = 1; - break; - } - line += '\r'; - hadCr = 1; - } - else if (leftOver[li] == '\n') { - line += '\n'; - li++; - gotLine = 1; - break; - } - else if (hadCr) { - gotLine = 1; - break; - } - else - line += leftOver[li]; - } - if (gotLine) { - for (size_t i = li; i < leftOver.size(); i++) - leftOver[i - li] = leftOver[i]; - leftOver.resize(leftOver.size() - li); - return 1; - } - leftOver.resize(0); - if (eof_) - return 1; - for (;;) { - char c; - long n; - do { - n = readsocket(fd_, &c, 1); - } while (n < 0 && errnosocket == SOCKET_EINTR); - if (n == 0) { - (void)closesocket(fd_); - eof_ = 1; - return 1; - } - if (n < 0) { - ParentLocationMessenger(mgr).message(URLStorageMessages::readError, - StringMessageArg(hostStr_), - SocketMessageArg(errnosocket)); - (void)closesocket(fd_); - fd_ = INVALID_SOCKET; - return 0; - } - switch (c) { - case '\r': - if (hadCr) { - leftOver += c; - return 1; - } - hadCr = 1; - line += c; - break; - case '\n': - line += c; - return 1; - default: - if (hadCr) { - leftOver += c; - return 1; - } - line += c; - break; - } - } - return 0; // not reached -} - -Boolean HttpSocketStorageObject::read(char *buf, size_t bufSize, Messenger &mgr, - size_t &nread) -{ - if (readSaved(buf, bufSize, nread)) - return 1; - if (fd_ == INVALID_SOCKET || eof_) - return 0; - long n; - do { - n = readsocket(fd_, buf, bufSize); - } while (n < 0 && errnosocket == SOCKET_EINTR); - if (n > 0) { - nread = size_t(n); - saveBytes(buf, nread); - return 1; - } - if (n < 0) { - ParentLocationMessenger(mgr).message(URLStorageMessages::readError, - StringMessageArg(hostStr_), - SocketMessageArg(errnosocket)); - fd_ = INVALID_SOCKET; - } - else { - eof_ = 1; - if (closesocket(fd_) == SOCKET_ERROR) - ParentLocationMessenger(mgr).message(URLStorageMessages::closeError, - StringMessageArg(hostStr_), - SocketMessageArg(errnosocket)); - fd_ = INVALID_SOCKET; - } - return 0; -} - -Boolean HttpSocketStorageObject::seekToStart(Messenger &) -{ - CANNOT_HAPPEN(); - return 0; -} - -#endif /* SP_HAVE_SOCKET */ - -#ifdef SP_NAMESPACE -} -#endif diff --git a/cde/programs/nsgmls/URLStorage.h b/cde/programs/nsgmls/URLStorage.h deleted file mode 100644 index 452435541..000000000 --- a/cde/programs/nsgmls/URLStorage.h +++ /dev/null @@ -1,62 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: URLStorage.h /main/1 1996/07/29 17:07:06 cde-hp $ */ -// Copyright (c) 1995 James Clark -// See the file COPYING for copying permission. - -#ifndef URLStorage_INCLUDED -#define URLStorage_INCLUDED 1 -#ifdef __GNUG__ -#pragma interface -#endif - -#include "StorageManager.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -class SP_API URLStorageManager : public IdStorageManager { -public: - URLStorageManager(const char *type); - StorageObject *makeStorageObject(const StringC &id, - const StringC &baseId, - Boolean search, - Boolean mayRewind, - Messenger &, - StringC &found); - const char *type() const; - Boolean guessIsId(const StringC &, const CharsetInfo &) const; - Boolean transformNeutral(StringC &, Boolean fold, Messenger &) const; -private: - Boolean resolveRelative(const StringC &base, StringC &specId, Boolean) const; - URLStorageManager(const URLStorageManager &); // undefined - void operator=(const URLStorageManager &); // undefined - const char *type_; -}; - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* not URLStorage_INCLUDED */ diff --git a/cde/programs/nsgmls/URLStorageMessages.h b/cde/programs/nsgmls/URLStorageMessages.h deleted file mode 100644 index 214818f0e..000000000 --- a/cde/programs/nsgmls/URLStorageMessages.h +++ /dev/null @@ -1,342 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: URLStorageMessages.h /main/1 1996/07/29 17:07:11 cde-hp $ */ -// This file was automatically generated from URLStorageMessages.msg by msggen.pl. -#include "Message.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -struct URLStorageMessages { - // 2300 - static const MessageType1 emptyHost; - // 2301 - static const MessageType1 badRelative; - // 2302 - static const MessageType1 emptyPort; - // 2303 - static const MessageType1 invalidPort; - // 2304 - static const MessageType1 hostNotFound; - // 2305 - static const MessageType1 hostTryAgain; - // 2306 - static const MessageType1 hostNoRecovery; - // 2307 - static const MessageType1 hostNoData; - // 2308 - static const MessageType2 hostOtherError; - // 2309 - static const MessageType1 hostUnknownError; - // 2310 - static const MessageType1 cannotCreateSocket; - // 2311 - static const MessageType2 cannotConnect; - // 2312 - static const MessageType2 writeError; - // 2313 - static const MessageType2 readError; - // 2314 - static const MessageType2 closeError; - // 2315 - static const MessageType1 invalidHostNumber; - // 2316 - static const MessageType3 getFailed; - // 2317 - static const MessageType0 notSupported; - // 2318 - static const MessageType0 onlyHTTP; - // 2319 - static const MessageType1 winsockInitialize; - // 2320 - static const MessageType0 winsockVersion; - // 2321 - static const MessageFragment winsockErrorNumber; -}; -const MessageType1 URLStorageMessages::emptyHost( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -2300 -#ifndef SP_NO_MESSAGE_TEXT -,"empty host in HTTP URL %1" -#endif -); -const MessageType1 URLStorageMessages::badRelative( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -2301 -#ifndef SP_NO_MESSAGE_TEXT -,"uncompletable relative HTTP URL %1" -#endif -); -const MessageType1 URLStorageMessages::emptyPort( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -2302 -#ifndef SP_NO_MESSAGE_TEXT -,"empty port number in HTTP URL %1" -#endif -); -const MessageType1 URLStorageMessages::invalidPort( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -2303 -#ifndef SP_NO_MESSAGE_TEXT -,"invalid port number in HTTP URL %1" -#endif -); -const MessageType1 URLStorageMessages::hostNotFound( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -2304 -#ifndef SP_NO_MESSAGE_TEXT -,"host %1 not found" -#endif -); -const MessageType1 URLStorageMessages::hostTryAgain( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -2305 -#ifndef SP_NO_MESSAGE_TEXT -,"could not resolve host %1 (try again later)" -#endif -); -const MessageType1 URLStorageMessages::hostNoRecovery( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -2306 -#ifndef SP_NO_MESSAGE_TEXT -,"could not resolve host %1 (unrecoverable error)" -#endif -); -const MessageType1 URLStorageMessages::hostNoData( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -2307 -#ifndef SP_NO_MESSAGE_TEXT -,"no address record for host name %1" -#endif -); -const MessageType2 URLStorageMessages::hostOtherError( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -2308 -#ifndef SP_NO_MESSAGE_TEXT -,"could not resolve host %1 (%2)" -#endif -); -const MessageType1 URLStorageMessages::hostUnknownError( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -2309 -#ifndef SP_NO_MESSAGE_TEXT -,"could not resolve host %1 (unknown error)" -#endif -); -const MessageType1 URLStorageMessages::cannotCreateSocket( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -2310 -#ifndef SP_NO_MESSAGE_TEXT -,"cannot create socket (%1)" -#endif -); -const MessageType2 URLStorageMessages::cannotConnect( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -2311 -#ifndef SP_NO_MESSAGE_TEXT -,"error connecting to %1 (%2)" -#endif -); -const MessageType2 URLStorageMessages::writeError( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -2312 -#ifndef SP_NO_MESSAGE_TEXT -,"error sending request to %1 (%2)" -#endif -); -const MessageType2 URLStorageMessages::readError( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -2313 -#ifndef SP_NO_MESSAGE_TEXT -,"error receiving from host %1 (%2)" -#endif -); -const MessageType2 URLStorageMessages::closeError( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -2314 -#ifndef SP_NO_MESSAGE_TEXT -,"error closing connection to host %1 (%2)" -#endif -); -const MessageType1 URLStorageMessages::invalidHostNumber( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -2315 -#ifndef SP_NO_MESSAGE_TEXT -,"invalid host number %1" -#endif -); -const MessageType3 URLStorageMessages::getFailed( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -2316 -#ifndef SP_NO_MESSAGE_TEXT -,"could not get %2 from %1 (reason given was %3)" -#endif -); -const MessageType0 URLStorageMessages::notSupported( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -2317 -#ifndef SP_NO_MESSAGE_TEXT -,"URL not supported by this version" -#endif -); -const MessageType0 URLStorageMessages::onlyHTTP( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -2318 -#ifndef SP_NO_MESSAGE_TEXT -,"only HTTP scheme supported" -#endif -); -const MessageType1 URLStorageMessages::winsockInitialize( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -2319 -#ifndef SP_NO_MESSAGE_TEXT -,"could not initialize Windows Sockets (%1)" -#endif -); -const MessageType0 URLStorageMessages::winsockVersion( -MessageType::error, -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -2320 -#ifndef SP_NO_MESSAGE_TEXT -,"incompatible Windows Sockets version" -#endif -); -const MessageFragment URLStorageMessages::winsockErrorNumber( -#ifdef BUILD_LIBSP -MessageFragment::libModule, -#else -MessageFragment::appModule, -#endif -2321 -#ifndef SP_NO_MESSAGE_TEXT -,"error number " -#endif -); -#ifdef SP_NAMESPACE -} -#endif diff --git a/cde/programs/nsgmls/UTF8CodingSystem.C b/cde/programs/nsgmls/UTF8CodingSystem.C deleted file mode 100644 index e45d5c2c2..000000000 --- a/cde/programs/nsgmls/UTF8CodingSystem.C +++ /dev/null @@ -1,289 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: UTF8CodingSystem.C /main/1 1996/07/29 17:07:15 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#include "splib.h" - -#ifdef SP_MULTI_BYTE - -#include "UTF8CodingSystem.h" -#include "constant.h" -#if defined(__linux__) || defined(CSRG_BASED) || defined(sun) -#include -#else -#include -#endif - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -enum { - // cmaskN is mask for first byte to test for N byte sequence - cmask1 = 0x80, - cmask2 = 0xe0, - cmask3 = 0xf0, - cmask4 = 0xf8, - cmask5 = 0xfc, - cmask6 = 0xfe, - // cvalN is value of masked first byte of N byte sequence - cval1 = 0x00, - cval2 = 0xc0, - cval3 = 0xe0, - cval4 = 0xf0, - cval5 = 0xf8, - cval6 = 0xfc, - // vmaskN is mask to get value from first byte in N byte sequence - vmask2 = 0x1f, - vmask3 = 0xf, - vmask4 = 0x7, - vmask5 = 0x3, - vmask6 = 0x1, - // minN is minimum legal resulting value for N byte sequence - min2 = 0x80, - min3 = 0x800, - min4 = 0x10000, - min5 = 0x200000, - min6 = 0x4000000, - max6 = 0x7fffffff -}; - -class UTF8Decoder : public Decoder { -public: - UTF8Decoder(); - size_t decode(Char *, const char *, size_t, const char **); -private: - // value for encoding error - enum { invalid = 0xfffd }; - Boolean recovering_; -}; - -class UTF8Encoder : public Encoder { -public: - UTF8Encoder(); - void output(const Char *, size_t, streambuf *); -}; - -Decoder *UTF8CodingSystem::makeDecoder() const -{ - return new UTF8Decoder; -} - -Encoder *UTF8CodingSystem::makeEncoder() const -{ - return new UTF8Encoder; -} - - -UTF8Decoder::UTF8Decoder() -: recovering_(0) -{ -} - -size_t UTF8Decoder::decode(Char *to, const char *s, - size_t slen, const char **result) -{ - Char *start = to; - const unsigned char *us = (const unsigned char *)s; - if (recovering_) { - recovering_ = 0; - goto recover; - } - while (slen > 0) { - unsigned c0; - c0 = us[0]; - if ((c0 & cmask1) == cval1) { - *to++ = c0; - us++; - slen--; - } - else if ((c0 & cmask2) == cval2) { - if (slen < 2) - goto done; - unsigned c1 = us[1] ^ 0x80; - if (c1 & 0xc0) - goto error; - unsigned c = ((c0 & vmask2) << 6) | c1; - if (c < min2) - c = invalid; - *to++ = c; - slen -= 2; - us += 2; - } - else if ((c0 & cmask3) == cval3) { - if (slen < 3) - goto done; - unsigned c1 = us[1] ^ 0x80; - unsigned c2 = us[2] ^ 0x80; - if ((c1 | c2) & 0xc0) - goto error; - unsigned c = ((((c0 & vmask3) << 6) | c1) << 6) | c2; - if (c < min3) - c = invalid; - *to++ = c; - slen -= 3; - us += 3; - } - else if ((c0 & cmask4) == cval4) { - if (slen < 4) - goto done; - if (charMax < min5 - 1) - *to++ = invalid; - unsigned c1 = us[1] ^ 0x80; - unsigned c2 = us[2] ^ 0x80; - unsigned c3 = us[3] ^ 0x80; - if ((c1 | c2 | c3) & 0xc0) - goto error; - else { - unsigned long c = ((((c0 & vmask4) << 6) | c1) << 6) | c2; - c = (c << 6) | c3; - if (c < min4) - c = invalid; - *to++ = c; - } - slen -= 4; - us += 4; - } - else if ((c0 & cmask5) == cval5) { - if (slen < 5) - goto done; - unsigned c1 = us[1] ^ 0x80; - unsigned c2 = us[2] ^ 0x80; - unsigned c3 = us[3] ^ 0x80; - unsigned c4 = us[4] ^ 0x80; - if ((c1 | c2 | c3 | c4) & 0xc0) - goto error; - if (charMax < min6 - 1) - *to++ = invalid; - else { - unsigned long c = ((((c0 & vmask5) << 6) | c1) << 6) | c2; - c = (((c << 6) | c3) << 6) | c4; - if (c < min5) - c = invalid; - *to++ = c; - } - slen -= 5; - us += 5; - } - else if ((c0 & cmask6) == cval6) { - if (slen < 6) - goto done; - unsigned c1 = us[1] ^ 0x80; - unsigned c2 = us[2] ^ 0x80; - unsigned c3 = us[3] ^ 0x80; - unsigned c4 = us[4] ^ 0x80; - unsigned c5 = us[5] ^ 0x80; - if ((c1 | c2 | c3 | c4 | c5) & 0xc0) - goto error; - if (charMax < max6) - *to++ = invalid; - else { - unsigned long c = ((((c0 & vmask6) << 6) | c1) << 6) | c2; - c = (((((c << 6) | c3) << 6) | c4) << 6) | c5; - if (c < min6) - c = invalid; - *to++ = c; - } - slen -= 6; - us += 6; - } - else { - error: - us++; - slen--; - *to++ = invalid; - recover: - for (;;) { - if (slen == 0) { - recovering_ = 1; - goto done; - } - if ((*us & 0xc0) != 0x80) - break; - us++; - slen--; - } - } - } - done: - *result = (char *)us; - return to - start; -} - -UTF8Encoder::UTF8Encoder() -{ -} - -// FIXME handle errors from streambuf::sputc - -void UTF8Encoder::output(const Char *s, size_t n, streambuf *sb) -{ - for (; n > 0; s++, n--) { - Char c = *s; - if (c < min2) - sb->sputc(char(c)); - else if (c < min3) { - sb->sputc((c >> 6) | cval2); - sb->sputc((c & 0x3f) | 0x80); - } - else if (c < min4) { - sb->sputc((c >> 12) | cval3); - sb->sputc(((c >> 6) & 0x3f) | 0x80); - sb->sputc((c & 0x3f) | 0x80); - } - else if (c < min5) { - sb->sputc((c >> 18) | cval4); - sb->sputc(((c >> 12) & 0x3f) | 0x80); - sb->sputc(((c >> 6) & 0x3f) | 0x80); - sb->sputc((c & 0x3f) | 0x80); - } - else if (c < min6) { - sb->sputc((c >> 24) | cval5); - sb->sputc(((c >> 18) & 0x3f) | 0x80); - sb->sputc(((c >> 12) & 0x3f) | 0x80); - sb->sputc(((c >> 6) & 0x3f) | 0x80); - sb->sputc((c & 0x3f) | 0x80); - } - else if (c <= max6) { - sb->sputc((c >> 30) | cval6); - sb->sputc(((c >> 24) & 0x3f) | 0x80); - sb->sputc(((c >> 18) & 0x3f) | 0x80); - sb->sputc(((c >> 12) & 0x3f) | 0x80); - sb->sputc(((c >> 6) & 0x3f) | 0x80); - sb->sputc((c & 0x3f) | 0x80); - } - } -} -#ifdef SP_NAMESPACE -} -#endif - -#else /* not SP_MULTI_BYTE */ - -#ifndef __GNUG__ -static char non_empty_translation_unit; // sigh -#endif - -#endif /* not SP_MULTI_BYTE */ diff --git a/cde/programs/nsgmls/UTF8CodingSystem.h b/cde/programs/nsgmls/UTF8CodingSystem.h deleted file mode 100644 index ccde4ac57..000000000 --- a/cde/programs/nsgmls/UTF8CodingSystem.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: UTF8CodingSystem.h /main/1 1996/07/29 17:07:20 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#ifndef UTF8CodingSystem_INCLUDED -#define UTF8CodingSystem_INCLUDED 1 - -#include "CodingSystem.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -class SP_API UTF8CodingSystem : public CodingSystem { -public: - Decoder *makeDecoder() const; - Encoder *makeEncoder() const; -}; - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* not UTF8CodingSystem_INCLUDED */ diff --git a/cde/programs/nsgmls/Undo.C b/cde/programs/nsgmls/Undo.C deleted file mode 100644 index 75618b63c..000000000 --- a/cde/programs/nsgmls/Undo.C +++ /dev/null @@ -1,77 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: Undo.C /main/1 1996/07/29 17:07:24 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#ifdef __GNUG__ -#pragma implementation -#endif -#include "splib.h" -#include "Undo.h" -#include "ParserState.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -Undo::Undo() -{ -} - -Undo::~Undo() -{ -} - -UndoTransition::UndoTransition(const MatchState &state) -: state_(state) -{ -} - -void UndoTransition::undo(ParserState *parser) -{ - parser->currentElement().setMatchState(state_); -} - -UndoStartTag::UndoStartTag() -{ -} - -void UndoStartTag::undo(ParserState *parser) -{ - parser->popElement(); -} - -UndoEndTag::UndoEndTag(OpenElement *e) -: element_(e) -{ -} - -void UndoEndTag::undo(ParserState *parser) -{ - parser->pushElement(element_.extract()); -} - -#ifdef SP_NAMESPACE -} -#endif diff --git a/cde/programs/nsgmls/Undo.h b/cde/programs/nsgmls/Undo.h deleted file mode 100644 index 59123a420..000000000 --- a/cde/programs/nsgmls/Undo.h +++ /dev/null @@ -1,91 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: Undo.h /main/1 1996/07/29 17:07:28 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#ifndef Undo_INCLUDED -#define Undo_INCLUDED 1 -#ifdef __GNUG__ -#pragma interface -#endif - -#include "Link.h" -#include "ContentToken.h" -#include "OpenElement.h" -#include "Allocator.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -class ParserState; -class Event; - -class Undo : public Link { -public: - void *operator new(size_t sz, Allocator &alloc) { return alloc.alloc(sz); } - void *operator new(size_t sz) { return Allocator::allocSimple(sz); } - void operator delete(void *p) { Allocator::free(p); } - Undo(); - virtual ~Undo(); - virtual void undo(ParserState *) = 0; -private: - Undo(const Undo &); // undefined - void operator=(const Undo &); // undefined -}; - -class UndoTransition : public Undo { -public: - UndoTransition(const MatchState &); - void undo(ParserState *); -private: - UndoTransition(const UndoTransition &); // undefined - void operator=(const UndoTransition &); // undefined - MatchState state_; -}; - -class UndoStartTag : public Undo { -public: - UndoStartTag(); - void undo(ParserState *); -private: - UndoStartTag(const UndoStartTag &); // undefined - void operator=(const UndoStartTag &); // undefined -}; - -class UndoEndTag : public Undo { -public: - UndoEndTag(OpenElement *); - void undo(ParserState *); -private: - UndoEndTag(const UndoEndTag &); // undefined - void operator=(const UndoEndTag &); // undefined - Owner element_; -}; - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* not Undo_INCLUDED */ diff --git a/cde/programs/nsgmls/UnicodeCodingSystem.C b/cde/programs/nsgmls/UnicodeCodingSystem.C deleted file mode 100644 index 5f9231d96..000000000 --- a/cde/programs/nsgmls/UnicodeCodingSystem.C +++ /dev/null @@ -1,245 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: UnicodeCodingSystem.C /main/1 1996/07/29 17:07:33 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#include "splib.h" - -#ifdef SP_MULTI_BYTE - -#include "UnicodeCodingSystem.h" -#include "macros.h" -#include "Owner.h" - -#include -#include -#ifdef DECLARE_MEMMOVE -extern "C" { - void *memmove(void *, const void *, size_t); -} -#endif -#if defined(__linux__) || defined(CSRG_BASED) || defined(sun) -#include -#else -#include -#endif - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -const unsigned short byteOrderMark = 0xfeff; -const unsigned short swappedByteOrderMark = 0xfffe; - -class UnicodeDecoder : public Decoder { -public: - UnicodeDecoder(const InputCodingSystem *sub); - size_t decode(Char *to, const char *from, size_t fromLen, - const char **rest); - Boolean convertOffset(unsigned long &offset) const; -private: - PackedBoolean hadFirstChar_; - PackedBoolean hadByteOrderMark_; - PackedBoolean swapBytes_; - Owner subDecoder_; - const InputCodingSystem *subCodingSystem_; -}; - -class UnicodeEncoder : public Encoder { -public: - UnicodeEncoder(); - ~UnicodeEncoder(); - void output(Char *, size_t, streambuf *); - void output(const Char *, size_t, streambuf *); - void startFile(streambuf *); -private: - void allocBuf(size_t); - unsigned short *buf_; - size_t bufSize_; -}; - -UnicodeCodingSystem::UnicodeCodingSystem(const InputCodingSystem *sub) -: sub_(sub) -{ -} - -Decoder *UnicodeCodingSystem::makeDecoder() const -{ - return new UnicodeDecoder(sub_); -} - -Encoder *UnicodeCodingSystem::makeEncoder() const -{ - return new UnicodeEncoder; -} - -unsigned UnicodeCodingSystem::fixedBytesPerChar() const -{ - return 2; -} - -UnicodeDecoder::UnicodeDecoder(const InputCodingSystem *subCodingSystem) -: Decoder(subCodingSystem ? 1 : 2), subCodingSystem_(subCodingSystem), - hadByteOrderMark_(0), hadFirstChar_(0), swapBytes_(0) -{ -} - - -size_t UnicodeDecoder::decode(Char *to, const char *from, size_t fromLen, - const char **rest) -{ - union U { - unsigned short word; - char bytes[2]; - }; - - if (subDecoder_) - return subDecoder_->decode(to, from, fromLen, rest); - if (!hadFirstChar_) { - hadFirstChar_ = 1; - minBytesPerChar_ = 2; - if (fromLen < 2) { - *rest = from; - return 0; - } - U u; - u.bytes[0] = from[0]; - u.bytes[1] = from[1]; - if (u.word == byteOrderMark) { - hadByteOrderMark_ = 1; - from += 2; - fromLen -= 2; - } - else if (u.word == swappedByteOrderMark) { - hadByteOrderMark_ = 1; - from += 2; - fromLen -= 2; - swapBytes_ = 1; - } - else if (subCodingSystem_) { - subDecoder_ = subCodingSystem_->makeDecoder(); - minBytesPerChar_ = subDecoder_->minBytesPerChar(); - return subDecoder_->decode(to, from, fromLen, rest); - } - } - fromLen &= ~1; - *rest = from + fromLen; - if (sizeof(Char) == 2) { - if (!swapBytes_) { - if (from != (char *)to) - memmove(to, from, fromLen); - return fromLen/2; - } - } - if (swapBytes_) { - for (size_t n = fromLen; n > 0; n -= 2) { - U u; - u.bytes[1] = *from++; - u.bytes[0] = *from++; - *to++ = u.word; - } - } - else { - for (size_t n = fromLen; n > 0; n -= 2) { - U u; - u.bytes[0] = *from++; - u.bytes[1] = *from++; - *to++ = u.word; - } - } - return fromLen/2; -} - -Boolean UnicodeDecoder::convertOffset(unsigned long &n) const -{ - if (subDecoder_) - return subDecoder_->convertOffset(n); - n *= 2; - if (hadByteOrderMark_) - n += 1; - return true; -} - -UnicodeEncoder::UnicodeEncoder() -: buf_(0), bufSize_(0) -{ -} - -UnicodeEncoder::~UnicodeEncoder() -{ - delete [] buf_; -} - -void UnicodeEncoder::allocBuf(size_t n) -{ - if (bufSize_ < n) { - delete [] buf_; - buf_ = new unsigned short[bufSize_ = n]; - } -} - -void UnicodeEncoder::startFile(streambuf *sb) -{ - const unsigned short n = byteOrderMark; - sb->sputn((char *)&n, 2); -} - -// FIXME handle errors from streambuf::sputn - -void UnicodeEncoder::output(Char *s, size_t n, streambuf *sb) -{ - if (sizeof(Char) == 2) { - sb->sputn((char *)s, n*2); - return; - } - ASSERT(sizeof(Char) >= 2); - unsigned short *p = (unsigned short *)s; - for (size_t i = 0; i < n; i++) - p[i] = s[i] & 0xffff; - sb->sputn((char *)s, n*2); -} - -void UnicodeEncoder::output(const Char *s, size_t n, streambuf *sb) -{ - if (sizeof(Char) == 2) { - sb->sputn((char *)s, n*2); - return; - } - allocBuf(n); - for (size_t i = 0; i < n; i++) - buf_[i] = s[i] & 0xffff; - sb->sputn((char *)buf_, n*2); -} - -#ifdef SP_NAMESPACE -} -#endif - -#else /* not SP_MULTI_BYTE */ - -#ifndef __GNUG__ -static char non_empty_translation_unit; // sigh -#endif - -#endif /* not SP_MULTI_BYTE */ diff --git a/cde/programs/nsgmls/UnicodeCodingSystem.h b/cde/programs/nsgmls/UnicodeCodingSystem.h deleted file mode 100644 index 7b88d8ee1..000000000 --- a/cde/programs/nsgmls/UnicodeCodingSystem.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: UnicodeCodingSystem.h /main/1 1996/07/29 17:07:38 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#ifndef UnicodeCodingSystem_INCLUDED -#define UnicodeCodingSystem_INCLUDED 1 - -#include "CodingSystem.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -class SP_API UnicodeCodingSystem : public CodingSystem { -public: - UnicodeCodingSystem(const InputCodingSystem *sub = 0); - Decoder *makeDecoder() const; - Encoder *makeEncoder() const; - unsigned fixedBytesPerChar() const; -private: - const InputCodingSystem *sub_; -}; - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* not UnicodeCodingSystem_INCLUDED */ diff --git a/cde/programs/nsgmls/UnivCharsetDesc.C b/cde/programs/nsgmls/UnivCharsetDesc.C deleted file mode 100644 index 10a4de06c..000000000 --- a/cde/programs/nsgmls/UnivCharsetDesc.C +++ /dev/null @@ -1,99 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: UnivCharsetDesc.C /main/1 1996/07/29 17:07:43 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#ifdef __GNUG__ -#pragma implementation -#endif -#include "splib.h" -#include "UnivCharsetDesc.h" -#include "macros.h" -#include "constant.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -UnivCharsetDesc::UnivCharsetDesc() -{ -} - -UnivCharsetDesc::UnivCharsetDesc(const Range *p, size_t n) -{ - set(p, n); -} - -void UnivCharsetDesc::set(const Range *p, size_t n) -{ - for (size_t i = 0; i < n; i++) { - const Range &r = p[i]; - WideChar max; - if (r.count > wideCharMax || r.descMin > wideCharMax - r.count) - max = wideCharMax; - else - max = r.descMin + (r.count - 1); - if (max - r.descMin > univCharMax - || r.univMin > univCharMax - (max - r.descMin)) - max = r.descMin + (univCharMax - r.univMin); - descToUniv_.addRange(r.descMin, max, r.univMin); - } -} - -void UnivCharsetDesc::addBaseRange(const UnivCharsetDesc &baseSet, - WideChar descMin, - WideChar descMax, - WideChar baseMin, - ISet &baseMissing) -{ - UnivCharsetDescIter iter(baseSet); - WideChar baseMax = baseMin + (descMax - descMin); - WideChar iDescMin, iDescMax; - UnivChar iBaseMin; - WideChar missingBaseMin = baseMin; - Boolean usedAll = 0; - while (iter.next(iDescMin, iDescMax, iBaseMin) && iDescMin <= baseMax) { - // baseMin baseMax - // iDescMin iDescMax - if (iDescMax >= baseMin) { - WideChar min = baseMin > iDescMin ? baseMin : iDescMin; - if (min > missingBaseMin) - baseMissing.addRange(missingBaseMin, min - 1); - WideChar max = baseMax < iDescMax ? baseMax : iDescMax; - missingBaseMin = max + 1; - if (missingBaseMin == 0) - usedAll = 1; - ASSERT(min <= max); - descToUniv_.addRange(descMin + (min - baseMin), - descMin + (max - baseMin), - iBaseMin + (min - iDescMin)); - } - } - if (!usedAll && baseMax >= missingBaseMin) - baseMissing.addRange(missingBaseMin, baseMax); -} - -#ifdef SP_NAMESPACE -} -#endif diff --git a/cde/programs/nsgmls/UnivCharsetDesc.h b/cde/programs/nsgmls/UnivCharsetDesc.h deleted file mode 100644 index 54536d050..000000000 --- a/cde/programs/nsgmls/UnivCharsetDesc.h +++ /dev/null @@ -1,155 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: UnivCharsetDesc.h /main/1 1996/07/29 17:07:49 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#ifndef UnivCharsetDesc_INCLUDED -#define UnivCharsetDesc_INCLUDED 1 -#ifdef __GNUG__ -#pragma interface -#endif - -#include -#include "types.h" -#include "RangeMap.h" -#include "Boolean.h" -#include "ISet.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -#ifndef SP_API -#define SP_API -#endif - -class SP_API UnivCharsetDesc { -public: - struct SP_API Range { - WideChar descMin; - // Note that this is a count, as in the SGML declaration, - // rather than a maximum. - unsigned long count; - UnivChar univMin; - }; - enum { - zero = 48, - A = 65, - a = 97, - tab = 9, - rs = 10, - re = 13, - space = 32, - exclamation = 33, - lessThan = 60, - greaterThan = 62 - }; - UnivCharsetDesc(); - UnivCharsetDesc(const Range *, size_t); - void set(const Range *, size_t); - Boolean descToUniv(WideChar from, UnivChar &to) const; - Boolean descToUniv(WideChar from, UnivChar &to, WideChar &alsoMax) const; - // Return 0 for no matches, 1 for 1, 2 for more than 1 - unsigned univToDesc(UnivChar from, WideChar &to, ISet &toSet) - const; - unsigned univToDesc(UnivChar from, WideChar &to, ISet &toSet, - WideChar &count) - const; - void addRange(WideChar descMin, WideChar descMax, UnivChar univMin); - void addBaseRange(const UnivCharsetDesc &baseSet, - WideChar descMin, - WideChar descMax, - WideChar baseMin, - ISet &baseMissing); - WideChar maxDesc() const; -private: - RangeMap descToUniv_; - friend class UnivCharsetDescIter; -}; - -class SP_API UnivCharsetDescIter { -public: - UnivCharsetDescIter(const UnivCharsetDesc &); - Boolean next(WideChar &descMin, WideChar &descMax, UnivChar &univMin); -private: - RangeMapIter iter_; -}; - -inline -Boolean UnivCharsetDesc::descToUniv(WideChar from, UnivChar &to) const -{ - WideChar tem; - return descToUniv_.map(from, to, tem); -} - -inline -Boolean UnivCharsetDesc::descToUniv(WideChar from, UnivChar &to, - WideChar &alsoMax) const -{ - return descToUniv_.map(from, to, alsoMax); -} - -inline -unsigned UnivCharsetDesc::univToDesc(UnivChar from, WideChar &to, - ISet &toSet) const -{ - WideChar tem; - return descToUniv_.inverseMap(from, to, toSet, tem); -} - -inline -unsigned UnivCharsetDesc::univToDesc(UnivChar from, WideChar &to, - ISet &toSet, - WideChar &count) const -{ - return descToUniv_.inverseMap(from, to, toSet, count); -} - -inline -void UnivCharsetDesc::addRange(WideChar descMin, - WideChar descMax, - UnivChar univMin) -{ - descToUniv_.addRange(descMin, descMax, univMin); -} - -inline -UnivCharsetDescIter::UnivCharsetDescIter(const UnivCharsetDesc &desc) -: iter_(desc.descToUniv_) -{ -} - -inline -Boolean UnivCharsetDescIter::next(WideChar &descMin, - WideChar &descMax, - UnivChar &univMin) -{ - return iter_.next(descMin, descMax, univMin); -} - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* not UnivCharsetDesc_INCLUDED */ diff --git a/cde/programs/nsgmls/VERSION b/cde/programs/nsgmls/VERSION deleted file mode 100644 index 9459d4ba2..000000000 --- a/cde/programs/nsgmls/VERSION +++ /dev/null @@ -1 +0,0 @@ -1.1 diff --git a/cde/programs/nsgmls/Vector.C b/cde/programs/nsgmls/Vector.C deleted file mode 100644 index b70717a6b..000000000 --- a/cde/programs/nsgmls/Vector.C +++ /dev/null @@ -1,181 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: Vector.C /main/3 1996/08/17 08:15:28 mgreess $ */ -// Copyright (c) 1994, 1996 James Clark -// See the file COPYING for copying permission. - -#ifndef Vector_DEF_INCLUDED -#define Vector_DEF_INCLUDED 1 - -#include -#include - -#ifdef SP_QUAL_TEMPLATE_DTOR_BROKEN -#define DTOR(T) ~T -#else -#define DTOR(T) T::~T -#endif - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -template -Vector::~Vector() -{ - if (ptr_) { - erase(ptr_, ptr_ + size_); - ::operator delete((void *)ptr_); - } -} - -template -Vector::Vector(const Vector &v) -: ptr_(0), size_(0), alloc_(0) -{ - insert(ptr_ + size_, v.ptr_, v.ptr_ + v.size_); -} - -template -Vector::Vector(size_t n, const T &t) -: ptr_(0), size_(0), alloc_(0) -{ - insert(ptr_ + size_, n, t); -} - -template -Vector &Vector::operator=(const Vector &v) -{ - if (&v != this) { - size_t n = v.size_; - if (n > size_) { - n = size_; - insert(ptr_ + size_, v.ptr_ + size_, v.ptr_ + v.size_); - } - else if (n < size_) - erase(ptr_ + n, ptr_ + size_); - while (n-- > 0) - ptr_[n] = v.ptr_[n]; - } - return *this; -} - -template -void Vector::assign(size_t n, const T &t) -{ - size_t sz = n; - if (n > size_) { - sz = size_; - insert(ptr_ + size_, n - size_, t); - } - else if (n < size_) - erase(ptr_ + n, ptr_ + size_); - while (sz-- > 0) - ptr_[sz] = t; -} - -template -void Vector::insert(const T *p, size_t n, const T &t) -{ - size_t i = p - ptr_; - reserve(size_ + n); - if (i != size_) - memmove(ptr_ + i + n, ptr_ + i, (size_ - i)*sizeof(T)); - size_ += n; - for (T *pp = ptr_ + i; n-- > 0; pp++) - (void)new (pp) T(t); -} - -template -void Vector::insert(const T *p, const T *q1, const T *q2) -{ - size_t i = p - ptr_; - size_t n = q2 - q1; - reserve(size_ + n); - if (i != size_) - memmove(ptr_ + i + n, ptr_ + i, (size_ - i)*sizeof(T)); - size_ += n; - for (T *pp = ptr_ + i; q1 != q2; q1++, pp++) - (void)new (pp) T(*q1); -} - -template -void Vector::swap(Vector &v) -{ - { - T *tem = ptr_; - ptr_ = v.ptr_; - v.ptr_ = tem; - } - { - size_t tem = size_; - size_ = v.size_; - v.size_ = tem; - } - { - size_t tem = alloc_; - alloc_ = v.alloc_; - v.alloc_ = tem; - } -} - -template -void Vector::append(size_t n) -{ - reserve(size_ + n); - while (n-- > 0) - (void)new (ptr_ + size_++) T; -} - -template -T *Vector::erase(const T *p1, const T *p2) -{ -#if !defined(SP_TEMPLATE_DESTRUCTOR_COMPILER_BUG) - for (const T *p = p1; p != p2; p++) - p->~T(); -#endif - if (p2 != ptr_ + size_) - memmove((T *)p1, p2, ((const T *)(ptr_ + size_) - p2)*sizeof(T)); - size_ -= p2 - p1; - return (T *)p1; -} - -template -void Vector::reserve1(size_t size) -{ - alloc_ *= 2; - if (size > alloc_) - alloc_ += size; - void *p = ::operator new(alloc_*sizeof(T)); - if (ptr_) { - memcpy(p, ptr_, size_*sizeof(T)); - ::operator delete((void *)ptr_); - } - ptr_ = (T *)p; -} - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* not Vector_DEF_INCLUDED */ diff --git a/cde/programs/nsgmls/Vector.h b/cde/programs/nsgmls/Vector.h deleted file mode 100644 index 2091a4509..000000000 --- a/cde/programs/nsgmls/Vector.h +++ /dev/null @@ -1,94 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: Vector.h /main/1 1996/07/29 17:08:00 cde-hp $ */ -// Copyright (c) 1994, 1996 James Clark -// See the file COPYING for copying permission. - -#ifndef Vector_INCLUDED -#define Vector_INCLUDED 1 - -#include -#include "xnew.h" - -// This offers a subset of the interface offered by the standard C++ -// vector class as defined in the Jan 96 WP. -// Code in SP currently assumes that size_type is size_t. - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -template -class Vector { -public: - typedef size_t size_type; - typedef T *iterator; - typedef const T *const_iterator; - Vector() : ptr_(0), size_(0), alloc_(0) { } - Vector(size_t n) : ptr_(0), size_(0), alloc_(0) { append(n); } - ~Vector(); - void resize(size_t n) { - if (n < size_) - erase(ptr_ + n, ptr_ + size_); - else if (n > size_) - append(n - size_); - } - Vector(size_t, const T &); - Vector(const Vector &); - Vector &operator=(const Vector &); - void assign(size_t, const T &); - void push_back(const T &t) { - reserve(size_ + 1); - (void)new (ptr_ + size_++) T(t); - } - void insert(const_iterator p, size_t n, const T &t); - void insert(const_iterator p, const_iterator q1, const_iterator q2); - void swap(Vector &); - void clear() { erase(ptr_, ptr_ + size_); } - size_t size() const { return size_; } - T &operator[](size_t i) { return ptr_[i]; } - const T &operator[](size_t i) const { return ptr_[i]; } - iterator begin() { return ptr_; } - const_iterator begin() const { return ptr_; } - T &back() { return ptr_[size_ - 1]; } - const T &back() const { return ptr_[size_ - 1]; } - void reserve(size_t n) { if (n > alloc_) reserve1(n); } - iterator erase(const_iterator, const_iterator); -private: - void append(size_t); - void reserve1(size_t); - - size_t size_; - T *ptr_; - size_t alloc_; // allocated size -}; - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* not Vector_INCLUDED */ - -#ifdef SP_DEFINE_TEMPLATES -#include "Vector.C" -#endif diff --git a/cde/programs/nsgmls/XcharMap.C b/cde/programs/nsgmls/XcharMap.C deleted file mode 100644 index 37156a0e8..000000000 --- a/cde/programs/nsgmls/XcharMap.C +++ /dev/null @@ -1,75 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: XcharMap.C /main/1 1996/07/29 17:08:05 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#ifndef XcharMap_DEF_INCLUDED -#define XcharMap_DEF_INCLUDED 1 - -#include - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -template -SharedXcharMap::SharedXcharMap() -{ -} - -template -SharedXcharMap::SharedXcharMap(T defaultValue) -{ - for (size_t i = 0; i < sizeof(v)/sizeof(v[0]); i++) - v[i] = defaultValue; -} - -template -XcharMap::XcharMap() -: ptr_(0) -{ -} - -template -XcharMap::XcharMap(T defaultValue) -: sharedMap_(new SharedXcharMap(defaultValue)) -{ - ptr_ = sharedMap_->ptr(); -} - -template -void XcharMap::setRange(Char min, Char max, T val) -{ - if (min <= max) { - do { - ptr_[min] = val; - } while (min++ != max); - } -} - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* not XcharMap_DEF_INCLUDED */ diff --git a/cde/programs/nsgmls/XcharMap.h b/cde/programs/nsgmls/XcharMap.h deleted file mode 100644 index 2414deddf..000000000 --- a/cde/programs/nsgmls/XcharMap.h +++ /dev/null @@ -1,72 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: XcharMap.h /main/1 1996/07/29 17:08:09 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#ifndef XcharMap_INCLUDED -#define XcharMap_INCLUDED 1 - -#include "types.h" -#include "Resource.h" -#include "Ptr.h" -#include "constant.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -template -class SharedXcharMap : public Resource { -public: - SharedXcharMap(); - SharedXcharMap(T defaultValue); - T *ptr() { return v + 1; } -private: - T v[2 + charMax]; -}; - -template -class XcharMap { -public: - XcharMap(); - XcharMap(T defaultValue); - T operator[](Xchar c) const { return ptr_[c]; } - void setRange(Char min, Char max, T val); - void setChar(Char c, T val) { ptr_[c] = val; } - void setEe(T val) { ptr_[-1] = val; } - void clear() { ptr_ = 0; sharedMap_.clear(); } -private: - T *ptr_; - Ptr > sharedMap_; -}; - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* not XcharMap_INCLUDED */ - -#ifdef SP_DEFINE_TEMPLATES -#include "XcharMap.C" -#endif diff --git a/cde/programs/nsgmls/app_inst.m4 b/cde/programs/nsgmls/app_inst.m4 deleted file mode 100644 index 30ac4f4d2..000000000 --- a/cde/programs/nsgmls/app_inst.m4 +++ /dev/null @@ -1,33 +0,0 @@ -/* $XConsortium: app_inst.m4 /main/2 1996/08/09 15:32:58 mgreess $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#include "splib.h" - -#ifdef SP_MANUAL_INST - -#define SP_DEFINE_TEMPLATES -#include "Vector.h" -#include "Owner.h" -#include "Options.h" -#undef SP_DEFINE_TEMPLATES - -#include -#include "CodingSystem.h" -#include "CmdLineApp.h" -#include "Event.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -__instantiate(Vector) -__instantiate(Owner) -__instantiate(Options) -__instantiate(Owner) - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* SP_MANUAL_INST */ diff --git a/cde/programs/nsgmls/arc_inst.m4 b/cde/programs/nsgmls/arc_inst.m4 deleted file mode 100644 index d548614cb..000000000 --- a/cde/programs/nsgmls/arc_inst.m4 +++ /dev/null @@ -1,29 +0,0 @@ -/* $XConsortium: arc_inst.m4 /main/2 1996/08/09 15:33:11 mgreess $ */ -// Copyright (c) 1996 James Clark -// See the file COPYING for copying permission. - -#include "splib.h" - -#ifdef SP_MANUAL_INST - -#define SP_DEFINE_TEMPLATES -#include "Vector.h" -#include "NCVector.h" -#include "Owner.h" -#undef SP_DEFINE_TEMPLATES - -#include "ArcProcessor.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -__instantiate(NCVector) -__instantiate(Owner) -__instantiate(NCVector >) - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* SP_MANUAL_INST */ diff --git a/cde/programs/nsgmls/assert.C b/cde/programs/nsgmls/assert.C deleted file mode 100644 index 889306546..000000000 --- a/cde/programs/nsgmls/assert.C +++ /dev/null @@ -1,47 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: assert.C /main/1 1996/07/29 17:08:24 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#include "splib.h" -#include -#include "macros.h" - -#if defined(__GNUG__) && !defined(sun) -void exit(int) __attribute__((noreturn)); -#endif - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -void assertionFailed(const char *, const char *, int) -{ - abort(); - exit(1); -} - -#ifdef SP_NAMESPACE -} -#endif diff --git a/cde/programs/nsgmls/config.h b/cde/programs/nsgmls/config.h deleted file mode 100644 index 50582016a..000000000 --- a/cde/programs/nsgmls/config.h +++ /dev/null @@ -1,238 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: config.h /main/1 1996/07/29 17:08:30 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#ifndef config_INCLUDED -#define config_INCLUDED 1 - -#define SP_INCLUDE_UNISTD_H -#define SP_POSIX_FILENAMES - -#if defined(__GNUG__) || defined(__SunOS) -// It's not missing, but it pulls in libg++ -#if !defined(__linux__) && !defined(CSRG_BASED) && !defined(sun) -#define SP_NEW_H_MISSING -// set_new_handler() has to be declared extern "C" -#define SP_SET_NEW_HANDLER_EXTERN_C -#endif -#ifndef SP_MANUAL_INST -#define SP_MANUAL_INST -#endif -#ifndef SP_ANSI_CLASS_INST -#define SP_ANSI_CLASS_INST -#endif -#ifndef SP_HAVE_BOOL -#define SP_HAVE_BOOL -#endif -#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7) -#define SP_ANSI_FOR_SCOPE -#endif - -#endif /* __GNUG__ */ - -#if defined(sun) || defined(__sun) -// struct stat has st_blksize member -#define SP_STAT_BLKSIZE -#endif - -#ifdef __EMX__ -// EMX 0.9a for OS/2 -#undef SP_POSIX_FILENAMES -#define SP_MSDOS_FILENAMES -#endif - -#ifdef _MSC_VER -// Microsoft Visual C++ 4.0 -#undef SP_INCLUDE_UNISTD_H -#define SP_INCLUDE_IO_H -#ifndef SP_ANSI_CLASS_INST -#define SP_ANSI_CLASS_INST -#endif -#undef SP_POSIX_FILENAMES -#define SP_MSDOS_FILENAMES -#define SP_SHORT_HEADERS -#pragma warning ( disable : 4660 ) // already instantiated -#pragma warning ( disable : 4661 ) // missing def for decl member -#pragma warning ( disable : 4786 ) // debug symbol truncated (>255 chars) -#pragma warning ( disable : 4018 ) // signed/unsigned mismatch -#pragma warning ( disable : 4251 ) // __declspec(dllexport) -#pragma warning ( disable : 4275 ) -#pragma warning ( disable : 4237 ) // future reserved keyword -#define huge verybig -#if _MSC_VER == 900 -#define SP_DECLARE_PLACEMENT_OPERATOR_NEW -#endif -#define set_new_handler _set_new_handler -// Function passed to set_new_handler() returns int and takes size_t argument. -#define SP_FANCY_NEW_HANDLER - -#define SP_HAVE_SETMODE -#define SP_DLLEXPORT __declspec(dllexport) -#define SP_DLLIMPORT __declspec(dllimport) - -#ifdef _DLL -#define SP_USE_DLL -#endif - -#ifdef SP_USE_DLL -#ifndef BUILD_LIBSP -// It's not possible to export templates using __declspec(dllexport), -// so instead we include the template definitions in the headers, -// which allows Visual C++ to instantiate any needed templates -// in the client. -#define SP_DEFINE_TEMPLATES -#endif -#endif /* SP_USE_DLL */ - -#ifndef SP_MANUAL_INST -#ifndef SP_DEFINE_TEMPLATES -#define SP_MANUAL_INST -#endif -#endif /* not SP_MANUAL_INST */ - -// Make sure both _UNICODE and UNICODE are defined if either is. - -#ifdef _UNICODE -#ifndef UNICODE -#define UNICODE -#endif /* not UNICODE */ -#endif /* _UNICODE */ - -#ifdef UNICODE -#ifndef _UNICODE -#define _UNICODE -#endif /* not _UNICODE */ -#endif /* UNICODE */ - -#ifdef _UNICODE -#define SP_WIDE_SYSTEM -#endif - -// wchar_t's base type is an unsigned short -#define SP_WCHAR_T_USHORT - -// Enable precompiled header support. -#define SP_PCH -// Don't compile in message text. -#define SP_NO_MESSAGE_TEXT -#endif /* _MSC_VER */ - -#ifdef __WATCOMC__ -// Watcom C++ 10.0a -#define SP_MANUAL_INST -#undef SP_POSIX_FILENAMES -#define SP_MSDOS_FILENAMES -#undef SP_INCLUDE_UNISTD_H -#define SP_INCLUDE_IO_H -#pragma warning 004 9 -#undef huge -// Cannot handle T::~T in template. -#define SP_QUAL_TEMPLATE_DTOR_BROKEN -#define SP_HAVE_SETMODE -#define _setmode setmode -#if __WATCOMC__ < 1050 -#define _O_BINARY O_BINARY -#endif -#define SP_WCHAR_T_USHORT -#endif /* __WATCOMC__ */ - -#ifdef __BORLANDC__ -// Borland C++ 5.0 -#define SP_ANSI_FOR_SCOPE -#define SP_HAVE_RTTI -#define SP_HAVE_SETMODE -#undef SP_INCLUDE_UNISTD_H -#define SP_INCLUDE_IO_H -#undef SP_POSIX_FILENAMES -#define SP_MSDOS_FILENAMES -#define SP_HAVE_BOOL -#define SP_SHORT_HEADERS -#define _O_BINARY O_BINARY -#define _setmode setmode -#define SP_ANSI_CLASS_INST -#define SP_MANUAL_INST -// Building as a DLL doesn't work with Borland C++ yet. -#define SP_DLLEXPORT __declspec(dllexport) -#define SP_DLLIMPORT __declspec(dllimport) -#ifdef SP_USE_DLL -#ifndef BUILD_LIBSP -#define SP_DEFINE_TEMPLATES -#endif -#endif /* SP_USE_DLL */ -#define SP_WCHAR_T_USHORT -#endif /* __BORLANDC__ */ - -#ifdef __IBMCPP__ -// IBM CSet++ 2.1 from Horst Szillat . -#undef SP_POSIX_FILENAMES -#define SP_MANUAL_INST -#define SP_SHORT_HEADERS -#define SP_MSDOS_FILENAMES -#undef SP_INCLUDE_UNISTD_H -#define SP_INCLUDE_IO_H -#define S_IFMT (S_IFDIR|S_IFCHR|S_IFREG) -#endif - -#ifndef SP_ANSI_FOR_SCOPE -// This simulates the new ANSI "for" scope rules -#define for if (0); else for -#endif - -#ifndef SP_DLLEXPORT -#define SP_DLLEXPORT /* as nothing */ -#endif - -#ifndef SP_DLLIMPORT -#define SP_DLLIMPORT /* as nothing */ -#endif - -#ifdef SP_USE_DLL - -#ifdef BUILD_LIBSP -#define SP_API SP_DLLEXPORT -#else -#define SP_API SP_DLLIMPORT -#endif - -#else /* not SP_USE_DLL */ - -#define SP_API /* as nothing */ - -#endif /* not SP_USE_DLL */ - -// SP_WIDE_SYSTEM says that your OS provides wide character interfaces -// SP_WIDE_SYSTEM currently works only with Visual C++ and Windows NT -// SP_WIDE_SYSTEM implies SP_MULTI_BYTE -#ifdef SP_WIDE_SYSTEM -#define SP_MULTI_BYTE -#endif - -#ifdef SP_NAMESPACE -#define SP_NAMESPACE_SCOPE SP_NAMESPACE:: -#else -#define SP_NAMESPACE_SCOPE -#endif - -#endif /* not config_INCLUDED */ diff --git a/cde/programs/nsgmls/constant.h b/cde/programs/nsgmls/constant.h deleted file mode 100644 index 048000aa9..000000000 --- a/cde/programs/nsgmls/constant.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: constant.h /main/1 1996/07/29 17:08:37 cde-hp $ */ -#ifndef constant_INCLUDED -#define constant_INCLUDED 1 - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -const Char charMax = Char(-1); -const WideChar wideCharMax = WideChar(-1); -const UnivChar univCharMax = UnivChar(-1); -const SyntaxChar syntaxCharMax = SyntaxChar(-1); - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* not constant_INCLUDED */ diff --git a/cde/programs/nsgmls/doc/archform.htm b/cde/programs/nsgmls/doc/archform.htm deleted file mode 100644 index 6b48ab944..000000000 --- a/cde/programs/nsgmls/doc/archform.htm +++ /dev/null @@ -1,405 +0,0 @@ - - - - -Architectural Form Processing - - -

Architectural Form Processing

-

-The Hytime standard (ISO/IEC 10744) introduced the concept of -architectural forms. This document assumes you are already familiar -with this concept. The first Technical Corrigendum to HyTime, which is -soon to be published, generalizes this, and makes it possible to have -an architecture engine which can perform architectural form -processing for arbitrary architectures. SP now includes such an -architecture engine. -

-Non-markup sensitive applications built using SP now support -architectural form processing using the -A -archname option. When this option is specified, the -document will be validated against all declared base architectures, -and the output will be for the architectural document for that -architecture: the element types, notations and attributes will be -those defined in the meta-DTD. -

-This option is experimental and has not been subject to much testing. -Please be sure to report any bugs or problems you encounter. -

-Although spam does not support the -A option because it -works with the markup of your document, sgmlnorm does. - -

Architectural Support Attributes

-

-To use the -A option with a document, you must add -

    -
  • -an architecture base declaration for archname, -
  • -a notation declaration and associated attribute definition list -declaration for archname; -this is called the architecture notation declaration. -
-

-An architecture base declaration is a processing instruction of the form: -

-<?ArcBase archname>
-
-

-The processing instruction is recognized either in the DTD or in an -active LPD. -

-The architecture notation declaration and associated attribute -definition list declaration serve to declare a number of architectural -support attributes which control the architecture engine. The value -for each architecture support attribute is taken from the default -value, if any, specified for that attribute in the attribute -definition list declaration. It is an error to declare an -architecture support attribute as #REQUIRED. -

-The following architectural support attributes are recognized: -

-
-ArcDTD -
-The name of an external entity that contains the meta-DTD. -This attribute is required. -If the name starts with the PERO delimiter %, -the entity is a parameter entity, -otherwise it is a general entity. -
-ArcQuant -
-A list of tokens that looks like what follows QUANTITY SGMLREF -in the quantity set section of an SGML declaration. -The quantities used for parsing the meta-DTD -and validating the architectural document -will be the maximum of the quantities in the document's concrete syntax -and the quantities specified here. -
-ArcDocF -
-The name of the document element type in the meta-DTD. -This would be HyDoc for HyTime. -This defaults to archname. -
-ArcFormA -
-The name of the attribute that elements use to specify the -corresponding element type, if any, in the meta-DTD. -Data entities also use this attribute to specify the corresponding -notation in the meta-DTD. -This would be HyTime for HyTime. -This defaults to archname. -
-ArcNamrA -
-The name of the attribute that elements use to specify substitutes for -the names of attributes in the meta-DTD. A value of -#DEFAULT is allowed for a substitute name; this inhibits -mapping of an attribute to an architectural attribute, but specifies -that the value of the architectural attribute should be defaulted -rather than taken from the value of another attribute in the document. -For HyTime the value of this attribute would be HyNames. -By default no attribute name substitutition is done. -
-ArcSuprA -
-The name of an attribute that elements may use to suppress processing -of their descendants. This attribute is not recognized for data -entities. The value of the attribute must be one of the following -tokens: -
-
-sArcAll -
-Completely suppress all architectural processing of descendants. -It is not possible to restore architectural processing -for a descendant. -
-sArcForm -
-Suppress processing of the ArcFormA attribute of all -descendants of this element, except for those elements that have a -non-implied ArcSuprA attribute. -
-sArcNone -
-Don't suppress architectural processing for the descendants of -this element. -
-

-The value may also be implied, in which case the state of -architectural processing is inherited. -

-If an element has an ArcSuprA attribute that was processed, its -ArcFormA attribute will always be processed. Otherwise its ArcFormA -attribute will be processed unless its closest ancestor that has a -non-implied value for the ArcSuprA attribute suppressed processing of -the ArcFormA attribute. An element whose ArcFormA attribute is -processed will not be treated as architectural if it has an implied -value for the ArcFormA attribute. -

-ArcSuprF -
-The name of the element type in the meta-DTD that suppresses -architectural processing in the same manner as does the -sHyTime form in HyTime. By default, no element type -does. This behaves like an element with an -ArcSuprA attribute of sArcForm. The element -type should be declared in the meta-DTD. You should not specify a -value for this attribute if you specified a value for the -ArcSuprA attribute. -

-This is a non-standardized extension. -

-ArcIgnDA -
-The name of an attribute that elements may use to control whether -data is ignored. -The value of the attribute must be one of the following values: -
-
-nArcIgnD -
-Data is not ignored. -It is an error if data occurs where not allowed by the meta-DTD. -
-cArcIgnD -
-Data is conditionally ignored. -Data will be ignored only when it occurs where the meta-DTD -does not allow it. -
-ArcIgnD -
-Data is always ignored. -
-

-The value may also be implied, in which case the state of -architectural processing is inherited. -If no the document element has no value specified, -cArcIgnD will be used. -

-ArcBridF -
-The name of a default element type declared in a meta-DTD, -to which elements in the document should be automatically mapped -if they have an ID and would not otherwise be considered -architectural. -This would be HyBrid for HyTime. -If your meta-DTD declares IDREF attributes, it will -usually be appropriate to specify a value for -ArcBridF, and to declare an ID attribute -for that form in your meta-DTD. -
-ArcDataF -
-The name of a default notation declared in the meta-DTD, -to which the external data entities in the document -should be automatically mapped if they would -not otherwise be considered architectural. -If this attribute is defined, -then general entities will be automatically architectural: -any external data entity whose notation cannot otherwise be mapped -into a notation in the meta-DTD will be automatically treated -as an instance of the ArcDataF notation. -This would be data for HyTime. -If your meta-DTD declares entity attributes, it will usually -be appropriate to specify a value for ArcDataF -even if your meta-DTD declares no data attributes for the -notation. -
-ArcAuto -
-This must have one of the following values: -
-
-ArcAuto -
-If an element does not have an ArcFormA attribute and the -meta-DTD defines an element type with the same name as the element's -type, the element will be automatically treated as being an instance -of the meta-type. This rule does not apply to the -document element type; this is automatically treated as being an -instance of the meta-DTD's document element type. -Note that this automatic mapping is prevented if -the element has an ArcFormA attribute with an implied -value. It is also prevented if processing of the -ArcFormA attribute is suppressed. This applies equally -to the notations of external data entities. -The default element or notation specified with the -ArcBridF or ArcDfltN attribute -is only considered after the mapping specified by ArcAuto. -
-nArcAuto -
-Automatic mapping is not performed. -
-

-The default value is ArcAuto. -

-ArcOptSA -
-A list of names of architectural support attributes, -each of which is interpreted as a list of parameter entities -to be defined with a replacement text of INCLUDE -when parsing the meta-DTD. -The default value is ArcOpt. -
-

Meta-DTDs

-

-A meta-DTD is allowed to use the following extensions: -

    -
  • -a single element type or notation is allowed to be an associated -element type or associated notation name for multiple attribute -definition lists. -
  • -#ALL can be used as an associated element type -or associated notation name in an attribute definition list -to define attributes for all element types or notations -in the meta-DTD -
-

-Before any of these extensions can be used, the meta-DTD must include a -declaration -

-<!AFDR "ISO/IEC 10744:1992">
-
-

-This declaration should only be included if the extensions are used. -

-In all other respects a meta-DTD must be a valid SGML DTD. -

-A declared value of ENTITY for an attribute in a meta-DTD means that -the value of the attribute must be an entity declared in -the (non-meta) DTD that is architectural. -An external data entity is architectural only if its notation can be -mapped into a notation in the meta-DTD. -All other kinds of data entities and subdoc entities are automatically -architectural. -

-An IDREF attribute in the meta-document must have a corresponding ID -in the meta-document. An attribute with a declared value of ID in the -document will be automatically mapped to an attribute with a declared -value of ID in the meta-DTD. -

-A declared value of NOTATION in the meta-DTD means that the value of -the attribute must have one the values specified in the name group and -that it must be a notation in the meta-DTD. -(Perhaps if the attribute also has a declared value of NOTATION -in the non-meta-DTD, the value should be mapped in a similar -way to the notation of an external data entity.) - -

Differences from HyTime

-

-There are a number of differences from how architectural processing is -defined in the pre-Corringendum version of the HyTime standard. -

    -
  • -The ArcNamrA and ArcFormA attributes are not -part of the meta-DTD. Rather they are used by the architecture engine -in deriving the meta-document that is validated against the meta-DTD. -
  • -The use: conventional comment is not recognized. Instead -a single element type is allowed to be an associated element type for -multiple attribute definition lists. -
  • -The notation and data attributes of an external data entity are -treated just like the element type and attributes of an element. The -notation of an external data entity is mapped into a notation in the -meta-DTD and the data attributes of the entity are mapped onto -attributes defined for the meta-DTD notation. -
  • -#FIXED has the same meaning in a meta-DTD that it does in -a regular DTD: the value of the attribute must be the same as the -default value of the attribute specified in the meta-DTD. -
- -

Specifying architectural processing with an LPD

-

-Link attributes defined by an implicit link process are treated in the -same way as non-link attributes. The only complication is that SGML -allows link attributes to have the same name as non-link attributes. -If there is a link attribute and a non-link attribute with the same -name, the architecture engine will only look at the link attribute, -even if the value of the link attribute is implied. The only -exception is the ArcNamrA attribute: the architecture -engine will use both the link attribute and the non-link attribute, -but the substitute names in the value of the non-link attribute cannot -refer to link attribute names. -

-The -A archname option automatically activates -any link type archname. -

-The architecture notation declaration and associated attribute -definition list declaration are allowed in the LPD. Although the -productions of ISO 8879 do not allow a notation declaration in a link -type declaration subset, it is clearly the intent of the standard that -they be allowed. You can use a -wlpd-notation option to -disallow them. - -

Notation set architecture

-

-An architecture for which archname is declared -as a notation with a public identifier of -

-"ISO/IEC 10744//NOTATION AFDR ARCBASE
-Notation Set Architecture Definition Document//EN"
-
-

-is special. The element types in the meta-DTD for this architecture -are the notations of the document DTD and the attributes defined for -the element types in the meta-DTD are the data attributes defined for -the notations in the document DTD. For each element, the attribute -with a declared value of NOTATION performs the function that the -ArcFormA attribute performs for normal architectures. Only the -ArcNamrA and ArcSuprA architectural support -attributes can be used with this architecture. -

-The notation set architecture can also be declared using -an architecture base declaration of the form: -

-<?ArcBase #NOTATION>
-
-

-In this case, no architecture support attributes can be declared; -ArcNamrA will be defaulted to notnames, -and ArcSuprA to notsupr. - -

Derived architectures

-

-A meta-DTD can have one or more base architectures in the same way as -a normal DTD. Multiple -A options can be used to exploit -this. For example, -

--A arch1 -A arch2
-
-

-will perform architectural processing on the source document to -produce an architectural document conforming to the architecture -arch1 declared in the source document, and -will then perform architectural processing on this architectural -document to produce an architectural document conforming to the -arch2 architecture declared in -arch1's meta-DTD. -

-A document that is validated against a meta-DTD will automatically -be validated against any base architectures of that meta-DTD. - -

Not implemented

-

-The following features in the current AFDR draft are not implemented: -

    -
  • -ArcIndr architectural support attribute with value -other than nArcIndr. -
-

-

-James Clark
-jjc@jclark.com -
- - diff --git a/cde/programs/nsgmls/doc/build.htm b/cde/programs/nsgmls/doc/build.htm deleted file mode 100644 index 5834b43df..000000000 --- a/cde/programs/nsgmls/doc/build.htm +++ /dev/null @@ -1,104 +0,0 @@ - - - - -Building SP - - -

Building SP

-

-You will need a C++ compiler with good template support to build this. -Support for exceptions is not required. -

-In most cases you should be able to port to a new compiler just by -editing include/config.h. - -

Unix

-

-To build on Unix, edit the Makefile, and do a make. You can also -build in a different directory. This requires GNU make or another -make that implements VPATH. Copy or link the top-level Makefile to -the build directory, change srcdir in the Makefile to point to the -original directory, and do a make in the build directory. -

-make check runs some tests. You shouldn't get any reports -of differences. -

-make install installs the programs; `make install-man' -installs the man pages. -

-You can use the following compilers: -

-
-gcc -
-gcc 2.7.2 works (gcc 2.7.0 won't work at least on the sparc). You -will also an iostream library (eg as provided by libg++ 2.7). This -distribution builds on Solaris 2.3 and on Linux 1.2. I expect it will -build on SunOS 4 as well with little difficulty. -

-With gcc 2.6.3/SunOS 4, you'll need to compile with --Dsig_atomic_t=int, and, if you want to compile with --DSP_HAVE_SOCKET, you'll need to make netdb.h and arpa/inet.h C++ -compatible. -

-Sun C++ -
-To compile with Sun C++ 4.0.1, run first sunfix.sh. Also in the -top-level Makefile, change set libMakefile to Makefile.lib.sun. -This makes the library build use the -xar option. -
-

-Nelson Beebe has ported SP to a variety of other Unix systems and has -produced some notes -about his experiences. - -

DOS/Windows

-

-You must use a compiler that generates 32-bit code. - -

-

-The following compilers have been tested: -

-
-Visual C++ 4.1 -
-Open SP.mak as a Makefile in the Developer Studio and build whatever -you want. -Don't use Batch Build or Rebuild All: these -rebuild the library repeatedly. -You can build all the targets in a particular configuration by -building the all target. -The sp-generate.mak makefile can be used to make -all the .cxx and .h files that are automatically generated. -(These are included in the distribution, so you don't need to do this -unless you want to modify SP.) -

-To create a new program, make a new project in the SP project -workspace using the Build>Subprojects command, and -include lib and maybe generic as -subprojects. You may also want to add your project as a subproject to -all. -Then, in Build>Settings under the C/C++ -tab in the Preprocessor category, copy the -Preprocessor definitions and Additional include -directories entries from the nsgmls subproject. -In the Code Generation category make sure you've selected -the same run-time library as that used by the corresponding configuration -of lib. -

-Watcom C++ 10.5a -
-Use Makefile.wat. -

-You must compile on a platform that supports long filenames. -

-

-

-James Clark
-jjc@jclark.com -
- - diff --git a/cde/programs/nsgmls/doc/catalog.htm b/cde/programs/nsgmls/doc/catalog.htm deleted file mode 100644 index d0808ea4b..000000000 --- a/cde/programs/nsgmls/doc/catalog.htm +++ /dev/null @@ -1,166 +0,0 @@ - - - - -SP - Catalogs - - -

Catalogs

-

-The entity manager generates a system identifier for every external -entity using catalog entry files in the format defined by SGML Open -Technical Resolution TR9401:1995. The entity manager will give an -error if it is unable to generate a system identifier for an external -entity. Normally if the external identifier for an entity includes a -system identifier then the entity manager will use that as the -effective system identifier for the entity; this behaviour can be -changed using OVERRIDE or SYSTEM entries in -a catalog entry file. -

-A catalog entry file contains a sequence of entries in one of the -following forms: -

-
-PUBLIC pubid sysid -
-This specifies that sysid should be used as -the effective system identifier if the public identifier is -pubid. Sysid is a -system identifier as defined in ISO 8879 and -pubid is a public identifier as defined in ISO -8879. -
-ENTITY name sysid -
-This specifies that sysid should be used as the effective -system identifier if the entity is a general entity whose name is -name. -
-ENTITY %name sysid -
-This specifies that sysid should be used as -the effective system identifier if the entity is a parameter entity -whose name is name. Note that there is no space between -the % and the name. -
-DOCTYPE name sysid -
-This specifies that sysid should be used as -the effective system identifier if the entity is an entity declared in -a document type declaration whose document type name is name. -
-LINKTYPE name sysid -
-This specifies that sysid should be used as the -effective system identifier if the entity is an entity declared in a -link type declaration whose link type name is name. -
-NOTATION name sysid -
-This specifies that sysid should be used as -the effective system identifier for a notation whose name is -name. This is an extension to the SGML Open -format. This is relevant only with the -n option. -
-OVERRIDE bool -
-bool may be YES or -NO. This sets the overriding mode for entries up to the -next occurrence of OVERRIDE or the end of the catalog entry file. At -the beginning of a catalog entry file the overriding mode will be NO. -A PUBLIC, ENTITY, DOCTYPE, LINKTYPE or NOTATION entry with an -overriding mode of YES will be used whether or not the external -identifier has an explicit system identifier; those with an overriding -mode of NO will be ignored if external identifier has an explicit -system identifier. This is an extension to the SGML Open format. -
-SYSTEM sysid1 sysid2 -
-This specifies that sysid2 should be used as the effective -system identifier if the system identifier specified in the external -identifier was sysid1. This is an extension -to the SGML Open format. sysid2 should always be quoted to -ensure that it is not misinterpreted when parsed by a system that does -not support this extension. -
-SGMLDECL sysid -
-This specifies that if the document does not contain an SGML declaration, -the SGML declaration in sysid should be implied. -
-DOCUMENT sysid -
-This specifies that the document entity is sysid. -This entry is used only with the -C option. -
-CATALOG sysid -
-This specifies that sysid is the system -identifier of an additional catalog entry file to be read after this -one. Multiple CATALOG entries are allowed and will be -read in order. This is an extension to the SGML Open format. -
-BASE sysid -
-This specifies that relative storage object identifiers in system -identifiers in the catalog entry file following this entry should be -resolved using first storage object identifier in -sysid as the base, instead of the storage -object identifiers of the storage objects comprising the catalog entry -file. This is an extension to the SGML Open format. This extension -is proposed in Using -SGML Open Catalogs and MIME to Exchange SGML Documents. -Note that the sysid must exist. -
-DELEGATE pubid-prefix sysid -
-This specifies that entities with a public identifier that has -pubid-prefix as a prefix should be resolved -using a catalog whose system identfier is -sysid. For more details, see A Proposal for -Delegating SGML Open Catalogs. This is an extension to the SGML -Open format. -
-

-The delimiters can be omitted from the sysid -provided it does not contain any white space. Comments are allowed -between parameters delimited by -- as in SGML. -

-The environment variable SGML_CATALOG_FILES contains a -list of catalog entry files. The list is separated by colons under -Unix and by semi-colons under MS-DOS and Windows.. These will be -searched after any catalog entry files specified using the --m option, and after the catalog entry file called -catalog in the same place as the document entity. If -this environment variable is not set, then a system dependent list of -catalog entry files will be used. In fact catalog entry files are not -restricted to being files: the name of a catalog entry file is -interpreted as a system identifier. -

-A match in one catalog entry file will take precedence over any match -in a later catalog entry file. A more specific matching entry in one -catalog entry file will take priority over a less specific matching -entry in the same catalog entry file. For this purpose, the order of -specificity is (most specific first): -

    -
  • -SYSTEM entries; -
  • -PUBLIC entries; -
  • -DELEGATE entries ordered by the length of the prefix, -longest first; -
  • -ENTITY, DOCTYPE, LINKTYPE and -NOTATION entries. -
-

-

-James Clark
-jjc@jclark.com -
- - diff --git a/cde/programs/nsgmls/doc/features.htm b/cde/programs/nsgmls/doc/features.htm deleted file mode 100644 index c5ce5db13..000000000 --- a/cde/programs/nsgmls/doc/features.htm +++ /dev/null @@ -1,139 +0,0 @@ - - - - -SP - Features Summary - -

-SP -

-

-A free, object-oriented toolkit for SGML parsing and entity management -

-

-Features summary -

-
    -
  • -Includes nsgmls -
      -
    • -Compatible with sgmls -
    • -Also generates RAST (ISO/IEC 13673) -
    -
  • -Provides access to all information about SGML document -
      -
    • -Access to DTD and SGML declaration as well as document instance -
    • -Access to markup as well as abstract document -
    • -Sufficient to recreate character-for-character identical -copy of any SGML document -
    -
  • -Supports almost all optional SGML features -
      -
    • -Arbitrary concrete syntaxes -
    • -SHORTTAG, OMITTAG, RANK -
    • -SUBDOC -
    • -LINK (SIMPLE, IMPLICIT and EXPLICIT) -
    • -Only DATATAG and CONCUR not supported -
    -
  • -Sophisticated entity manager -
      -
    • -Supports ISO/IEC 10744 Formal System Identifiers -
    • -Supports SGML Open catalogs -
    • -Supports WWW -
    • -Can be used independently of parser -
    -
  • -Supports multi-byte character sets -
      -
    • -Parser can use 16-bit characters internally -
    • -16-bit characters can be used in tag names and other markup -
    • -Supports ISO/IEC 10646 (Unicode) using both UCS-2 and UTF-8 -
    • -Supports Japanese character sets (Shift-JIS, EUC) -
    -
  • -Object-oriented -
  • -Written in C++ from scratch -
      -
    • -Not a modified version of a parser originally written in C -
    • -Reentrant -
    • -Sophisticated architecture -
    -
  • -Fast -
      -
    • -Up to twice as fast as sgmls on large documents -
    -
  • -Portable -
      -
    • -All major Unix variants -
    • -MS-DOS -
    • -Win32: Windows 95/Windows NT -
    • -OS/2 -
    -
  • -Production quality -
      -
    • -Version 1.0 recently released, after a year of test releases -
    • -Tested using several SGML test suites -
    • -Already used in several new commercial products -
    • -Written by James Clark, previously responsible for turning arcsgml into sgmls -
    -
  • -Free -
      -
    • -Includes source code -
    • -No restrictions on commercial use -
    -
  • -Disadvantages -
      -
    • -Programmer-level documentation only for generic API -and not for native API. -
    -
- -

-

-James Clark
-jjc@jclark.com -
- - diff --git a/cde/programs/nsgmls/doc/generic.htm b/cde/programs/nsgmls/doc/generic.htm deleted file mode 100644 index 9e66308ee..000000000 --- a/cde/programs/nsgmls/doc/generic.htm +++ /dev/null @@ -1,1082 +0,0 @@ - - - - -The generic API to SP - - -

The generic API to SP

-

-SP provides a generic API in addition to its native API. The generic -interface is much simpler than the native interface. It is generic in -the sense that it could be easily implemented using parsers other than -SP. It provides all ESIS information as well as some other -information about the instance that is commonly needed by -applications. However, it doesn't provide access to all information -available from SP; in particular, it doesn't provide information about -the DTD. It is also slightly less efficient than the native -interface. -

-The interface uses two related abstract classes. An -SGMLApplication is an object that can handle a number of -different kinds of event which correspond to information in an SGML -document. An EventGenerator is an object that can -generate a sequence of events of the kinds handled by an -SGMLApplication. The -ParserEventGeneratorKit class makes an -EventGenerator that generates events using SP. - -

Types

-

-SGMLApplication has a number of local types that are used -in several contexts: -

-
-Char -
-This typedef is an unsigned integral type that represents a single bit -combination (character). It is unsigned short if -SP_MULTI_BYTE is defined and unsigned char -otherwise. -
-CharString -
-This struct represents a string of Char. -It has the following members: -
-
-const Char *ptr -
-A pointer to the Chars of the string. -
-size_t len -
-The number of Chars in the string. -
-
-Location -
-This struct holds information about a location in the entity structure -of a document. It is constucted using an OpenEntityPtr -and a Position. The CharStrings in it will -remain valid as long as the OpenEntity that is pointed to -by the OpenEntityPtr that was used to construct it -remains valid. -

-It has the following members: -

-
-unsigned long lineNumber -
-The line number. -(unsigned long)-1 if invalid. -
-unsigned long columnNumber -
-The column number. -Note that tabs are not treated specially. -(unsigned long)-1 if invalid. -
-unsigned long byteOffset -
-The number of bytes in the storage object preceding the location. -(unsigned long)-1 if invalid. -
-unsigned long entityOffset -
-The number of bit combinations in the entity preceding the location. -(unsigned long)-1 if invalid. -
-CharString entityName -
-The name of the external entity containing the location. -An empty string if invalid. -
-CharString filename -
-The name of the file containing the location. -An empty string if invalid. -
-const void *other -
-Other implementation-dependent information about the location. In the -SP implementation it will be a pointer to a StorageObjectSpec. 0 if -invalid. -
-

-When a location is in an internal entity, the location of the reference -to the entity will be used instead. -

-OpenEntity -
-This class represents a currently open entity. The only use for an -OpenEntity is, in conjunction with a -Position, to create a Location. An -OpenEntity is accessed using an -OpenEntityPtr. -
-OpenEntityPtr -
-This class is a reference-counted pointer to an OpenEntity. -
-Position -
-This is an integral type that represents a position in an open entity. -The meaning of a Position is completely determined by the -OpenEntity object with which it is associated. The only -use for an Position is, in conjunction with an -OpenEntity, to create a Location. -
-ExternalId -
-This struct represents an external identifier. It has the following -members: -
-
-bool haveSystemId -
-True iff the external identifier included an explicit system identifier. -
-CharString systemId -
-The system identifier included in the external identifier. -Valid only if havePublicId is true. -
-bool havePublicId -
-True iff the external identifier included an explicit public identifier. -
-CharString publicId -
-The public identifier included in the external identifier. -Valid only if havePublicId is true. -
-bool haveGeneratedSystemId -
-True iff a system identifier was generated for the external identifier. -
-
-CharString generatedSystemId -
-The system identifier generated for the external identifier. -Valid only if haveGeneratedSystemId is true. -
-
-Notation -
-This struct represents a notation. -It has the following members: -
-
-CharString name -
-The name of the notation. -
-ExternalId externalId -
-The external identifier of the notation. -
-
-Entity -
-This struct represents an entity. -It has the following members. -
-
-CharString name -
-The name of the entity. -
-Entity::DataType dataType -
-The type of the data of the entity. -

-Entity::DataType is a local enum with the following possible -values: -

-
-Entity::sgml -
-
-Entity::cdata -
-
-Entity::sdata -
-
-Entity::ndata -
-
-Entity::subdoc -
-
-Entity::pi -
-
-
-Entity::DeclType declType -
-The type of the declaration of the entity. -

-Entity::DeclType is a local enum with the following possible -values: -

-
-Entity::general -
-The entity is a general entity. -
-Entity::parameter -
-The entity is a parameter entity. -
-Entity::doctype -
-The entity was declared in a doctype declaration. -
-Entity::linktype -
-The entity was declared in a linktype declaration. -
-
-bool isInternal -
-True iff the entity is internal rather than external. -
-CharString text -
-The replacement text of the entity. -Valid only if isInternal is true. -
-ExternalId externalId -
-The external identifier of the entity. -Valid only if isInternal is false. -
-const Attribute *attributes -
-Pointer to the data attributes of the entity. -Valid only if isInternal is false. -
-size_t nAttributes -
-The number of data attributes of the entity. -Valid only if isInternal is false. -
-Notation notation -
-The entity's notation. -An empty string if the entity has no notation. -Valid only if isInternal is false. -
-
-Attribute -
-This struct represents an attribute. More precisely it represents the -assignment of an attribute value to an attribute name. -It has the following members: -
-
-CharString name -
-The attribute name. -
-Attribute::Type type -
-An enumeration describing the type of the attribute. -

-Attribute::Type is a local type with the following possible -values: -

-
Attribute::invalid -
-The attribute is invalid. -
Attribute::implied -
-The attribute is an impliable attribute for which -no value was specified. -
Attribute::cdata -
-The attribute is a CDATA attribute. -
Attribute::tokenized -
-The attribute is a tokenized attribute. -
-
-Attribute::Defaulted defaulted -
-An enumeration specifying whether the entity was defaulted, and, if -so, how. -This is non-ESIS information. -

-Attribute::Defaulted is a local enum with the following -possible values: -

-
-Attribute::specified -
-The value was explicitly specified. -
-Attribute::definition -
-The value was defaulted from the attribute definition. -
-Attribute::current -
-The value was defaulted using the CURRENT value of the attribute. -
-
-size_t nCdataChunks -
-The number of Attribute::CdataChunks comprising the value -of the attribute. Valid only if type is -cdata. -
-const Attribute::CdataChunk *cdataChunks -
-The Attribute::CdataChunks comprising the value of this attribute. -Valid only if type is cdata. -

-Attribute::CdataChunk is a local struct with the -following members: -

-
-bool isSdata -
-True iff this chunk is the replacement text of an internal SDATA entity. -
-CharString data -
-The data of this chunk. -
-CharString entityName -
-The name of the internal SDATA entity that this chunk is the -replacement text of. Valid only if isSdata is true. -This is non-ESIS information. -
-
-CharString tokens -
-Valid only if type is Attribute::tokenized. -
-bool isId -
-True iff the declared value is ID. -This is non-ESIS information. -
-size_t nEntities -
-The number of entities associated with this attribute. -This will be zero unless the declared value is ENTITY or ENTITIES. -
-const Entity *entities -
-The entities associated with this attribute. -
-Notation notation -
-The notation associated with this attribute. -If the declared value of the attribute is not NOTATION, -then the name member will be an empty string. -
-
-

Events

-

-For each event xyzEvent handled by -SGMLApplication, there is a virtual function of -SGMLApplication named xyz to -handle the event, and a local struct of SGMLApplication -named XyzEvent. -

-Pointers within an event xyzEvent are valid -only during the call to xyz. None of the -structs in events have copy constructors or assignment operators -defined. It is up to the event handling function to make a copy of -any data that it needs to preserve after the function returns. -

-Except as otherwise stated, -the information in events is ESIS information. -All position information is non-ESIS information. -

-There are the following types of event: -

-
-AppinfoEvent -
-Generated for the APPINFO section of the SGML declaration. -The event has the following members: -
-
Position pos -
-The position of APPINFO parameter of the SGML declaration. -
bool none -
-True iff APPINFO NONE was specified. -
CharString string -
-The interpreted value of the minimum literal specified -in the appinfo parameter of the SGML declaration. -Valid only if none is false. -
-
-PiEvent -
-Generated for a processing instruction. -The event has the following members: -
-
-Position pos -
-The position of the processing instruction. -
-CharString data -
-The system data of the processing instuction. -
-CharString entityName -
-If the processing instruction was the result of the -reference to a PI entity, the name of the entity. -If not, an empty string. -This is non-ESIS information. -
-
-StartElementEvent -
-Generated for the start of an element. -The event has the following members: -
-
-Position pos -
-The position of the start of the element. -
-CharString gi -
-The generic identifier of the element. -
-Element::ContentType contentType -
-The type of the element's content. -This is non-ESIS information. -

-Element::ContentType is an enum with the following -possible values: -

-
-Element::empty -
-The element has empty content, either because it was -declared as EMPTY or because there was a #CONREF attribute. -
-Element::cdata -
-The element has CDATA content. -
-Element::rcdata -
-The element has RCDATA content. -
-Element::mixed -
-The element has mixed content. -
-Element::element -
-The element has element content. -
-
-bool included -
-True iff the element was an included subelement -(rather than a proper subelement). -This is non-ESIS information. -
-size_t nAttributes -
-The number of attributes of this element. -
-const Attribute *attributes -
-A pointer to the attributes for this element. -
-
-EndElementEvent -
-Generated for the end of an elemenet. -The event has the following members: -
-
-Position pos -
-The position of the end of the element. -
-CharString gi -
-The generic identifier of the element. -
-
-DataEvent -
-Generated for character data. -The event has the following members: -
-
-Position pos -
-The position of the first character of the data. -
-CharString data -
-The data. -
-
-SdataEvent -
-Generated for a reference to an internal sdata entity in content. -The event has the following members: -
-
-Position pos -
-The position of the entity reference. -
-CharString text -
-The replacement text of the entity. -
-CharString entityName -
-The entity name. -This is non-ESIS information. -
-
-ExternalDataEntityRefEvent -
-Generated for a reference to an external data entity. -The event has the following members: -
-
-Position pos -
-The position of the entity reference. -
-Entity entity -
-The referenced entity. -
-
-SubdocEntityRefEvent -
-Generated for a reference to a subdoc entity. -The event has the following members: -
-
-Position pos -
-The position of the entity reference. -
-Entity entity -
-The referenced entity. -
-
-StartDtdEvent -
-Generated at the start of a document type declaration. -This is non-ESIS information. -The event has the following members: -
-
-Position pos -
-The position of the start of the document type declaration. -
-CharString name -
-The document type name. -
-bool haveExternalId -
-The external identifier for the entity declared in the document type -declaration. -
-ExternalId externalId -
-Valid iff haveExternalId is true. -
-
-EndDtdEvent -
-Generated at the end of a document type declaration. -This is non-ESIS information. -The event has the following members: -
-
-Position pos -
-The position of the end of the DTD. -
-CharString name -
-
-
-EndPrologEvent -
-Generated at the end of the prolog. -The event has the following members: -
-
-Position pos -
-The position of the start of the instance. -
-
-GeneralEntityEvent -
-Generated for each general entity in the name space of the governing -doctype, but only if the -ParserEventGeneratorKit::outputGeneralEntities option is -enabled. This is non-ESIS information. The event has the following -members: -
-
-Entity entity -
-The entity. -
-

-No event will be generated for the declaration of the -#default entity; instead an event will be generated when -an entity reference uses the #default entity if that is -the first time on which an entity with that name is used. This means -that GeneralEntityEvent can occur after the end of the -prolog. -

-CommentDeclEvent -
-Generated for each comment declaration in the instance, but only if -ParserEventGeneratorKit::outputCommentDecls option is -enabled. This is non-ESIS information. The event has the following -members: -
-
-Position pos -
-The position of the start of the comment declaration. -
-size_t nComments -
-The number of comments in the comment declaration. -
-const CharString *comments -
-The content of each comment in the declaration. -This excludes the com delimiters. -
-const CharString *seps -
-The separator following each comment in the declaration. -
-
-MarkedSectionStartEvent -
-Generated for the start of a marked section in the instance, -but only if the ParserEventGeneratorKit::outputMarkedSections -option is enabled. -This is non-ESIS information. -The event has the following members: -
-
-Position pos -
-The position of the start of the marked section declaration. -
-MarkedSectionStartEvent::Status status -
-The effective status of the marked section. -

-MarkedSectionStartEvent::Status is a local enum with the -following possible values: -

    -
  • MarkedSectionStartEvent::include -
  • MarkedSectionStartEvent::rcdata -
  • MarkedSectionStartEvent::cdata -
  • MarkedSectionStartEvent::ignore -
-
-size_t nParams -
-The number of top-level parameters in the status keyword specification. -
-const MarkedSectionStartEvent::Param *params -
-The top-level parameters in the status keyword specification. -

-Param is a local struct with the following members: -

-
-MarkedSectionStartEvent::Param::Type type -
-The type of top-level parameter: -

-MarkedSectionStartEvent::Param::Type is a local enum with the -following possible values: -

-
-MarkedSectionStartEvent::Param::temp -
-MarkedSectionStartEvent::Param::include -
-MarkedSectionStartEvent::Param::rcdata -
-MarkedSectionStartEvent::Param::cdata -
-MarkedSectionStartEvent::Param::ignore -
-The parameter is the corresponding keyword. -
-MarkedSectionStartEvent::Param::entityRef -
-The parameter is an entity reference. -
-
-CharString entityName -
-Valid when type is -MarkedSectionStartEvent::Param::entityRef. -
-
-
-MarkedSectionEndEvent -
-Generated for the end of a marked section in the instance, but only if -the ParserEventGeneratorKit::outputMarkedSections option is -enabled. This is non-ESIS information. The event has the following -members: -
-
-Position pos -
-The position of the end of the marked section declaration. -
-MarkedSectionEndEvent::Status status -
-The effective status of the marked section. -

-MarkedSectionEndEvent::Status is a local enum with the -following possible values: -

    -
  • MarkedSectionEndEvent::include -
  • MarkedSectionEndEvent::rcdata -
  • MarkedSectionEndEvent::cdata -
  • MarkedSectionEndEvent::ignore -
-
-
-IgnoredCharsEvent -
-Generated for a sequence of characters in an ignored marked section in -the instance, but only if the -ParserEventGeneratorKit::outputMarkedSections option is -enabled. This is non-ESIS information. The event has the following -members: -
-
-Position pos -
-The position of the first of the ignored characters. -
-CharString data -
-The ignored characters. -
-
-ErrorEvent -
-Generated for each error detected by the parser, -and also for any other cases where the parser produces a message. -This is non-ESIS information. -It has the following members: -
-
-Position pos -
-The position at which the error was detected. -
-ErrorEvent::Type type -
-The type of error. -

-ErrorEvent::Type is a local enum with the following possible -values: -

-
-ErrorEvent::quantity -
-Exceeding a quantity limit. -
-ErrorEvent::idref -
-An IDREF to a non-existent ID. -
-ErrorEvent::capacity -
-Exceeding a capacity limit. -
-ErrorEvent::otherError -
-Any other kind of error. -
-ErrorEvent::warning -
-A warning. Not actually an error. -
-ErrorEvent::info -
-An informational message. Not actually an error. -
-
-CharString message -
-The message produced by the parser. -If messages are not disabled, this will be the same as the message -printed to standard error. -
-
-

-SGMLApplication also has a virtual function -

-void openEntityChange(const OpenEntityPtr &);
-
-

-which is similar to an event. An application that wishes to makes use -of position information must maintain a variable of type -OpenEntityPtr representing the current open entity, and -must provide an implementation of the openEntityChange -function that updates this variable. It can then use the value of -this variable in conjunction with a Position to obtain a -Location; this can be relatively slow. Unlike events, an -OpenEntityPtr has copy constructors and assignment -operators defined. - -

EventGenerator

-

-The EventGenerator interface provides the following -functions: -

-
-unsigned run(SGMLApplication &app) -
-Generate the sequence of events, calling the corresponding member of -app for each event. Returns the number of -errors. This must not be called more than once for any -EventGeneratorobject. -
- -EventGenerator *makeSubdocEventGenerator(const SGMLApplication::Char *s, size_t n) - -
-Makes a new EventGenerator for a subdocument of the -current document. s and n together specify the -system identifier of the subdocument entity. These should usually be -obtained from the generatedSystemId member of the -externalId member of the Entity object for -the subdocument entity. This function can only be called after -run has been called; the call to run need -not have returned, but the SGMLApplication - -must have been passed events from the prolog or instance (ie the SGML -declaration must have been parsed). -
-void inhibitMessages(bool b) -
-If b is true, disables error and warning messages, -otherwise enables them. Initially errors and warnings are enabled. -This function may be called at any time, including while -run() is executing. -
-void halt() -
-Halt the generation of events by run(). -This can be at any point during the execution of run(). -It is safe to call this function from a different thread from that which -called run(). -
-

ParserEventGeneratorKit

-

-The ParserEventGeneratorKit class is used to create an -EventGenerator that generate events using SP. It -provides the following members: -

-
-EventGenerator *makeEventGenerator(int nFiles, char *const *files) -
-This returns a new EventGenerator that will generate events -for the SGML document whose document entity is contained in the -files. -The returned EventGenerator should be deleted when it -is no longer needed. -makeEventGenerator may be called more than once. -
-void setOption(ParserEventGeneratorKit::Option opt) -
-This can be called any time before makeEventGenerator() is called. -

-ParserEventGeneratorKit::Option is a local enum with the following possible -values: -

-
-ParserEventGeneratorKit::showOpenEntities -
-This corresponds to the -e option of nsgmls. -
-ParserEventGeneratorKit::showOpenElements -
-This corresponds to the -g option of nsgmls. -
-ParserEventGeneratorKit::outputCommentDecls -
-This will cause CommentDeclEvents to be generated. -
-ParserEventGeneratorKit::outputMarkedSections -
-This will cause -MarkedSectionStartEvents, -MarkedSectionStartEvents -and IgnoredCharsEvents -to be generated. -
-ParserEventGeneratorKit::outputGeneralEntities -
-This will cause GeneralEntityEvents to be generated. -
-
- -void setOption(ParserEventGeneratorKit::OptionWithArg opt, const char *arg) - -
-This can be called any time before makeEventGenerator() is called. -

-ParserEventGeneratorKit::OptionWithArg is a local enum with the following possible -values: -

-
-ParserEventGeneratorKit::addCatalog -
-This corresponds to the -m option of nsgmls. -
-ParserEventGeneratorKit::includeParam -
-This corresponds to the -i option of nsgmls. -
-ParserEventGeneratorKit::enableWarning -
-This corresponds to the -w option of nsgmls. -
-ParserEventGeneratorKit::addSearchDir -
-This corresponds to the -D option of nsgmls. -
-
- -

Using the interface

-

-Creating an application with this interface involves the following steps: -

    -
  • -Derive a class from SGMLApplication, -called, say, MyApplication. -
  • -For each kind of event FooEvent that the application -needs information from, define a member of MyApplication -void MyApplication::foo(const FooEvent &). -
  • -Declare an object of type ParserEventGeneratorKit. -
  • -Optionally set options for the ParserEventGeneratorKit using -ParserEventGeneratorKit::setOption. -
  • -Create an EventGenerator using -ParserEventGeneratorKit::makeEventGenerator. -
  • -Create an instance of MyApplication -(usually on the stack). -
  • -Call EventGenerator::run passing it a reference to -the instance of MyApplication. -
  • -Delete the EventGenerator. -
-

-The application must include the ParserEventGeneratorKit.h -file (which in turn includes EventGenerator.h and -SGMLApplication.h), which is in the generic -directory. If your compiler does not support the standard C++ -bool type, you must ensure that bool is -defined as a typedef for int, before including this. One -way to do this is to include config.h and then -Boolean.h from the lib subdirectory of the SP -distribution. -

-On Unix, the application must be linked with the -lib/libsp.a library. - -

Example

-

-Here's a simple example of an application that uses this interface. -The application prints an outline of the element structure of a -document, using indentation to represent nesting. -

-// The next two lines are only to ensure bool gets defined appropriately.
-#include "config.h"
-#include "Boolean.h"
-
-#include "ParserEventGeneratorKit.h"
-#include <iostream.h>
-
-ostream &operator<<(ostream &os, SGMLApplication::CharString s)
-{
-  for (size_t i = 0; i < s.len; i++)
-    os << char(s.ptr[i]);
-  return os;
-}
-
-class OutlineApplication : public SGMLApplication {
-public:
-  OutlineApplication() : depth_(0) { }
-  void startElement(const StartElementEvent &event) {
-    for (unsigned i = 0; i < depth_; i++)
-      cout << "    ";
-    cout << event.gi << '\n';
-    depth_++;
-  }
-  void endElement(const EndElementEvent &) { depth_--; }
-private:
-  unsigned depth_;
-};
-
-int main(int argc, char **argv)
-{
-  ParserEventGeneratorKit parserKit;
-  // Use all the arguments after argv[0] as filenames.
-  EventGenerator *egp = parserKit.makeEventGenerator(argc - 1, argv + 1);
-  OutlineApplication app;
-  unsigned nErrors = egp->run(app);
-  delete egp;
-  return nErrors > 0;
-}
-
-

-There's a bigger example in the sgmlnorm directory in the SP -distribution. -This uses the SGMLApplication interface, but it doesn't -use the ParserEventGeneratorKit interface. -

-

-James Clark
-jjc@jclark.com -
- - diff --git a/cde/programs/nsgmls/doc/ideas.htm b/cde/programs/nsgmls/doc/ideas.htm deleted file mode 100644 index 2be7c56b2..000000000 --- a/cde/programs/nsgmls/doc/ideas.htm +++ /dev/null @@ -1,489 +0,0 @@ - - - - -Ideas for improving SP - - -

Ideas for improving SP

-

-Parser -

-

-Have option (fixedDocCharset) in which document charcater set cannot -be changed by SGML declaration; declared document character set used -for character references, and to determine which characters are -non-SGML. Would need separate event for non-SGML character. -In Text would need separate TextItem for non-SGML data. -Disallow non-SGML charcters in internal entities. -

-Supporting caching across multiple runs of parser in single -process. -

-Make Dtd copiable. -

-?Subdoc parser needs character set for system id (should be system -character set). -

-Recover better from non-existent documents or subdocuments. -

-Think about entity declarations/references in inactive LPDs. -

-Don't allow name groups in parameter entity references in document -type specifications in start-/end-tags. -

-With link, don't do a pass 2 unless we replace a referenced entity -(what about default entity?). -

-Options to warn about things that HTML disallows: marked sections in -instance, explicit subsets. -

-Option to warn about MDCs in comments in comment declarations. -

-Option to warn about omitted REFC. -

-Check that names of added functions are valid names in concrete syntax -(both characters and lengths). Also need to do upper-case -substitution on them? -

-Recover from nested doctype declaration intelligently. -

-Recover from missing doctype declaration intelligently. -

-Could optimize parsing of attribute literals using technique similar -to extendData(). -

-attributeValueLength error should give actual length of value. -

-Recover better from entity reference with name group in literal. -

-At start of pass 2 clear everything in pass1LPDs except entity sets. -

-Give an error if EXPLICIT > 1 and LPDs don't chain as required by -436:5-7 and 436:18-20. -

-Handle quantity errors by reporting at the end of the prolog and the -end of the instance any quantities that need to be increased. -

-Make noSuchReservedName error more helpful. -

-Function characters should perform their function even when markup -recognition is suppressed. (I think I've handled this.) -

-Give a warning for notation attribute that is #CONREF. -

-Try to separate out Parser::compileModes(). -

-In CompiledModelGroup have vector that gives an index for each element type -that occurs in the model group. Then in each leaf content token have a -vector that maps this index to a LeafContentToken *, if there -is a simple transition (no and groups involved) to that element type. -

-MatchState::minAndDepth and MatchState::AndInfo should be separated -off info object pointed to from MatchState; pointer would be null for -elements with no AND groups. -

-What to do if we encounter USELINK or USEMAP declaration after DTD in -prolog? Should stop prolog and start DTD. If we have SCOPE INSTANCE -then if we get an unknown declaration type in prolog, don't give -error, but unget token and start instance. -

-?Have separate version of reportNonSgml() for case where datachar is allowed. -

-Implement CONCUR. -

-AttributeDefinition constructors should have Owner<DeclaredValue> &, -arguments to avoid storage leaks when exceptions are thrown. -

-Create a list like IList but which keeps track of length. Then -combine tagLevel into openElement stack, and inputLevel into -inputStack. -

-AttributeDefinition::makeValue should return -ConstResourcePointer<AttributeValue>. -

-Syntax member functions should use reference for result. -

-Have a LocationKey data structure that can be used to determine the -relative order of locations in possibly different concurrent -instances. Contains: offset in document instance; is it a replacement -of named character reference; for each entity and numeric character -reference: location in entity and index of dtd in which instance is -declared. -

-On systems with fixed stacks, avoid unlimited stack growth: hard -limits on number of SUBDOCS and GRPLVL. -

-With extendData and extendS don't extend more than some fixed amount -(eg 1024), otherwise could overrun InputSource buffer on 16-bit -system. -

-Have a location in ElementType saying where the first mention of the -element name was. Useful for giving warnings about undefined -elements. -

-How to detect 310:8-10? -

-AttributeSemantics should return const pointers rather than ResourcePointer's -

-Rename Parser -> ParserImpl SgmlParser -> Parser -Syntax::isB -> Syntax::isBlank -

-What mode should be used for parsing other prolog after document element? -

-Flag out of context data. -

-Provide mechanism to allow character names to be mapped onto universal -character numbers. -

-Provide mechanism to allow specification of wbat characters are -control characters (for the purposes of SHUNCHAR controls). -

-With SCOPE INSTANCE, which syntax should be used for delimiters in -bracketed text entities? -

-Better error messages for ambiguous delimiters. -

-Do we need both EndLpd and ComplexLink/SimpleLink events? -

-What to do about 457:19-21? -

-Rename lpd_ to activeLpd_; allLpd_ to lpd_. -

-Test for validity of character numbers in syn ref charset (perhaps -unnecessary, because bad numbers won't be translateable into doc -charset). -

-Option to read bootstrap character set from entity. -

-In AttributeDefinitionList have a flag that is true if any checking of -unspecified values in attribute list is needed (ie CURRENT, REQUIRED, -non-implied ENTITY, non-implied NOTATION). In this case can avoid -running over attributes in AttributeList::finish, by computing value -only when user calls Attribute::value(). -

-Construct link attributes from definition if no applicable link rule. -(RAST maybe doesn't want this. Make it a separate method in LinkProcess and -use in SgmlsEventHandler. Very useful with ArcEngine.) -

-Shouldn't have OpenElementInfo in Message. Instead use RTTI. -

-noSuchAttribute: include gi in message; if element is undefined, don't -give error at all -

-noSuchAttributeToken: say what element or entity -

-nonExistentEntityRef should say document/link type -

-Distinguish errors that are totally recoverable. -

-Find better way to unpack entity information in entity attribute. - -

-Entity Manager -

-

-Avoid requiring that BASE sysid exist. -

-When FSI has only a single storage manager and that is a literal, -return an InternalInputSource. -

-Allow user of InputSource to specify what bit combinations they -want to see for RS and RE. -

-Have environment variable SP_INPUT_BCTF that overrides SP_BCTF for -input. -

-Avoid using numeric character references for all characters in storage -object identifier of literal storage manager in effective system -identifier. -

-Instead of registering coding system pass CodingSystemKit that can create -that can create coding systems. -

-Need BCTF entry in catalog that specifies default BCTF. -

-Have catalog entry that describes internet charset as BCTF plus PUBLIC -identifier of SGML character set; then have charset= storage attribute -that does the translation. -

-An SOEntityCatalog should consist of a Vector<ConstPtr<EntityCatalog> -> which can be shared between several catalogs. This would facilitate -> caching. -

-Maybe need to be able to specify two types of catalog entry file: one -used for all documents; one used for this document alone. -

-Allow end-tags in FSIs. Support alternative SOSs. -

-Character sets in the catalog need rethinking. Also character set of -ParsedSystemId::Map::publicId. -

-Allow for HTTP proxy. -

-Cache catalogs. -

-Use Microsoft ActiveX (formerly Sweeper) DLL on Win95 or NT. -

-Implement DTDDECL catalog entry. -

-Support FILE URLs. -

-Perhaps don't want to do searching for catalog files (and perhaps -command line files). -

-Provide mechanism for specifying when (if at all) base dir is searched -relative to other dirs. -

-Provide extension to catalog format to distinguish entities declared -in non-base DTDs. Perhaps precede entity name by document type name -surrounded by GRPO/GRPC delimiters. -

-URLStorageManager should use a DescriptorManager shared with -PosixStorageManager. -

-URLStorageManager::resolveRelative should delete "xxx/../" and "./" -components. Might also be a good idea to resolve host names. -

-Implement JIS encoding system (what should be done with half-width yen -and overbar in JIS-Roman? translate to Unicode). -

-ExternalInfoImpl::convertOffset: when the position is the character -past the last character and the last character was a newline, line -number should be number of lines + 1. -

-Try harder to rewind in StdioStorageObject. -

-charset= storage attribute that infers BCTF from MIME charset assuming -10646 document character set. - -

-Generic -

-

-Provide mechanism to access data entities using generated system id. -

-Support IMPLICIT/SIMPLE LINK. -

-Character set information. -

-Need to know space character that separates token. Alternatively -provide broken down view of tokens. -

-Need to know IDREF (and other declared values)? - -

-nsgmls -

-

-Problem with "\#n;" escape sequence is that it might get used other -than in data. Probably should get rid of this feature, and give -a warning when there's an unencodable character. - -

-Internal -

-

-Make all macros that occur in headers begin with SP. -

-Make sure all files use #pragma i/i. -

-Get rid of assumption that Vector<T>::size_type, String<T>::size_type -is size_t. -

-Maybe align Owner with auto_ptr. -

-Get rid of uses of string as identifier. -

-?Maybe support non-const copy constructors for NCVector/Owner. -

-Get rid of asEntityOrigin (as far as possible). Make -InputSourceOrigin::defLocation virtual on origin. Avoid excessive use -of asInputSourceOrigin. -

-Hash should define Hash(String<unsigned char>), -Hash(String<unsigned short>) etc. -

-Invert sense of SP_HAVE_BOOL define. -

-Get rid of OutputCharStream::open. Instead have -OutputCharStream::setEncoding. (Perhaps make a friend so we can use -ostream if we're not interested in encodings.) Allow use of ostream -instead of OutputCharStream. Change ParserToolkit::errorStream_'s coding -system when we change the coding system. -

-Support 32-bit Char. Need to fix XcharMap and SubstTable. -Detemplatize SubstTable. Then support UTF-16. -

-Have a common version of Ptr for things that have a virtual -destructor. -

-Have a common version of Owner for all things that have a virtual -destructor. -

-Inheritance in AttributeSemantics unnecesary. -

-Rename ISet -> RangeSet. -

-ISet and RangeMap should use binary search. -

-Better hash function for wide characters. -

-OutputCharStream should canonically use RS/RE and translate to system -newline char with raw option that prevents this. -

-Avoid having Entity.h depend on ParserState, perhaps by double -dispatching. -

-Add uses of explicit keyword. -

-When generating message.h file; if we don't have .cxx file and -namespaces are supported, use anonymous namespace. - -

-Application framework -

-

-Only use static programName for outOfMemory message. -

-Need to use AppChar *const * not AppChar ** in CmdLineApp. -

-When reporting message with MessageEventHandler need to be able to -update error count. -

-Option argument names need to be internationalized. -

-Support response files for DOS. -

-Sort options in usage message. -

-StringMessageArg should be associated with a character set (in -particular, need to distinguish parser character sets from -StorageManager character sets). -

-Should translate StringMessageArg from document character set to -system character set. Have MessageReporter::setDocumentCharacter -function. -

-In MessageReporter, maybe distinguish messages coming from the parser. -

-Don't ever give a non-existent file as a location in a error message. -

-Text of messages should be able to specify that an open quote or close -quote should be inserted at a particular point. -

-When outputting a StringMessageArg translate \r to \n. -

-Make sure wild cards work in VC++ and MS-DOS. - -

-Win32 -

-

-Compilers can typically eliminate unused templates. Reengineer Vector -to reduce code size with such compilers. -

-Store messages in resources; requires numeric tags for messages. -

-Should automatically register all available code pages. -

-Make use of IsTextUnicode() API. -

-Have StorageManager that uses Win32 API directly. Would avoid limits -on number of open files. Also use flag that says file is being -accessed sequentially. -

-Allow DTDs to be compiled into binary by having storage manager that -uses resource ids. - -

-Architecture engine -

-

-Should give an error with -A if the specified arch does not exist. -

-Interpret APPINFO parameter, and automatically enable architectural -processing based on this. -

-Handle derived architecture support attributes. -

-When doing architectural processing in link type, not possible to have -notation declaration, so need some other way to specify public -identifier for architecture. -

-Allow DOCTYPE to be declared inline (as with CONCUR or EXPLICIT LINK). -

-Grok conventional comments. -

-Make work automatically with EventHandlers that process subdoc. Make -references to subdocs architectural. -

-Support different SGML declaration for meta-DTD. -

-Maybe should map internal sdata/cdata entities to copies in meta-DTD. -

-Perhaps when getting open element info should indicate that gis are -architectural. -

-Think about references to SDATA entities in default values in meta-DTD. -

-Add default entity from real DTD to meta-DTD. -

-Tokenize ArcForm attribute appropriately. -

-Make special case for parsing DTD when entity can't be accessed. -

-Try to provide extension that would allow architecture elements be -asynchronous with actual elements? This would provide CONCUR -functionality. - -

-sgmlnorm -

-

-Avoid bogus newline from invalid empty document. -

-Avoid always escaping >. -

-Option to say whether to use character references for 8-bit characters. -

-Option to output implied attributes. -

-Option to output all non-implied attributes. -

-Option to omit attribute name with name tokens. -

-Protect against recognition of short references. -

-Option to preserve CDATA entity references. -

-Option to output general entity declarations in DTD subset -(but what about data attributes)? - -

-spam -

-

-Option to normalize names. -

-Add comments round expanded entities to prevent false delimiter -recognition. -

-Add newline at the end if last thing was omitted tag. -

-Option to warn about changes in internal entities when not expanding. - -

-Documentation -

-

-Error message format. -

-<catalog> FSI tag. -

-

-James Clark
-jjc@jclark.com -
- - diff --git a/cde/programs/nsgmls/doc/index.htm b/cde/programs/nsgmls/doc/index.htm deleted file mode 100644 index cfadff9bc..000000000 --- a/cde/programs/nsgmls/doc/index.htm +++ /dev/null @@ -1,94 +0,0 @@ - - - - -SP - - -

SP

-

-An SGML System Conforming to International Standard ISO 8879 -- -Standard Generalized Markup Language -

-

-The following documents are available: -

-

-

-There is a mailing list for programmer-level discussions of SP. Mail -subscription requests sp-prog-request@jclark.com. -Messages for the list should go to sp-prog@jclark.com. -

-For information about SGML, see -

-

-I would like to hear about any bugs you find in SP. When reporting a -bug, please always include a complete self-contained file that will -enable me to reproduce the bug. I am also interested in receiving -suggestions for improvements to SP no matter how small. -

-

-James Clark
-jjc@jclark.com -
- - diff --git a/cde/programs/nsgmls/doc/new.htm b/cde/programs/nsgmls/doc/new.htm deleted file mode 100644 index d2b400a4c..000000000 --- a/cde/programs/nsgmls/doc/new.htm +++ /dev/null @@ -1,166 +0,0 @@ - - - - -What's new in SP? - - -

What's new?

-

-This document describes recent user-visible changes in SP. Bug fixes -are not described. - -

Version 1.1

-

-There is now generalized support for architectural form processing. -

-Documentation is now in HTML format. -

-A BASE catalog entry can be used to specify a base system identifier -for resolving relative storage object identifiers occurring in the -catalog. -

-A LITERAL storage manager is now provided. -

-Programs have a -E option that sets the maximum number of errors. -

-A DELEGATE catalog entry allows distributed resolution of public -identifiers. -

-nsgmls has a -B (batch mode) option that allows you to parse multiple -documents with a single invocation of nsgmls. -

-In nsgmls the -c option now specifies a catalog as it does in spam and -sgmlnorm, in addition to the -m option that previously did this. -

-The -n option has been replaced by a --onotation-sysid which applies to nsgmls only, and a --wnotation-sysid which applies generally. -

-SP can be built as a DLL under Win32. - -

Version 1.0

-

-The syntax of system identifiers has completely changed. The new -syntax is based on the syntax of formal system identifiers defined in -ISO/IEC 10744 (HyTime) Technical Corrigendum 1, Annex D. -

-The NSGMLS_CODE environment variable has been renamed to SP_BCTF. -nsgmls has a -b option to specify the bit combination transformation -format to be used for output. -

-A list of directories in which files specified in system identifiers -should be searched for can be specified using the environment variable -SGML_SEARCH_PATH or the option -D. -

-Individual SYSTEM identifiers in external identifiers can be -overridden using SYSTEM entries in the catalog. -

-The OVERRIDE catalog entry now takes a YES/NO argument. (This change -was required for conformance to the SGML Open TR.) It applies to each -entry individually rather than to the entire catalog. -

-The -w options of nsgmls and spam have been enhanced. In spam, the -w -option takes an argument as with nsgmls. There are new warnings for -minimized start and end tags (-wunclosed, -wempty, -wnet and --wmin-tag); for unused short reference maps (-wunused-maps); for -unused parameter entities (-wunused-param). -wall now doesn't include -those warnings that are about conditions that, in the opinion of the -author, there is no reason to avoid. A warning can be turned off by -using its name prefixed by no-; thus -wmin-tag -wno-net is equivalent -to -wunclosed -wempty. The -w option is also used to turn off errors: --wno-idref replaces the -x option; -wno-significant replaces the -X -option. -

-In the output of nsgmls, characters that cannot be represented in the -encoding translation specified by the NSGMLS_BCTF environment variable -are represented using an escape sequence of the form \#N; when N is a -decimal integer. -

-In the multi-byte versions of nsgmls there are new BCTFs is8859-N -for N = 1,...,9. -

-There is a -o option to nsgmls which makes it output additional -information: -oentity outputs information about all entities; -oid -distinguish attributes with a declared value of id; -oincluded -distinguishes included subelements. -

-nsgmls now automatically searches for a catalog entry file called -"catalog" in the same place as the document entity. Note that when -the document entity is specified with a URL, this matches the -behaviour of Panorama. -

-A catalog entry file can contain CATALOG entries specifying additional -catalog entry files. This matches the behaviour of Panorama. -

-The parser can now make available to an application complete -information about the markup of prologs and SGML declarations. It -would now be possible, for example, to use SP to write a DTD editor. -spam exploits this to a limited extent: if the -p option is specified -twice, then parameter entity references between declarations will be -expanded; the -mreserved option puts all reserved names in upper-case; -with the -mshortref option short reference use declarations and short -reference mapping declarations will be removed; attribute -specification lists in data attribute specifications in entity -declarations can be normalized like attribute specification lists in -start-tags; with -mms it resolves IGNORE/INCLUDE marked sections. -

-nsgmls has a -C option which causes the command line filenames to be -treated as a catalog whose DOCUMENT entry specifies the document -entity. -

-nsgmls has a -n option which causes it to generate system identifiers -for notations in the same way as it does for entities. -

-spam now has a -f option like nsgmls. -

-The interface between the parser and entity manager has been -redesigned so that the entity manager can be used independently of the -parser. This is exploited by a new program called spent that prints -an entity with a specified system identifier on the standard output. -

-In most cases, a Control-Z occurring as the last byte in a file will -be stripped. This is controlled by the zapeof attribute in formal -system identifiers. - -

Version 0.4

-

-External concrete syntaxes, character sets and capacity sets are -supported using PUBLIC entries in catalog files. The multicode code -core and reference syntaxes are no longer built-in. Only a few -character sets are now built-in. -

-Within external concrete syntaxes, various useful extensions are -permitted. In particular, an ellipsis syntax is allowed for the -specification of name characters and single character short -references. It is now practical to specify tens of thousands of -additional name characters. -

-The default SGML declaration is more permissive. -

-nsgmls has a -x option that inhibits checking of idrefs. -

-nsgmls has a -w option that can enable additional warnings. In -particular, -wmixed will warn about mixed content models that do not -allow #pcdata everywhere. -

-The meaning of the f command in the output of nsgmls has changed -slightly. It now gives the effective system identifier of the entity. -

-The functionality of the rast program has been merged into the nsgmls -program and the rast program has been removed. The -t option makes -nsgmls generate a RAST result. -

-spam has a -l option that uses lower-case for added names that were -subject to upper-case substitution. -

-spam has a -mcurrent option that adds omitted attribute specifications -for current attributes. -

-

-James Clark
-jjc@jclark.com -
- - diff --git a/cde/programs/nsgmls/doc/nsgmls.htm b/cde/programs/nsgmls/doc/nsgmls.htm deleted file mode 100644 index 9f52043a4..000000000 --- a/cde/programs/nsgmls/doc/nsgmls.htm +++ /dev/null @@ -1,448 +0,0 @@ - - - - -NSGMLS - - -

NSGMLS

-

-An SGML System Conforming to -International Standard ISO 8879 --
-Standard Generalized Markup Language -

-

-SYNOPSIS -

-

-nsgmls -[ --BCdeglprsuv -] -[ --alinktype -] -[ --bbctf -] -[ --csysid -] -[ --Ddirectory -] -[ --Emax_errors -] -[ --ffile -] -[ --iname -] -[ --ooutput_option -] -[ --tfile -] -[ --wwarning_type -] -[ -sysid... -] -

DESCRIPTION

-

-Nsgmls parses and validates -the SGML document whose document entity is specified by the -system identifiers -sysid... -and prints on the standard output a simple text representation of its -Element Structure Information Set. -(This is the information set which a structure-controlled -conforming SGML application should act upon.) -If more than one system identifier is specified, -then the corresponding entities will be concatenated to form -the document entity. -Thus the document entity may be spread amongst several files; -for example, the SGML declaration, prolog and document -instance set could each be in a separate file. -If no system identifiers are specified, then -nsgmls -will read the document entity from the standard input. -A command line system identifier of -- -can be used to refer to the standard input. -(Normally in a system identifier, -<osfd>0 -is used to refer to standard input.) -

OPTIONS

-

-The following options are available: -

-
--alinktype -
-Make link type -linktype -active. -Not all ESIS information is output in this case: -the active LPDs are not explicitly reported, -although each link attribute is qualified with -its link type name; -there is no information about result elements; -when there are multiple link rules applicable to the -current element, -nsgmls -always chooses the first. -
--bbctf -
-Use the BCTF named -bctf -for output. -
--B -
-Batch mode. -Parse each sysid... specified on the command -line separately, rather than concatenating them. -This is useful mainly with -s. -

-If -tfilename is also specified, then -the specified filename will be prefixed -to the sysid to make the filename -for the RAST result for each sysid. -

--csysid -
-Map public identifiers and entity names to system identifiers -using the catalog entry file whose system identifier is -sysid. -Multiple --c -options are allowed. -If there is a catalog entry file called -catalog -in the same place as the document entity, -it will be searched for immediately after those specified by --c. -
--C -
-The -filename... -arguments specify catalog files rather than the document entity. -The document entity is specified by the first -DOCUMENT -entry in the catalog files. -
--Ddirectory -
-Search -directory -for files specified in system identifiers. -Multiple --D options -are allowed. -See the description of the -osfile -storage manager for more information about file searching. -
--e -
-Describe open entities in error messages. -Error messages always include the position of the most recently -opened external entity. -
--Emax_errors -
-Nsgmls -will exit after -max_errors -errors. -If -max_errors -is 0, there is no limit on the number of errors. -The default is 200. -
--ffile -
-Redirect errors to -file. -This is useful mainly with shells that do not support redirection -of stderr. -
--g -
-Show the generic identifiers of open elements in error messages. -
--iname -
-Pretend that -
-<!ENTITY % name "INCLUDE">
-
-

-occurs at the start of the document type declaration subset -in the SGML document entity. -Since repeated definitions of an entity are ignored, -this definition will take precedence over any other definitions -of this entity in the document type declaration. -Multiple --i -options are allowed. -If the SGML declaration replaces the reserved name -INCLUDE -then the new reserved name will be the replacement text of the entity. -Typically the document type declaration will contain -

-<!ENTITY % name "IGNORE">
-
-

-and will use -%name; -in the status keyword specification of a marked section declaration. -In this case the effect of the option will be to cause the marked -section not to be ignored. -

--ooutput_option -
-Output additional information accordig to -output_option: -
-
-entity -
-Output definitions of all general entities -not just for data or subdoc entities that are referenced or named in an -ENTITY or ENTITIES attribute. -
-id -
-Distinguish attributes whose declared value is ID. -
-line -
-Output -L -commands giving the current line number and filename. -
-included -
-Output an -i -command for included subelements. -
-notation-sysid -
-Output an f command before an N command, -if a system identifier could be generated for that notation. -
-

-Multiple --o -options are allowed. -

--p -
-Parse only the prolog. -Nsgmls -will exit after parsing the document type declaration. -Implies --s. -
--s -
-Suppress output. -Error messages will still be printed. -
--tfile -
-Output to -file -the RAST result as defined by -ISO/IEC 13673:1995 (actually this isn't quite an IS yet; -this implements the Intermediate Editor's Draft of 1994/08/29, -with changes to implement ISO/IEC JTC1/SC18/WG8 N1777). -The normal output is not produced. -
--v -
-Print the version number. -
--wtype -
-Control warnings and errors. -Multiple --w -options are allowed. -The following values of -type -enable warnings: -
-
-mixed -
-Warn about mixed content models that do not allow #pcdata anywhere. -
-sgmldecl -
-Warn about various dubious constructions in the SGML declaration. -
-should -
-Warn about various recommendations made in ISO 8879 that the document -does not comply with. -(Recommendations are expressed with ``should'', as distinct from -requirements which are usually expressed with ``shall''.) -
-default -
-Warn about defaulted references. -
-duplicate -
-Warn about duplicate entity declarations. -
-undefined -
-Warn about undefined elements: elements used in the DTD but not defined. -
-unclosed -
-Warn about unclosed start and end-tags. -
-empty -
-Warn about empty start and end-tags. -
-net -
-Warn about net-enabling start-tags and null end-tags. -
-min-tag -
-Warn about minimized start and end-tags. -Equivalent to combination of -unclosed, -empty -and -net -warnings. -
-unused-map -
-Warn about unused short reference maps: maps that are declared with a -short reference mapping declaration but never used in a short -reference use declaration in the DTD. -
-unused-param -
-Warn about parameter entities that are defined but not used in a DTD. -Unused internal parameter entities whose text is -INCLUDE -or -IGNORE -won't get the warning. -
-notation-sysid -
-Warn about notations for which no system identifier could be generated. -
-all -
-Warn about conditions that should usually be avoided -(in the opinion of the author). -Equivalent to: -mixed, -should, -default, -undefined, -sgmldecl, -unused-map, -unused-param, -empty -and -unclosed. -
-

-A warning can be disabled by using its name prefixed with -no-. -Thus --wall -wno-duplicate -will enable all warnings except those about duplicate entity -declarations. -

-The following values for -warning_type -disable errors: -

-
-no-idref -
-Do not give an error for an ID reference value -which no element has as its ID. -The effect will be as if each attribute declared as -an ID reference value had been declared as a name. -
-no-significant -
-Do not give an error when a character that is not a significant -character in the reference concrete syntax occurs in a literal in the -SGML declaration. This may be useful in conjunction with certain -buggy test suites. -
-
-

-The following options are also supported for backwards compatibility -with sgmls: -

-
--d -
-Same as --wduplicate. -
--l -
-Same as --oline. -
--msysid -
-Same as -c. -
--r -
-Same as --wdefault. -
--u -
-Same as --wundef. -
-

ENVIRONMENT

-
-
-SP_BCTF -
-If this is set to one of -identity, -utf-8, -euc-jp and sjis, then that BCTF will be used as the -default BCTF for everything (including file input, file output, -message output, filenames, environment variable names, environment -variable values and command line arguments). Note that setting -SP_BCTF to unicode -will not work. -
-

-

-James Clark
-jjc@jclark.com -
- - diff --git a/cde/programs/nsgmls/doc/sgmldecl.htm b/cde/programs/nsgmls/doc/sgmldecl.htm deleted file mode 100644 index c4a718c0c..000000000 --- a/cde/programs/nsgmls/doc/sgmldecl.htm +++ /dev/null @@ -1,273 +0,0 @@ - - - - -SP - SGML declaration - - -

Handling of the SGML declaration in SP

-

Default SGML declaration

-

-If the SGML declaration is omitted -and there is no applicable -SGMLDECL -entry in a catalog, -the following declaration will be implied: -

-		    <!SGML "ISO 8879:1986"
-			    CHARSET
-BASESET  "ISO 646-1983//CHARSET
-	  International Reference Version (IRV)//ESC 2/5 4/0"
-DESCSET    0  9 UNUSED
-	   9  2  9
-	  11  2 UNUSED
-	  13  1 13
-	  14 18 UNUSED
-	  32 95 32
-	 127  1 UNUSED
-CAPACITY PUBLIC    "ISO 8879:1986//CAPACITY Reference//EN"
-SCOPE    DOCUMENT
-SYNTAX
-SHUNCHAR CONTROLS 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
-	 18 19 20 21 22 23 24 25 26 27 28 29 30 31 127 255
-BASESET  "ISO 646-1983//CHARSET International Reference Version
-	  (IRV)//ESC 2/5 4/0"
-DESCSET  0 128 0
-FUNCTION RE                    13
-	 RS                    10
-	 SPACE                 32
-	 TAB       SEPCHAR     9
-NAMING   LCNMSTRT  ""
-	 UCNMSTRT  ""
-	 LCNMCHAR  "-."
-	 UCNMCHAR  "-."
-	 NAMECASE  GENERAL     YES
-		   ENTITY      NO
-DELIM    GENERAL   SGMLREF
-	 SHORTREF  SGMLREF
-NAMES    SGMLREF
-QUANTITY SGMLREF
-	 ATTCNT    99999999
-	 ATTSPLEN  99999999
-	 DTEMPLEN  24000
-	 ENTLVL    99999999
-	 GRPCNT    99999999
-	 GRPGTCNT  99999999
-	 GRPLVL    99999999
-	 LITLEN    24000
-	 NAMELEN   99999999
-	 PILEN     24000
-	 TAGLEN    99999999
-	 TAGLVL    99999999
-			   FEATURES
-MINIMIZE DATATAG   NO
-	 OMITTAG   YES
-	 RANK      YES
-	 SHORTTAG  YES
-LINK     SIMPLE    YES 1000
-	 IMPLICIT  YES
-	 EXPLICIT  YES 1
-OTHER    CONCUR    NO
-	 SUBDOC    YES 99999999
-	 FORMAL    YES
-			  APPINFO NONE>
-
-

-with the exception that all characters that are neither significant -nor shunned will be assigned to DATACHAR. -

Character sets

-

-A character in a base character set is described either by giving its -number in a universal character set, or by specifying a minimum -literal. The constraints on the choice of universal character set are -that characters that are significant in the SGML reference concrete -syntax must be in the universal character set and must have the same -number in the universal character set as in ISO 646 and that each -character in the character set must be represented by exactly one -number; that character numbers in the range 0 to 31 and 127 to 159 are -control characters (for the purpose of enforcing SHUNCHAR CONTROLS). -It is recommended that ISO 10646 (Unicode) be used as the universal -character set, except in environments where the normal document -character sets are large character set which cannot be compactly -described in terms of ISO 10646. -The public identifier of a base character set can be associated -with an entity that describes it by using a -PUBLIC -entry in the catalog entry file. -The entity must be a fragment -of an SGML declaration -consisting of the -portion of a character set description, -following the DESCSET keyword, -that is, it must be a sequence of character descriptions, -where each character description specifies a described character -number, the number of characters and -either a character number in the universal character set, a minimum literal -or the keyword -UNUSED. -Character numbers in the universal character set can be as big as -99999999. -

-In addition SP has built in knowledge of a few character sets. -These are identified using the designating sequence in the -public identifier. The following designating sequences are -recognized: -

-
-ESC 2/5 4/0 -
-The full set of ISO 646 IRV. -This is not a registered character set, -but is recommended by ISO 8879 (clause 10.2.2.4). -
-ESC 2/8 4/0 -
-G0 set of ISO 646 IRV, -ISO Registration Number 2. -
-ESC 2/8 4/2 -
-G0 set of ASCII, -ISO Registration Number 6. -
-ESC 2/1 4/0 -
-C0 set of ISO 646, -ISO Registration Number 1. -
-

-All the above character sets will be treated as mapping character numbers -0 to 127 inclusive as in ISO 646. -

-It is not necessary for every character set used in the SGML -declaration to be known to SP -provided that characters in the document character set that are -significant both in the reference concrete syntax and in the described -concrete syntax are described using known base character sets and that -characters that are significant in the described concrete syntax are -described using the same base character sets or the same minimum -literals in both the document character set description and the syntax -reference character set description. - -

Concrete syntaxes

-

-The public identifier for a public concrete syntax can be associated -with an entity that describes using a -PUBLIC -entry in the catalog entry file. -The entity must be a fragment of an SGML declaration -consisting of a concrete syntax description -starting with the -SHUNCHAR -keyword -as in an SGML declaration. -The entity can also make use of the following extensions: -

    -
  • -An -added function -can be expressed as a parameter literal -instead of a name. -
  • -The replacement for a reference reserved name -can be expressed as a parameter literal instead of a name. -
  • -The -LCNMSTRT, -UCNMSTRT, -LCNMCHAR -and -UCNMCHAR -keywords may each be followed by more than one parameter literal. A -sequence of parameter literals has the same meaning as a single -parameter literal whose content is the concatenation of the content of -each of the literals in the sequence. This extension is useful -because of the restriction on the length of a parameter literal in the -SGML declaration to 240 characters. -
  • -The total number of characters specified for -UCNMCHAR -or -UCNMSTRT -may exceed the total number of characters specified for -LCNMCHAR -or -LCNMSTRT -respectively. -Each character in -UCNMCHAR -or -UCNMSTRT -which does not have a corresponding character in the same position in -LCNMCHAR -or -LCNMSTRT -is simply assigned to UCNMCHAR or UCNMSTRT -without making it the upper-case form of any character. -
  • -A parameter following any of -LCNMSTRT, -UCNMSTRT, -LCNMCHAR -and -UCNMCHAR -keywords may be followed by -the name token ... -(three periods) and another parameter literal. -This has the same meaning as the two parameter literals -with a parameter literal in between -containing in order each character whose number -is greater than the number of the last character in -the first parameter literal and less than the -number of the first character in the second -parameter literal. -A parameter literal must contain at least one character for each -... -to which it is adjacent. -
  • -A number may be used as a parameter following the -LCNMSTRT, -UCNMSTRT, -LCNMCHAR -and -UCNMCHAR -keywords or as a delimiter in the -DELIM -section with the same meaning as a parameter literal -containing just a numeric character reference with that number. -
  • -The parameters following the -LCNMSTRT, -UCNMSTRT, -LCNMCHAR -and -UCNMCHAR -keywords may be omitted. -This has the same meaning as specifying -an empty parameter literal. -
  • -Within the specification of the short reference delimiters, -a parameter literal containing exactly one character -may be followed by the name token ... -and another parameter literal containing exactly one character. -This has the same meaning as a sequence of parameter literals -one for each character number that is greater than or equal -to the number of the character in the first parameter literal -and less than or equal to the number of the character in the -second parameter literal. -
-

Capacity sets

-

-The public identifier for a public capacity set can be associated -with an entity that describes using a -PUBLIC -entry in the catalog entry file. -The entity must be a fragment of an SGML declaration -consisting of a sequence of capacity names and numbers. -

-

-James Clark
-jjc@jclark.com -
- - diff --git a/cde/programs/nsgmls/doc/sgmlnorm.htm b/cde/programs/nsgmls/doc/sgmlnorm.htm deleted file mode 100644 index b51df2ea8..000000000 --- a/cde/programs/nsgmls/doc/sgmlnorm.htm +++ /dev/null @@ -1,151 +0,0 @@ - - - - -SGMLNORM - - -

SGMLNORM

-

-An SGML System Conforming to -International Standard ISO 8879 --
-Standard Generalized Markup Language -

-

SYNOPSIS

-

-sgmlnorm -[ --Cdemnv -] -[ --bbctf -] -[ --ccatalog -] -[ --Ddir -] -[ --iname -] -[ --wwarning -] -sysid... - -

DESCRIPTION

-

-Sgmlnorm prints on the standard output a normalized document instance -for the SGML document contained in the concatenation of the entities -with system identifiers -sysid.... -

-When the normalized instance is prefixed with the original SGML declaration -and prolog, it will have the same ESIS as the original SGML document, -with the following exceptions: -

    -
  • -The output of sgmlnorm does not protect against the recognition of -short reference delimiters, so any USEMAP declarations -must be removed from the DTD. -
  • -The normalized instance will use the reference delimiters, even if the -original instance did not. -
  • -If marked sections are included in the output using the --m option, the reference reserved names will be used for -the status keywords even if the original instance did not. -
  • -Any ESIS information relating to the SGML LINK feature will be lost. -
-

-The normalized instance will not use any markup minimization features -except that: -

    -
  • -Any attributes that were not specified in the original instance -will not be included in the normalized instance. -(Current attributes will be included.) -
  • -If the declared value of an attribute was a name token group, -and a value was specified that was the same as the name of -the attribute, then the attribute name and value indicator will be -omitted. -For example, with HTML sgmlnorm would output <DL COMPACT> -rather than <DL COMPACT="COMPACT"> -
-

-The following options are available: -

-
--bbctf -
-Use the BCTF with name -bctf -for output. -
--cfile -
-Use the catalog entry file -file. -
--C -
-This has the same effect as in nsgmls. -
--d -
-Output a document type declaration with the same external -identifier as the input document, and with no -internal declaration subset. -No check is performed that the document instance is valid -with respect to this DTD. -
--Ddirectory -
-Search -directory -for files specified in system identifiers. -This has the same effect as in nsgmls. -
--e -
-Describe open entities in error messages. -
--iname -
-This has the same effect as in nsgmls. -
--m -
-Output any marked sections that were in the input document instance. -
--n -
-Output any comments that were in the input document instance. -
--r -
-Raw output. -Don't perform any conversion on RSs and REs when printing the entity. -The entity would typically have the storage manager attribute -records=asis. -
--v -
-Print the version number. -
--wtype -
-Control warnings and errors according to -type. -This has the same effect as in nsgmls. -
-

-

-James Clark
-jjc@jclark.com -
- - diff --git a/cde/programs/nsgmls/doc/sgmlsout.htm b/cde/programs/nsgmls/doc/sgmlsout.htm deleted file mode 100644 index b9ee523e7..000000000 --- a/cde/programs/nsgmls/doc/sgmlsout.htm +++ /dev/null @@ -1,418 +0,0 @@ - - - - -Nsgmls Output Format - - -

Nsgmls Output Format

-

-The output is a series of lines. -Lines can be arbitrarily long. -Each line consists of an initial command character -and one or more arguments. -Arguments are separated by a single space, -but when a command takes a fixed number of arguments -the last argument can contain spaces. -There is no space between the command character and the first argument. -Arguments can contain the following escape sequences: -

-
-\\ -
-A -\. -
-\n -
-A record end character. -
-\| -
-Internal SDATA entities are bracketed by these. -
-\nnn -
-The character whose code is -nnn -octal. -

-A record start character will be represented by -\012. -Most applications will need to ignore -\012 -and translate -\n -into newline. -

-\#n; -
-The character whose number is -n -in decimal. -n -can have any number of digits. -This is used for characters that are not representable by the -encoding translation used for output -(as specified by the -SP_BCTF -environment variable). -This will only occur with the multibyte version of nsgmls. -
-

-The possible command characters and arguments are as follows: -

-
-(gi -
-The start of an element whose generic identifier is -gi. -Any attributes for this element -will have been specified with -A -commands. -
-)gi -
-The end of an element whose generic identifier is -gi. -
--data -
-Data. -
-&name -
-A reference to an external data entity -name; -name -will have been defined using an -E -command. -
-?pi -
-A processing instruction with data -pi. -
-Aname val -
-The next element to start has an attribute -name -with value -val -which takes one of the following forms: -
-
-IMPLIED -
-The value of the attribute is implied. -
-CDATA data -
-The attribute is character data. -This is used for attributes whose declared value is -CDATA. -
-NOTATION nname -
-The attribute is a notation name; -nname -will have been defined using a -N -command. -This is used for attributes whose declared value is -NOTATION. -
-ENTITY name... -
-The attribute is a list of general entity names. -Each entity name will have been defined using an -I, -E -or -S -command. -This is used for attributes whose declared value is -ENTITY -or -ENTITIES. -
-TOKEN token... -
-The attribute is a list of tokens. -This is used for attributes whose declared value is anything else. -
-ID token -
-The attribute is an ID value. -This will be output only if the --oid -option is specified. -Otherwise -TOKEN -will be used for ID values. -
-
-Dename name val -
-This is the same as the -A -command, except that it specifies a data attribute for an -external entity named -ename. -Any -D -commands will come after the -E -command that defines the entity to which they apply, but -before any -& -or -A -commands that reference the entity. -
-atype name val -
-The next element to start has a link attribute with link type -type, -name -name, -and value -val, -which takes the same form as with the -A -command. -
-Nnname -
-Define a notation nname. -This command will be preceded by a -p -command if the notation was declared with a public identifier, -and by a -s -command if the notation was declared with a system identifier. -If the --onotation-sysid -option was specified, -this command will also be preceded by an -f -command giving the system identifier generated by the entity manager -(unless it was unable to generate one). -A notation will only be defined if it is to be referenced -in an -E -command or in an -A -command for an attribute with a declared value of -NOTATION. -
-Eename typ nname -
-Define an external data entity named -ename -with type -typ -(CDATA, NDATA or SDATA) -and notation not. -Thiscommand will be preceded by an -f -command giving the system identifier generated by the entity manager -(unless it was unable to generate one), -by a -p -command if a public identifier was declared for the entity, -and by a -s -command if a system identifier was declared for the entity. -not -will have been defined using a -N -command. -Data attributes may be specified for the entity using -D -commands. -If the --oentity -option is not specified, -an external data entity will only be defined if it is to be referenced in a -& -command or in an -A -command for an attribute whose declared value is -ENTITY -or -ENTITIES. -
-Iename typ text -
-Define an internal data entity named -ename -with type -typ -and entity text -text. -The -typ -will be -CDATA -or -SDATA -unless the --oentity -option was specified, -in which case it can also be -PI -or -TEXT -(for an SGML text entity). -If the --oentity -option is not specified, -an internal data entity will only be defined if it is referenced in an -A -command for an attribute whose declared value is -ENTITY -or -ENTITIES. -
-Sename -
-Define a subdocument entity named -ename. -This command will be preceded by an -f -command giving the system identifier generated by the entity manager -(unless it was unable to generate one), -by a -p -command if a public identifier was declared for the entity, -and by a -s -command if a system identifier was declared for the entity. -If the --oentity -option is not specified, -a subdocument entity will only be defined if it is referenced -in a -{ -command -or in an -A -command for an attribute whose declared value is -ENTITY -or -ENTITIES. -
-Tename -
-Define an external SGML text entity named -ename. -This command will be preceded by an -f -command giving the system identifier generated by the entity manager -(unless it was unable to generate one), -by a -p -command if a public identifier was declared for the entity, -and by a -s -command if a system identifier was declared for the entity. -This command will be output only if the --oentity -option is specified. -
-ssysid -
-This command applies to the next -E, -S, -T -or -N -command and specifies the associated system identifier. -
-ppubid -
-This command applies to the next -E, -S, -T -or -N -command and specifies the associated public identifier. -
-fsysid -
-This command applies to the next -E, -S, -T -or, if the --onotation-sysid -option was specified, -N -command and specifies the system identifier -generated by the entity manager from the specified external identifier -and other information about the entity or notation. -
-{ename -
-The start of the SGML subdocument entity -ename; -ename -will have been defined using a -S -command. -
-}ename -
-The end of the SGML subdocument entity -ename. -
-Llineno file -
-Llineno -
-Set the current line number and filename. -The -file -argument will be omitted if only the line number has changed. -This will be output only if the --l -option has been given. -
-#text -
-An APPINFO parameter of -text -was specified in the SGML declaration. -This is not strictly part of the ESIS, but a structure-controlled -application is permitted to act on it. -No -# -command will be output if -APPINFO NONE -was specified. -A -# -command will occur at most once, -and may be preceded only by a single -L -command. -
-C -
-This command indicates that the document was a conforming SGML document. -If this command is output, it will be the last command. -An SGML document is not conforming if it references a subdocument entity -that is not conforming. -
-

-

-James Clark
-jjc@jclark.com -
- - diff --git a/cde/programs/nsgmls/doc/spam.htm b/cde/programs/nsgmls/doc/spam.htm deleted file mode 100644 index b6d664e83..000000000 --- a/cde/programs/nsgmls/doc/spam.htm +++ /dev/null @@ -1,272 +0,0 @@ - - - - -SPAM - - -

SPAM

-

-An SGML System Conforming to -International Standard ISO 8879 --
-Standard Generalized Markup Language -

-

-SYNOPSIS -

-

-spam -[ --Cehilprvx -] -[ --ccatalog_file -] -[ --Ddirectory -] -[ --ffile -] -[ --mmarkup_option -] -[ --oentity_name -] -[ --wwarning_type -] -sysid... -

DESCRIPTION

-

-Spam (SP Add Markup) -is an SGML markup stream editor implemented using the SP parser. -Spam parses the SGML document contained in -sysid... -and copies to the standard output -the portion of the document entity containing the document -instance, adding or changing markup as specified by the --m options. -The -p -option can be used to include the SGML declaration and prolog -in the output. -The -o -option can be used to output other entities. -The --x -option can be used to expand entity references. -

-The following options are available: -

-
--cfile -
-Use the catalog entry file -file. -
--C -
-This has the same effect as in nsgmls. -
--Ddirectory -
-Search -directory -for files specified in system identifiers. -This has the same effect as in nsgmls. -
--e -
-Describe open entities in error messages. -
--ffile -
-Redirect errors to -file. -This is useful mainly with shells that do not support redirection -of stderr. -
--h -
-Hoist omitted tags out from the start of internal entities. -If the text at the beginning of an internal entity causes -a tag to be implied, -the tag will usually be treated as being in that internal entity; -this option will instead cause it to be treated as being in the entity -that referenced the internal entity. -This option makes a difference in conjunction with --momittag -or --x -x. -
--iname -
-This has the same effect as in nsgmls. -
--l -
-Prefer lower-case. -Added names that were subject to upper-case substitution -will be converted to lower-case. -
--mmarkup_option -
-Change the markup in the output according to the value -of -markup_option -as follows: -
-
-omittag -
-Add tags that were omitted using omitted tag minimization. -End tags that were omitted because the element has -a declared content of EMPTY -or an explicit content reference -will not be added. -
-shortref -
-Replace short references by named entity references. -
-net -
-Change null end-tags -into unminimized end-tags, -and change net-enabling start-tags -into unminimized start-tags. -
-emptytag -
-Change empty tags into unminimized tags. -
-unclosed -
-Change unclosed tags into unminimized tags. -
-attname -
-Add omitted attribute names and -vis. -
-attvalue -
-Add literal delimiters omitted from attribute values. -
-attspec -
-Add omitted attribute specifications. -
-current -
-Add omitted attribute specifications for current attributes. -This option is implied by the -attspec -option. -
-shorttag -
-Equivalent to combination of -net, -emptytag, -unclosed, -attname, -attvalue -and -attspec -options. -
-rank -
-Add omitted rank suffixes. -
-reserved -
-Put reserved names in upper-case. -
-ms -
-Remove marked section declarations whose effective status -is IGNORE, and replace each marked section declaration -whose effective status is INCLUDE by its marked section. -In the document instance, empty comments will be added -before or after the marked section declaration to ensure -that ignored record ends remain ignored. -
-

-Multiple --m -options are allowed. -

--oname -
-Output the general entity -name -instead of the document entity. -The output will correspond to the first time -that the entity is referenced in content. -
--p -
-Output the part of the document entity containing the SGML declaration -(if it was explicitly present in the document entity) -and the prolog before anything else. -If this option is specified two or more times, -then all entity references occurring between declarations -in the prolog will be expanded; -this includes the implicit reference to the entity -containing the external subset of the DTD, if there is one. -Note that the SGML declaration will not be included if it was -specified by an SGMLDECL entry in a catalog. -
--r -
-Don't perform any conversion on RSs and REs when outputting the entity. -The entity would typically have the storage manager attribute -records=asis. -
--v -
-Print the version number. -
--wtype -
-Control warnings and errors according to -type. -This has the same effect as in nsgmls. -
--x -
-Expand references to entities that are changed. -If this option is specified two or more times, -then all references to entities that contain tags -will be expanded. -
- -

BUGS

-

-Omitted tags are added at the point where they are -implied by the SGML parser (except as modified -by the --h -option); this is often not quite where they are wanted. -

-The case of general delimiters is not preserved. -

-Incorrect results may be produced if a variant concrete syntax is used -which is such that there are delimiters in markup to be added that have a -prefix that is a proper suffix of some other delimiter. -

-If an entity reference in a default value uses the default entity and -an entity with that name is subsequently defined and that default -value is added to the document instance, then the resulting document -may not be equivalent to the original document. -Spam will give a warning when the first two conditions are met. -

-

-James Clark
-jjc@jclark.com -
- - diff --git a/cde/programs/nsgmls/doc/spent.htm b/cde/programs/nsgmls/doc/spent.htm deleted file mode 100644 index ea35c1857..000000000 --- a/cde/programs/nsgmls/doc/spent.htm +++ /dev/null @@ -1,68 +0,0 @@ - - - - -SPENT - - -

SPENT

-

SYNOPSIS

-

-spent -[ --Crv -] -[ --bbctf -] -[ --Ddirectory -] -sysid... - -

DESCRIPTION

-

-Spent (SGML print entity) -prints the concatenation of the entities with -system identifiers -sysid... -on the standard output. -

-The following options are available: -

-
--bbctf -
-Use the BCTF with name -bctf -for output. -
--C -
-This has the same effect as in nsgmls. -
--Ddirectory -
-Search -directory -for files specified in system identifiers. -This has the same effect as in nsgmls. -
--r -
-Raw output. -Don't perform any conversion on RSs and REs when printing the entity. -The entity would typically have the storage manager attribute -records=asis. -
--v -
-Print the version number. -
-

-

-James Clark
-jjc@jclark.com -
- - diff --git a/cde/programs/nsgmls/doc/sysdecl.htm b/cde/programs/nsgmls/doc/sysdecl.htm deleted file mode 100644 index 3e623df2a..000000000 --- a/cde/programs/nsgmls/doc/sysdecl.htm +++ /dev/null @@ -1,41 +0,0 @@ - - - - -SP - System declaration - - -

SP System Declaration

-

-The system declaration for SP is as follows: -

-			<!SYSTEM "ISO 8879:1986"
-				CHARSET
-BASESET  "ISO 646-1983//CHARSET
-	  International Reference Version (IRV)//ESC 2/5 4/0"
-DESCSET  0 128 0
-CAPACITY PUBLIC  "ISO 8879:1986//CAPACITY Reference//EN"
-			       FEATURES
-MINIMIZE DATATAG NO        OMITTAG  YES     RANK     YES   SHORTTAG YES
-LINK     SIMPLE  YES 65535 IMPLICIT YES     EXPLICIT YES 1
-OTHER    CONCUR  NO        SUBDOC   YES 100 FORMAL   YES
-SCOPE    DOCUMENT
-SYNTAX   PUBLIC  "ISO 8879:1986//SYNTAX Reference//EN"
-SYNTAX   PUBLIC  "ISO 8879:1986//SYNTAX Core//EN"
-			       VALIDATE
-	 GENERAL YES       MODEL    YES     EXCLUDE  YES   CAPACITY NO
-	 NONSGML YES       SGML     YES     FORMAL   YES
-				 SDIF
-	 PACK    NO        UNPACK   NO>
-
-

-The limit for the SUBDOC parameter is memory dependent. -

-Any legal concrete syntax may be used. -

-

-James Clark
-jjc@jclark.com -
- - diff --git a/cde/programs/nsgmls/doc/sysid.htm b/cde/programs/nsgmls/doc/sysid.htm deleted file mode 100644 index b59080c98..000000000 --- a/cde/programs/nsgmls/doc/sysid.htm +++ /dev/null @@ -1,305 +0,0 @@ - - - - -SP - System identifiers - - -

System identifiers

-

-There are two kinds of system identifier: formal system identifiers -and simple system identifiers. A system identifier that does not -start with < will always be interpreted as a simple -system identifier. A simple system identifier will always be -interpreted either as a filename or as a URL. - -

Formal system identifiers

-

-Formal system identifiers are based on the -System Identifier facility defined in ISO/IEC 10744 (HyTime) Technical -Corrigendum 1, Annex D. -A system identifier that is a formal system -identifier consists of a sequence of one or more storage object -specifications. The objects specified by the storage object -specifications are concatenated to form the entity. A storage object -specification consists of an SGML start-tag in the reference concrete -syntax followed by character data content. The generic identifier of -the start-tag is the name of a storage manager. The content is a -storage object identifier which identifies the storage object in a -manner dependent on the storage manager. The start-tag can also -specify attributes giving additional information about the storage -object. Numeric character references are recognized in storage object -identifiers and attribute value literals in the start-tag. Record -ends are ignored in the storage object identifier as with SGML. A -system identifier will be interpreted as a formal system identifier if -it starts with a < followed by a storage manager name, -followed by either > or white-space; otherwise it will be -interpreted as a simple system identifier. A storage object -identifier extends until the end of the system identifier or until the -first occurrence of < followed by a storage manager -name, followed by either > or white-space. -

-The following storage managers are available: -

-
-osfile -
-The storage object identifier is a filename. If the filename is -relative it is resolved using a base filename. Normally the base -filename is the name of the file in which the storage object -identifier was specified, but this can be changed using the -base attribute. The filename will be searched for first -in the directory of the base filename. If it is not found there, then -it will be searched for in directories specified with the --D option in the order in which they were specified on -the command line, and then in the list of directories specified by the -environment variable SGML_SEARCH_PATH. The list -is separated by colons under Unix and by semi-colons under MSDOS. -
-osfd -
-The storage object identifier is an integer specifying a file -descriptor. Thus a system identifier of <osfd>0 will -refer to the standard input. -
-url -
-The storage object identifier is a URL. Only the http -scheme is currently supported and not on all systems. -
-neutral -
-The storage manager is the storage manager of storage object in which -the system identifier was specified (the underlying storage -manager). However if the underlying storage manager does not -support named storage objects (ie it is osfd), then the -storage manager will be osfile. The storage object -identifier is treated as a relative, hierarchical name separated by -slashes (/) and will be transformed as appropriate for -the underlying storage manager. -
-literal -
-The bit combinations of the storage object identifier are -the contents of the storage object. -
-

-The following attributes are supported: -

-
-records -
-This describes how records are delimited in the storage object: -
-
cr -
-Records are terminated by a carriage return. -
-lf -
-Records are terminated by a line feed. -
-crlf -
-Records are terminated by a carriage return followed by a line feed. -
-find -
-Records are terminated by whichever of -cr, -lf -or -crlf -is first encountered in the storage object. -
-asis -
-No recognition of records is performed. -
-

-The default is find except for NDATA entities for which -the default is asis. This attribute is not applicable to -the literal storage manager. -

-When records are recognized in a storage object, a record start is -inserted at the beginning of each record, and a record end at the end -of each record. If there is a partial record (a record that doesn't -end with the record terminator) at the end of the entity, then a -record start will be inserted before it but no record end will be -inserted after it. -

-The attribute name and = can be omitted for this attribute. -

-zapeof -
-This specifies whether a Control-Z character that occurs as the final byte -in the storage object should be stripped. -The following values are allowed: -
-
zapeof -
-A final Control-Z should be stripped. -
nozapeof -
-A final Control-Z should not be stripped. -
-

-The default is zapeof except for NDATA entities, entities -declared in storage objects with zapeof=nozapeof and -storage objects with records=asis. This attribute is not -applicable to the literal storage manager. -

-The attribute name and = can be omitted for this -attribute. -

-bctf -
-The bctf (bit combination transformation format) attribute describes -how the bit combinations of the storage object are transformed into -the sequence of bytes that are contained in the object identified by -the storage object identifier. This inverse of this transformation is -performed when the entity manager reads the storage object. It has -one of the following values: -
-
-identity -
-Each bit combination is represented by a single byte. -
-fixed-2 -
-Each bit combination is represented by exactly 2 -bytes, with the more significant byte first. -
-utf-8 -
-Each bit combination is represented by a variable number of bytes -according to UCS Transformation Format 8 defined in Annex P to be -added by the first proposed drafted amendment (PDAM 1) to ISO/IEC -10646-1:1993. -
-euc-jp -
-Each bit combination is treated as a pair of bytes, most significant -byte first, encoding a character using the -Extended_UNIX_Code_Fixed_Width_for_Japanese Internet charset, and is -transformed into the variable length sequence of octets that would -encode that character using the -Extended_UNIX_Code_Packed_Format_for_Japanese Internet charset. -
-sjis -
-Each bit combination is treated as a pair of bytes, most significant -byte first, encoding a character using the -Extended_UNIX_Code_Fixed_Width_for_Japanese Internet charset, and is -transformed into the variable length sequence of bytes that would -encode that character using the Shift_JIS Internet charset. -
-unicode -
-Each bit combination is represented by 2 bytes. The bytes -representing the entire storage object may be preceded by a pair of -bytes representing the byte order mark character (0xFEFF). The bytes -representing each bit combination are in the system byte order, unless -the byte order mark character is present, in which case the order of -its bytes determines the byte order. When the storage object is read, -any byte order mark character is discarded. -
-is8859-n -
-n can be any single digit other than 0. Each -bit combination is interpreted as the number of a character in ISO/IEC -10646 and is represented by the single byte that would encode that -character in ISO 8859-n. These values are not supported -with the -b option. -
-

-Values other than identity are supported only with the -multi-byte version of nsgmls. This attribute is not applicable to the -literal storage manager. -

-tracking -
-This specifies whether line boundaries should be tracked for this -object: a value of track specifies that they should; a -value of notrack specifies that they should not. The -default value is track. Keeping track of where line -boundaries occur in a storage object requires approximately one byte -of storage per line and it may be desirable to disable this for very -large storage objects. -

-The attribute name and -= -can be omitted for this attribute. -

-base -
-When the storage object identifier specified in the content of the -storage object specification is relative, this specifies the base -storage object identifier relative to which that storage object -identifier should be resolved. -When not specified a storage object identifier is interpreted -relative to the storage object in which it is specified, -provided that this has the same storage manager. -This applies both to system identifiers specified in SGML -documents and to system identifiers specified in the catalog entry -files. -
-smcrd -
-The value is a single character that will be recognized in storage -object identifiers (both in the content of storage object -specifications and in the value of base attributes) as a -storage manager character reference delimiter when followed by a -digit. A storage manager character reference is like an SGML numeric -character reference except that the number is interpreted as a -character number in the inherent character set of the storage manager -rather than the document character set. The default is for no -character to be recognized as a storage manager character reference -delimiter. Numeric character references cannot be used to prevent -recognition of storage manager character reference delimiters. -
-fold -
-This applies only to the neutral storage manager. It -specifies whether the storage object identifier should be folded to -the customary case of the underlying storage manager if storage object -identifiers for the underlying storage manager are case sensitive. -The following values are allowed: -
-
fold -
-The storage object identifier will be folded. -
-nofold -
-The storage object identifier will not be folded. -
-

-The default value is fold. The attribute name and -= can be omitted for this attribute. -

-For example, on Unix filenames are case-sensitive and the customary -case is lower-case. So if the underlying storage manager were -osfile and the system was a Unix system, then -<neutral>FOO.SGM would be equivalent to -<osfile>foo.sgm. -

-

Simple system identfiers

-

-A simple system identifier is interpreted as a storage object -identifier with a storage manager that depends on where the system -identifier was specified: if it was specified in a storage object -whose storage manager was url or if the system identifier -looks like an absolute URL in a supported scheme, the storage manager -will be url; otherwise the storage manager will be -osfile. The storage manager attributes are defaulted as -for a formal system identifier. Numeric character references are not -recognized in simple system identifiers. -

-

-James Clark
-jjc@jclark.com -
- - diff --git a/cde/programs/nsgmls/doc/winntu.htm b/cde/programs/nsgmls/doc/winntu.htm deleted file mode 100644 index a4a9baa1a..000000000 --- a/cde/programs/nsgmls/doc/winntu.htm +++ /dev/null @@ -1,53 +0,0 @@ - - - - -SP Unicode support under Windows NT - - -

Notes on SP Unicode support under Windows NT

-

-When compiled with the appropriate preprocessor definition -(UNICODE), SP now uses Unicode interfaces to NT. This -means that the SP_BCTF environment variable applies only -to file input and output, and so unicode is allowed as -the value of SP_BCTF. -

-In order for non-ASCII characters to be correctly displayed on your -console you must select a TrueType font, such as Lucida Console, as your -console font. -

-If you define your own public character sets, you should use Unicode -(or a superset of Unicode) as your universal character set. -

-The following additional BCTFs are supported: -

-
-windows -
-Specify this BCTF when a storage object is encoded using your -system's default Windows character set, and your document character -set is declared as Unicode. This uses the so-called ANSI code page. -
-wunicode -
-This uses the unicode BCTF if the storage object starts -with a byte order mark and otherwise the windows BCTF. -If you are working with Unicode, this is probably the best value -for SP_BCTF. -
-ms-dos -
-Specify this BCTF when a storage object (file) uses the OEM code page, -and your document character set is declared as Unicode. -The OEM code-page for a particular -machine is the code-page used by FAT file-systems on that machine and -is the default code-page for MS-DOS consoles. -
-

-

-James Clark
-jjc@jclark.com -
- - diff --git a/cde/programs/nsgmls/entmgr_inst.m4 b/cde/programs/nsgmls/entmgr_inst.m4 deleted file mode 100644 index 20002a844..000000000 --- a/cde/programs/nsgmls/entmgr_inst.m4 +++ /dev/null @@ -1,83 +0,0 @@ -/* $XConsortium: entmgr_inst.m4 /main/2 1996/08/09 15:33:21 mgreess $ */ -// Copyright (c) 1995 James Clark -// See the file COPYING for copying permission. - -#include "splib.h" - -#ifdef SP_MANUAL_INST - -#define SP_DEFINE_TEMPLATES -#include "Owner.h" -#include "CopyOwner.h" -#include "RangeMap.h" -#include "Ptr.h" -#include "StringOf.h" -#include "StringC.h" -#include "Vector.h" -#include "ISet.h" -#include "ISetIter.h" -#include "XcharMap.h" -#include "SubstTable.h" -#include "StringResource.h" -#undef SP_DEFINE_TEMPLATES - -#include "types.h" -#include "Location.h" -#include "Message.h" -#include "NamedResource.h" -#include "EntityManager.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -__instantiate(Ptr) -__instantiate(ConstPtr) -__instantiate(Ptr) -__instantiate(ConstPtr) -__instantiate(Ptr >) -__instantiate(ConstPtr >) -__instantiate(Ptr >) -__instantiate(ConstPtr >) -__instantiate(Ptr >) -__instantiate(ConstPtr >) -__instantiate(Ptr >) -__instantiate(ConstPtr >) -__instantiate(Ptr) -__instantiate(ConstPtr) -__instantiate(Ptr) -__instantiate(ConstPtr) -__instantiate(Ptr) -__instantiate(ConstPtr) -__instantiate(Owner) -__instantiate(CopyOwner) -__instantiate(String) -__instantiate(Vector) -__instantiate(Vector >) -__instantiate(SharedXcharMap) -__instantiate(XcharMap) -__instantiate(`Vector >') -__instantiate(`RangeMapIter') -__instantiate(`RangeMap') -__instantiate(Vector) -__instantiate(Vector) -__instantiate(Owner) -__instantiate(ISet) -__instantiate(Vector >) -__instantiate(ISet) -__instantiate(ISetIter) -__instantiate(ISetIter) -__instantiate(Vector >) -__instantiate(SubstTable) -__instantiate(SharedXcharMap) -__instantiate(SharedXcharMap) -__instantiate(String) -__instantiate(XcharMap) -__instantiate(XcharMap) -__instantiate(Vector) - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* SP_MANUAL_INST */ diff --git a/cde/programs/nsgmls/events.h b/cde/programs/nsgmls/events.h deleted file mode 100644 index 782b3baa5..000000000 --- a/cde/programs/nsgmls/events.h +++ /dev/null @@ -1,65 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: events.h /main/1 1996/07/29 17:08:51 cde-hp $ */ -// Copyright (c) 1995 James Clark -// See the file COPYING for copying permission. - -EVENT(MessageEvent, message) -EVENT(DataEvent, data) -EVENT(StartElementEvent, startElement) -EVENT(EndElementEvent, endElement) -EVENT(PiEvent, pi) -EVENT(SdataEntityEvent, sdataEntity) -EVENT(ExternalDataEntityEvent, externalDataEntity) -EVENT(SubdocEntityEvent, subdocEntity) -EVENT(AppinfoEvent, appinfo) -EVENT(UselinkEvent, uselink) -EVENT(UsemapEvent, usemap) -EVENT(StartDtdEvent, startDtd) -EVENT(EndDtdEvent, endDtd) -EVENT(StartLpdEvent, startLpd) -EVENT(EndLpdEvent, endLpd) -EVENT(EndPrologEvent, endProlog) -EVENT(SgmlDeclEvent, sgmlDecl) -EVENT(CommentDeclEvent, commentDecl) -EVENT(SSepEvent, sSep) -EVENT(IgnoredReEvent, ignoredRe) -EVENT(ReOriginEvent, reOrigin) -EVENT(IgnoredRsEvent, ignoredRs) -EVENT(IgnoredCharsEvent, ignoredChars) -EVENT(MarkedSectionStartEvent, markedSectionStart) -EVENT(MarkedSectionEndEvent, markedSectionEnd) -EVENT(EntityStartEvent, entityStart) -EVENT(EntityEndEvent, entityEnd) -EVENT(EntityDeclEvent, entityDecl) -EVENT(NotationDeclEvent, notationDecl) -EVENT(ElementDeclEvent, elementDecl) -EVENT(AttlistDeclEvent, attlistDecl) -EVENT(LinkAttlistDeclEvent, linkAttlistDecl) -EVENT(AttlistNotationDeclEvent, attlistNotationDecl) -EVENT(LinkDeclEvent, linkDecl) -EVENT(IdLinkDeclEvent, idLinkDecl) -EVENT(ShortrefDeclEvent, shortrefDecl) -EVENT(IgnoredMarkupEvent, ignoredMarkup) -EVENT(EntityDefaultedEvent, entityDefaulted) -EVENT(SgmlDeclEntityEvent, sgmlDeclEntity) diff --git a/cde/programs/nsgmls/instmac.m4 b/cde/programs/nsgmls/instmac.m4 deleted file mode 100644 index d22e14751..000000000 --- a/cde/programs/nsgmls/instmac.m4 +++ /dev/null @@ -1,80 +0,0 @@ -/* $XConsortium: instmac.m4 /main/3 1996/08/13 10:09:17 mgreess $ */ - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -dnl Copyright (c) 1994 James Clark -dnl See the file COPYING for copying permission. -dnl M4 macros for template instantiation. -define(`__undefine', defn(`undefine'))dnl -define(`__define', defn(`define'))dnl -define(`__changequote', defn(`changequote'))dnl -define(`__include', defn(`include'))dnl -define(`__ifdef', defn(`ifdef'))dnl -define(`__divert', defn(`divert'))dnl -define(`__dnl', defn(`dnl'))dnl -define(`__incr', defn(`incr'))dnl -define(`__index', 0)dnl -define(`__concat', $1$2)dnl -define(`__instantiate',`#if defined(__DECCXX) - #pragma define_template $1 -#elif defined(AIXV3) - #pragma define($1) -#elif defined(SP_ANSI_CLASS_INST) - template class $1; -#else - typedef $1 __concat(Dummy_,__index); -#endif -__define(`__index',__incr(__index))__dnl')dnl -define(`__func_index', 0)dnl -define(`__instantiate_func3', -`#ifdef __GNUG__ -template void $1($2, $3, $4); -#else -static -void __concat(func_,__func_index) ($2 arg1, $3 arg2, $4 arg3) { -(void)$1(arg1, arg2, arg3); -} -#endif -__define(`__func_index',__incr(__func_index))__dnl')dnl -dnl we want __p to be expanded even inside comments -changecom()__dnl -__undefine(`changecom')__dnl -__undefine(`changequote')__dnl -__undefine(`decr')__dnl -__undefine(`define')__dnl -__undefine(`defn')__dnl -__undefine(`divert')__dnl -__undefine(`divnum')__dnl -__undefine(`dnl')__dnl -__undefine(`dumpdef')__dnl -__undefine(`errprint')__dnl -__undefine(`eval')__dnl -__undefine(`ifdef')__dnl -__undefine(`ifelse')__dnl -__undefine(`include')__dnl -__undefine(`incr')__dnl -__undefine(`index')__dnl -__undefine(`len')__dnl -__undefine(`m4exit')__dnl -__undefine(`m4wrap')__dnl -__undefine(`maketemp')__dnl -__undefine(`popdef')__dnl -__undefine(`pushdef')__dnl -__undefine(`shift')__dnl -__undefine(`sinclude')__dnl -__undefine(`substr')__dnl -__undefine(`syscmd')__dnl -__undefine(`sysval')__dnl -__undefine(`traceoff')__dnl -__undefine(`traceon')__dnl -__undefine(`translit')__dnl -__undefine(`undefine')__dnl -__undefine(`undivert')__dnl -__undefine(`unix')__dnl -__dnl __changequote(,)__dnl disable quoting - -#ifdef SP_NAMESPACE -} -#endif diff --git a/cde/programs/nsgmls/macros.h b/cde/programs/nsgmls/macros.h deleted file mode 100644 index 9815c0731..000000000 --- a/cde/programs/nsgmls/macros.h +++ /dev/null @@ -1,60 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: macros.h /main/1 1996/07/29 17:08:55 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#ifndef macros_INCLUDED -#define macros_INCLUDED 1 - -#ifndef __GNUG__ -#define __attribute__(args) /* as nothing */ -#endif - -#ifdef NDEBUG - -#include -#define ASSERT(expr) ((void)0) -#define CANNOT_HAPPEN() ((void)abort()) - -#else /* not NDEBUG */ - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif -extern SP_API void assertionFailed(const char *, const char *, int) - __attribute__((noreturn)); -#ifdef SP_NAMESPACE -} -#endif - -#define ASSERT(expr) \ - ((void)((expr) || \ - (::SP_NAMESPACE_SCOPE assertionFailed(# expr, __FILE__, __LINE__), 0))) -#define CANNOT_HAPPEN() ASSERT(0) - -#endif /* not NDEBUG */ - -#define SIZEOF(v) (sizeof(v)/sizeof(v[0])) - -#endif /* not macros_INCLUDED */ diff --git a/cde/programs/nsgmls/nsgmls.C b/cde/programs/nsgmls/nsgmls.C deleted file mode 100644 index 25c038bdd..000000000 --- a/cde/programs/nsgmls/nsgmls.C +++ /dev/null @@ -1,298 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: nsgmls.C /main/1 1996/07/29 17:08:59 cde-hp $ */ -// Copyright (c) 1994, 1995 James Clark -// See the file COPYING for copying permission. - -#include "config.h" -#include "Event.h" -#include "MessageEventHandler.h" -#include "SgmlsEventHandler.h" -#include "RastEventHandler.h" -#include "OutputCharStream.h" -#include "Boolean.h" -#include "NsgmlsMessages.h" -#include "MessageArg.h" -#include "ErrnoMessageArg.h" -#include "ParserApp.h" -#include "sptchar.h" -#include "macros.h" - -#if defined(__linux__) || defined(CSRG_BASED) || defined(sun) -#include -#include -#else -#include -#include -#endif -#include -#include -#include -#include - -#ifdef SP_NAMESPACE -using namespace SP_NAMESPACE; -#endif - -class NsgmlsApp : public ParserApp { -public: - NsgmlsApp(); - int processArguments(int argc, AppChar **argv); - ErrorCountEventHandler *makeEventHandler(); - void processOption(AppChar opt, const AppChar *arg); - void allLinkTypesActivated(); -private: - Boolean suppressOutput_; - Boolean prologOnly_; - unsigned outputFlags_; - String rastFile_; - const AppChar *rastOption_; - Boolean batchMode_; -}; - -SP_DEFINE_APP(NsgmlsApp) - -class PrologMessageEventHandler : public MessageEventHandler { -public: - PrologMessageEventHandler(Messenger *messenger); - void endProlog(EndPrologEvent *); -}; - -class XRastEventHandler : public RastEventHandler { -public: - XRastEventHandler(SgmlParser *, - const AppChar *filename, - const StringC &filenameStr, - const OutputCodingSystem *, -#if defined(__linux__) || defined(CSRG_BASED) || defined(sun) - ::Messenger *messenger); -#else - Messenger *messenger); -#endif - ~XRastEventHandler(); - void message(MessageEvent *); - void truncateOutput(); - void allLinkTypesActivated(); -private: -#if defined(__linux__) || defined(CSRG_BASED) || defined(sun) - ::Messenger *messenger_; -#else - Messenger *messenger_; -#endif - // file_ must come before os_ so it gets inited first - filebuf file_; - IosOutputCharStream os_; - const AppChar *filename_; - const StringC filenameStr_; -}; - -NsgmlsApp::NsgmlsApp() -: suppressOutput_(0), - batchMode_(0), - prologOnly_(0), - outputFlags_(0), - rastOption_(0) -{ - registerOption('B'); - registerOption('d'); - registerOption('l'); - registerOption('m', SP_T("catalog_sysid")); - registerOption('o', SP_T("output_option")); - registerOption('p'); - registerOption('r'); - registerOption('s'); - registerOption('t', SP_T("rast_file")); - registerOption('u'); -} - -void NsgmlsApp::processOption(AppChar opt, const AppChar *arg) -{ - switch (opt) { - case 'B': - batchMode_ = 1; - break; - case 'd': - // warn about duplicate entity declarations - options_.warnDuplicateEntity = 1; - break; - case 'l': - // output L commands - outputFlags_ |= SgmlsEventHandler::outputLine; - break; - case 'm': - processOption(SP_T('c'), arg); - break; - case 'o': - { - static struct { - const AppChar *name; - unsigned flag; - } outputOptions[] = { - { SP_T("line"), SgmlsEventHandler::outputLine }, - { SP_T("entity"), SgmlsEventHandler::outputEntity }, - { SP_T("id"), SgmlsEventHandler::outputId }, - { SP_T("included"), SgmlsEventHandler::outputIncluded }, - { SP_T("notation-sysid"), SgmlsEventHandler::outputNotationSysid }, - }; - Boolean found = 0; - for (size_t i = 0; i < SIZEOF(outputOptions); i++) - if (tcscmp(arg, outputOptions[i].name) == 0) { - outputFlags_ |= outputOptions[i].flag; - found = 1; - break; - } - if (!found) - message(NsgmlsMessages::unknownOutputOption, - StringMessageArg(convertInput(arg))); - } - break; - case 'p': - prologOnly_ = 1; - break; - case 'r': - // warn about defaulted entity reference - options_.warnDefaultEntityReference = 1; - break; - case 's': - suppressOutput_ = 1; - break; - case 't': - rastOption_ = arg; - break; - case 'u': - // warn about undefined elements - options_.warnUndefinedElement = 1; - break; - default: - ParserApp::processOption(opt, arg); - break; - } -} - -int NsgmlsApp::processArguments(int argc, AppChar **argv) -{ - if (batchMode_) { - int ret = 0; - for (int i = 0; i < argc; i++) { - if (rastOption_) { - rastFile_.assign(rastOption_, tcslen(rastOption_)); - rastFile_.append(argv[i], tcslen(argv[i])); - rastFile_ += SP_T('\0'); - } - int tem = ParserApp::processArguments(1, argv + i); - if (tem > ret) - ret = tem; - } - return ret; - } - else - return ParserApp::processArguments(argc, argv); -} - -void NsgmlsApp::allLinkTypesActivated() -{ - if (!rastOption_) - ParserApp::allLinkTypesActivated(); -} - -ErrorCountEventHandler *NsgmlsApp::makeEventHandler() -{ - if (prologOnly_) - return new PrologMessageEventHandler(this); - else if (rastOption_) { - const AppChar *s = batchMode_ ? rastFile_.data() : rastOption_; - return new XRastEventHandler(&parser_, s, convertInput(s), - outputCodingSystem_, this); - } - else if (suppressOutput_) - return new MessageEventHandler(this, &parser_); - else - return new SgmlsEventHandler(&parser_, - makeStdOut(), - this, - outputFlags_); -} - -PrologMessageEventHandler::PrologMessageEventHandler(Messenger *messenger) -: MessageEventHandler(messenger) -{ -} - -void PrologMessageEventHandler::endProlog(EndPrologEvent *event) -{ - cancel(); - delete event; -} - -XRastEventHandler::XRastEventHandler(SgmlParser *parser, - const AppChar *filename, - const StringC &filenameStr, - const OutputCodingSystem *codingSystem, -#if defined(__linux__) || defined(CSRG_BASED) || defined(sun) - ::Messenger *messenger) -#else - ::Messenger *messenger) -#endif -: RastEventHandler(parser, messenger), - messenger_(messenger), - filename_(filename), - filenameStr_(filenameStr) -{ - errno = 0; - if (!CmdLineApp::openFilebufWrite(file_, filename)) { - messenger->message(NsgmlsMessages::cannotOpenOutputError, - StringMessageArg(filenameStr), - ErrnoMessageArg(errno)); - exit(1); - } - os_.open(&file_, codingSystem); - setOutputStream(&os_); -} - -XRastEventHandler::~XRastEventHandler() -{ - end(); -} - -void XRastEventHandler::truncateOutput() -{ - os_.flush(); - errno = 0; - if (!file_.close()) - messenger_->message(NsgmlsMessages::closeOutputError, - StringMessageArg(filenameStr_), - ErrnoMessageArg(errno)); - errno = 0; - if (!CmdLineApp::openFilebufWrite(file_, filename_)) { - messenger_->message(NsgmlsMessages::cannotOpenOutputError, - StringMessageArg(filenameStr_), - ErrnoMessageArg(errno)); - exit(1); - } -} - -void XRastEventHandler::message(MessageEvent *event) -{ - messenger_->dispatchMessage(event->message()); - ErrorCountEventHandler::message(event); -} diff --git a/cde/programs/nsgmls/nsgmls_inst.m4 b/cde/programs/nsgmls/nsgmls_inst.m4 deleted file mode 100644 index e82adbcb3..000000000 --- a/cde/programs/nsgmls/nsgmls_inst.m4 +++ /dev/null @@ -1,36 +0,0 @@ -/* $XConsortium: nsgmls_inst.m4 /main/2 1996/08/09 15:33:44 mgreess $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#include "config.h" - -#ifdef SP_MANUAL_INST - -#define SP_DEFINE_TEMPLATES -#include "Vector.h" -#include "PointerTable.h" -#include "OwnerTable.h" -#include "Vector.h" -#include "IQueue.h" -#include "Owner.h" -#undef SP_DEFINE_TEMPLATES - -#include "StringSet.h" -#include "RastEventHandler.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -__instantiate(`PointerTable') -__instantiate(`OwnerTable') -__instantiate(Vector) -__instantiate(Owner) -__instantiate(IQueue) -__instantiate(Vector >) - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* SP_MANUAL_INST */ diff --git a/cde/programs/nsgmls/parseAttribute.C b/cde/programs/nsgmls/parseAttribute.C deleted file mode 100644 index f87ce33a9..000000000 --- a/cde/programs/nsgmls/parseAttribute.C +++ /dev/null @@ -1,474 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: parseAttribute.C /main/1 1996/07/29 17:09:07 cde-hp $ */ -// Copyright (c) 1994, 1995 James Clark -// See the file COPYING for copying permission. - -#include "splib.h" -#include "Parser.h" -#include "MessageArg.h" -#include "token.h" -#include "macros.h" -#include "ParserMessages.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -Boolean Parser::parseAttributeSpec(Boolean inDecl, - AttributeList &atts, - Boolean &netEnabling) - -{ - unsigned specLength = 0; - AttributeParameter::Type curParm; - - if (!parseAttributeParameter(inDecl, 0, curParm, netEnabling)) - return 0; - while (curParm != AttributeParameter::end) { - switch (curParm) { - case AttributeParameter::name: - { - Text text; - text.addChars(currentInput()->currentTokenStart(), - currentInput()->currentTokenLength(), - currentLocation()); - size_t nameMarkupIndex; - if (currentMarkup()) - nameMarkupIndex = currentMarkup()->size() - 1; - text.subst(*syntax().generalSubstTable(), syntax().space()); - if (!parseAttributeParameter(inDecl, 1, curParm, netEnabling)) - return 0; - if (curParm == AttributeParameter::vi) { - specLength += text.size() + syntax().normsep(); - if (!parseAttributeValueSpec(inDecl, text.string(), atts, - specLength)) - return 0; - // setup for next attribute - if (!parseAttributeParameter(inDecl, 0, curParm, netEnabling)) - return 0; - } - else { - if (currentMarkup()) - currentMarkup()->changeToAttributeValue(nameMarkupIndex); - if (!handleAttributeNameToken(text, atts, specLength)) - return 0; - } - } - break; - case AttributeParameter::nameToken: - { - Text text; - text.addChars(currentInput()->currentTokenStart(), - currentInput()->currentTokenLength(), - currentLocation()); - text.subst(*syntax().generalSubstTable(), syntax().space()); - if (!handleAttributeNameToken(text, atts, specLength)) - return 0; - if (!parseAttributeParameter(inDecl, 0, curParm, netEnabling)) - return 0; - } - break; - case AttributeParameter::recoverUnquoted: - { - if (!atts.recoverUnquoted(currentToken(), currentLocation(), *this)) { - // Don't treat it as an unquoted attribute value. - currentInput()->endToken(1); - if (!atts.handleAsUnterminated(*this)) - message(ParserMessages::attributeSpecCharacter, - StringMessageArg(currentToken())); - return 0; - } - if (!parseAttributeParameter(inDecl, 0, curParm, netEnabling)) - return 0; - } - break; - default: - CANNOT_HAPPEN(); - } - } - atts.finish(*this); - if (specLength > syntax().attsplen()) - message(ParserMessages::attsplen, - NumberMessageArg(syntax().attsplen()), - NumberMessageArg(specLength)); - return 1; -} - -Boolean Parser::handleAttributeNameToken(Text &text, - AttributeList &atts, - unsigned &specLength) -{ - unsigned index; - if (!atts.tokenIndex(text.string(), index)) { - if (atts.handleAsUnterminated(*this)) - return 0; - atts.noteInvalidSpec(); - message(ParserMessages::noSuchAttributeToken, - StringMessageArg(text.string())); - } - else { - if (!sd().shorttag()) - message(ParserMessages::attributeNameShorttag); - atts.setSpec(index, *this); - atts.setValueToken(index, text, *this, specLength); - } - return 1; -} - -Boolean Parser::parseAttributeValueSpec(Boolean inDecl, - const StringC &name, - AttributeList &atts, - unsigned &specLength) -{ - Mode mode = inDecl ? asMode : tagMode; - Markup *markup = currentMarkup(); - Token token = getToken(mode); - if (token == tokenS) { - if (markup) { - do { - markup->addS(currentChar()); - token = getToken(mode); - } while (token == tokenS); - } - else { - do { - token = getToken(mode); - } while (token == tokenS); - } - } - unsigned index; - Boolean valid = atts.attributeIndex(name, index); - if (!valid) { - message(ParserMessages::noSuchAttribute, StringMessageArg(name)); - atts.noteInvalidSpec(); - } - else - atts.setSpec(index, *this); - Text text; - switch (token) { - case tokenUnrecognized: - if (reportNonSgmlCharacter()) - return 0; - // fall through - case tokenEtago: - case tokenStago: - case tokenNet: - message(ParserMessages::unquotedAttributeValue); - extendUnquotedAttributeValue(); - if (markup) - markup->addAttributeValue(currentInput()); - text.addChars(currentInput()->currentTokenStart(), - currentInput()->currentTokenLength(), - currentLocation()); - break; - case tokenEe: - message(ParserMessages::attributeSpecEntityEnd); - return 0; - case tokenTagc: - case tokenDsc: - case tokenVi: - message(ParserMessages::attributeValueExpected); - return 0; - case tokenNameStart: - case tokenDigit: - case tokenLcUcNmchar: - if (!sd().shorttag()) - message(ParserMessages::attributeValueShorttag); - extendNameToken(syntax().litlen() >= syntax().normsep() - ? syntax().litlen() - syntax().normsep() - : 0, - ParserMessages::attributeValueLength); - if (markup) - markup->addAttributeValue(currentInput()); - text.addChars(currentInput()->currentTokenStart(), - currentInput()->currentTokenLength(), - currentLocation()); - break; - case tokenLit: - case tokenLita: - Boolean lita; - lita = (token == tokenLita); - if (!((valid ? atts.tokenized(index) : 1) - ? parseTokenizedAttributeValueLiteral(lita, text) - : parseAttributeValueLiteral(lita, text))) - return 0; - if (markup) - markup->addLiteral(text); - break; - default: - CANNOT_HAPPEN(); - } - if (valid) - return atts.setValue(index, text, *this, specLength); - else - return !AttributeValue::handleAsUnterminated(text, *this); -} - - -Boolean Parser::parseAttributeParameter(Boolean inDecl, - Boolean allowVi, - AttributeParameter::Type &result, - Boolean &netEnabling) -{ - Mode mode = inDecl ? asMode : tagMode; - Token token = getToken(mode); - Markup *markup = currentMarkup(); - if (markup) { - while (token == tokenS) { - markup->addS(currentChar()); - token = getToken(mode); - } - } - else { - while (token == tokenS) - token = getToken(mode); - } - switch (token) { - case tokenUnrecognized: - if (reportNonSgmlCharacter()) - return 0; - extendUnquotedAttributeValue(); - result = AttributeParameter::recoverUnquoted; - break; - case tokenEe: - message(ParserMessages::attributeSpecEntityEnd); - return 0; - case tokenEtago: - case tokenStago: - if (!sd().shorttag()) - message(ParserMessages::minimizedStartTag); - else if (options().warnUnclosedTag) - message(ParserMessages::unclosedStartTag); - result = AttributeParameter::end; - currentInput()->ungetToken(); - netEnabling = 0; - break; - case tokenNet: - if (markup) - markup->addDelim(Syntax::dNET); - if (!sd().shorttag()) - message(ParserMessages::minimizedStartTag); - else if (options().warnNet) - message(ParserMessages::netStartTag); - netEnabling = 1; - result = AttributeParameter::end; - break; - case tokenTagc: - if (markup) - markup->addDelim(Syntax::dTAGC); - netEnabling = 0; - result = AttributeParameter::end; - break; - case tokenDsc: - if (markup) - markup->addDelim(Syntax::dDSC); - result = AttributeParameter::end; - break; - case tokenNameStart: - extendNameToken(syntax().namelen(), ParserMessages::nameTokenLength); - if (markup) - markup->addName(currentInput()); - result = AttributeParameter::name; - break; - case tokenDigit: - case tokenLcUcNmchar: - extendNameToken(syntax().namelen(), ParserMessages::nameTokenLength); - if (markup) - markup->addName(currentInput()); - result = AttributeParameter::nameToken; - break; - case tokenLit: - case tokenLita: - message(allowVi - ? ParserMessages::attributeSpecLiteral - : ParserMessages::attributeSpecNameTokenExpected); - return 0; - case tokenVi: - if (!allowVi) { - message(ParserMessages::attributeSpecNameTokenExpected); - return 0; - } - if (markup) - markup->addDelim(Syntax::dVI); - result = AttributeParameter::vi; - break; - default: - CANNOT_HAPPEN(); - } - return 1; -} - -void Parser::extendUnquotedAttributeValue() -{ - InputSource *in = currentInput(); - size_t length = in->currentTokenLength(); - const Syntax &syn = syntax(); - for (;;) { - Xchar c = in->tokenChar(messenger()); - if (syn.isS(c) - || !syn.isSgmlChar(c) - || c == InputSource::eE - || c == syn.delimGeneral(Syntax::dTAGC)[0]) - break; - length++; - } - in->endToken(length); -} - -Boolean Parser::parseAttributeValueLiteral(Boolean lita, Text &text) -{ - size_t maxLength = (syntax().litlen() > syntax().normsep() - ? syntax().litlen() - syntax().normsep() - : 0); - if (parseLiteral(lita ? alitaMode : alitMode, aliteMode, - maxLength, - ParserMessages::attributeValueLength, - (wantMarkup() ? unsigned(literalDelimInfo) : 0), - text)) { - if (text.size() == 0 - && syntax().normsep() > syntax().litlen()) - message(ParserMessages::attributeValueLengthNeg, - NumberMessageArg(syntax().normsep() - syntax().litlen())); - return 1; - } - else - return 0; -} - -Boolean Parser::parseTokenizedAttributeValueLiteral(Boolean lita, Text &text) -{ - size_t maxLength = (syntax().litlen() > syntax().normsep() - ? syntax().litlen() - syntax().normsep() - : 0); - if (parseLiteral(lita ? talitaMode : talitMode, taliteMode, - maxLength, - ParserMessages::tokenizedAttributeValueLength, - literalSingleSpace - | (wantMarkup() ? unsigned(literalDelimInfo) : 0), - text)) { - if (text.size() == 0 - && syntax().normsep() > syntax().litlen()) - message(ParserMessages::tokenizedAttributeValueLengthNeg, - NumberMessageArg(syntax().normsep() - syntax().litlen())); - return 1; - } - else - return 0; -} - - -Boolean Parser::skipAttributeSpec() -{ - AttributeParameter::Type parm; - Boolean netEnabling; - if (!parseAttributeParameter(0, 0, parm, netEnabling)) - return 0; - while (parm != AttributeParameter::end) { - if (parm == AttributeParameter::name) { - size_t nameMarkupIndex = 0; - if (currentMarkup()) - nameMarkupIndex = currentMarkup()->size() - 1; - if (!parseAttributeParameter(0, 1, parm, netEnabling)) - return 0; - if (parm == AttributeParameter::vi) { - Token token = getToken(tagMode); - while (token == tokenS) { - if (currentMarkup()) - currentMarkup()->addS(currentChar()); - token = getToken(tagMode); - } - switch (token) { - case tokenUnrecognized: - if (!reportNonSgmlCharacter()) - message(ParserMessages::attributeSpecCharacter, - StringMessageArg(currentToken())); - return 0; - case tokenEe: - message(ParserMessages::attributeSpecEntityEnd); - return 0; - case tokenEtago: - case tokenStago: - case tokenNet: - case tokenTagc: - case tokenDsc: - case tokenVi: - message(ParserMessages::attributeValueExpected); - return 0; - case tokenNameStart: - case tokenDigit: - case tokenLcUcNmchar: - if (!sd().shorttag()) - message(ParserMessages::attributeValueShorttag); - extendNameToken(syntax().litlen() >= syntax().normsep() - ? syntax().litlen() - syntax().normsep() - : 0, - ParserMessages::attributeValueLength); - if (currentMarkup()) - currentMarkup()->addAttributeValue(currentInput()); - break; - case tokenLit: - case tokenLita: - { - Text text; - if (!parseLiteral(token == tokenLita ? talitaMode : talitMode, - taliteMode, - syntax().litlen(), - ParserMessages::tokenizedAttributeValueLength, - (currentMarkup() ? literalDelimInfo : 0) - | literalNoProcess, - text)) - return 0; - if (currentMarkup()) - currentMarkup()->addLiteral(text); - } - break; - default: - CANNOT_HAPPEN(); - } - if (!parseAttributeParameter(0, 0, parm, netEnabling)) - return 0; - } - else { - if (currentMarkup()) - currentMarkup()->changeToAttributeValue(nameMarkupIndex); - if (!sd().shorttag()) - message(ParserMessages::attributeNameShorttag); - } - } - else { - // It's a name token. - if (!parseAttributeParameter(0, 0, parm, netEnabling)) - return 0; - if (!sd().shorttag()) - message(ParserMessages::attributeNameShorttag); - } - } - if (netEnabling) - message(ParserMessages::startTagGroupNet); - return 1; -} - -#ifdef SP_NAMESPACE -} -#endif diff --git a/cde/programs/nsgmls/parseCommon.C b/cde/programs/nsgmls/parseCommon.C deleted file mode 100644 index 56464717a..000000000 --- a/cde/programs/nsgmls/parseCommon.C +++ /dev/null @@ -1,490 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: parseCommon.C /main/1 1996/07/29 17:09:12 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#include "splib.h" -#include "Parser.h" -#include "token.h" -#include "MessageArg.h" -#include "ParserMessages.h" -#include "constant.h" -#include "NumericCharRefOrigin.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -Boolean Parser::parseProcessingInstruction() -{ - currentInput()->startToken(); - Location location(currentLocation()); - StringC buf; - for (;;) { - Token token = getToken(piMode); - if (token == tokenPic) - break; - switch (token) { - case tokenEe: - message(ParserMessages::processingInstructionEntityEnd); - return 0; - case tokenUnrecognized: - reportNonSgmlCharacter(); - // fall through - case tokenChar: - buf += *currentInput()->currentTokenStart(); - if (buf.size()/2 > syntax().pilen()) { - message(ParserMessages::processingInstructionLength, - NumberMessageArg(syntax().pilen())); - message(ParserMessages::processingInstructionClose); - return 0; - } - break; - } - } - if (buf.size() > syntax().pilen()) - message(ParserMessages::processingInstructionLength, - NumberMessageArg(syntax().pilen())); - noteMarkup(); - eventHandler().pi(new (eventAllocator()) ImmediatePiEvent(buf, location)); - return 1; -} - -Boolean Parser::parseLiteral(Mode litMode, - Mode liteMode, - size_t maxLength, - const MessageType1 &tooLongMessage, - unsigned flags, - Text &text) -{ - unsigned startLevel = inputLevel(); - Mode currentMode = litMode; - // If the literal gets to be longer than this, then we assume - // that the closing delimiter has been omitted if we're at the end - // of a line and at the starting input level. - size_t reallyMaxLength = (maxLength > size_t(-1)/2 - ? size_t(-1) - : maxLength * 2); - text.clear(); - Location startLoc(currentLocation()); - if (flags & literalDelimInfo) - text.addStartDelim(currentLocation()); - for (;;) { - int done = 0; - Token token = getToken(currentMode); - switch (token) { - case tokenEe: - if (inputLevel() == startLevel) { - message(ParserMessages::literalLevel); - return 0; - } - text.addEntityEnd(currentLocation()); - popInputStack(); - if (inputLevel() == startLevel) - currentMode = litMode; - break; - case tokenUnrecognized: - if (reportNonSgmlCharacter()) - break; - message(ParserMessages::literalMinimumData, - StringMessageArg(currentToken())); - break; - case tokenRs: - text.ignoreChar(currentChar(), currentLocation()); - break; - case tokenRe: - if (text.size() > reallyMaxLength && inputLevel() == startLevel) { -#if 0 - message(tooLongMessage, NumberMessageArg(maxLength)); -#endif - // guess that the closing delimiter has been omitted - Messenger::setNextLocation(startLoc); - message(ParserMessages::literalClosingDelimiter); - return 0; - } - // fall through - case tokenSepchar: - if ((flags & literalSingleSpace) - && (text.size() == 0 || text.lastChar() == syntax().space())) - text.ignoreChar(currentChar(), currentLocation()); - else - text.addChar(syntax().space(), - Location(new ReplacementOrigin(currentLocation(), - currentChar()), - 0)); - break; - case tokenSpace: - if ((flags & literalSingleSpace) - && (text.size() == 0 || text.lastChar() == syntax().space())) - text.ignoreChar(currentChar(), currentLocation()); - else - text.addChar(currentChar(), currentLocation()); - break; - case tokenCroDigit: - { - Char c; - Location loc; - if (!parseNumericCharRef(c, loc)) - return 0; - if (flags & literalDataTag) { - if (!syntax().isSgmlChar(c)) - message(ParserMessages::dataTagPatternNonSgml); - else if (syntax().charSet(Syntax::functionChar)->contains(c)) - message(ParserMessages::dataTagPatternFunction); - } - if ((flags & literalSingleSpace) - && c == syntax().space() - && (text.size() == 0 || text.lastChar() == syntax().space())) - text.ignoreChar(c, loc); - else - text.addChar(c, loc); - } - break; - case tokenCroNameStart: - if (!parseNamedCharRef()) - return 0; - break; - case tokenEroGrpo: - message(inInstance() ? ParserMessages::eroGrpoStartTag : ParserMessages::eroGrpoProlog); - break; - case tokenLit: - case tokenLita: - if (flags & literalDelimInfo) - text.addEndDelim(currentLocation(), token == tokenLita); - done = 1; - break; - case tokenEroNameStart: - case tokenPeroNameStart: - { - ConstPtr entity; - Ptr origin; - if (!parseEntityReference(token == tokenPeroNameStart, - (flags & literalNoProcess) ? 2 : 0, - entity, origin)) - return 0; - if (!entity.isNull()) - entity->litReference(text, *this, origin, - (flags & literalSingleSpace) != 0); - if (inputLevel() > startLevel) - currentMode = liteMode; - } - break; - case tokenPeroGrpo: - message(ParserMessages::peroGrpoProlog); - break; - case tokenChar: - if (text.size() > reallyMaxLength && inputLevel() == startLevel - && currentChar() == syntax().standardFunction(Syntax::fRE)) { -#if 0 - message(tooLongMessage, NumberMessageArg(maxLength)); -#endif - // guess that the closing delimiter has been omitted - Messenger::setNextLocation(startLoc); - message(ParserMessages::literalClosingDelimiter); - return 0; - } - text.addChar(currentChar(), currentLocation()); - break; - } - if (done) break; - } - if ((flags & literalSingleSpace) - && text.size() > 0 - && text.lastChar() == syntax().space()) - text.ignoreLastChar(); - if (text.size() > maxLength) { - switch (litMode) { - case alitMode: - case alitaMode: - case talitMode: - case talitaMode: - if (AttributeValue::handleAsUnterminated(text, *this)) - return 0; - default: - break; - } - message(tooLongMessage, NumberMessageArg(maxLength)); - } - return 1; -} - -Boolean Parser::parseNamedCharRef() -{ - InputSource *in = currentInput(); - Index startIndex = currentLocation().index(); - in->discardInitial(); - extendNameToken(syntax().namelen(), ParserMessages::nameLength); - Char c; - Boolean valid; - StringC name; - getCurrentToken(syntax().generalSubstTable(), name); - if (!syntax().lookupFunctionChar(name, &c)) { - message(ParserMessages::functionName, StringMessageArg(name)); - valid = 0; - } - else { - valid = 1; - if (wantMarkup()) - getCurrentToken(name); // the original name - } - NamedCharRef::RefEndType refEndType; - switch (getToken(refMode)) { - case tokenRefc: - refEndType = NamedCharRef::endRefc; - break; - case tokenRe: - refEndType = NamedCharRef::endRE; - break; - default: - refEndType = NamedCharRef::endOmitted; - break; - } - in->startToken(); - if (valid) - in->pushCharRef(c, NamedCharRef(startIndex, refEndType, name)); - return 1; -} - -Boolean Parser::parseNumericCharRef(Char &ch, Location &loc) -{ - InputSource *in = currentInput(); - Location startLocation = currentLocation(); - in->discardInitial(); - extendNumber(syntax().namelen(), ParserMessages::numberLength); - Boolean valid = 1; - Char c = 0; - const Char *lim = in->currentTokenEnd(); - for (const Char *p = in->currentTokenStart(); p < lim; p++) { - int val = sd().digitWeight(*p); - if (c <= charMax/10 && (c *= 10) <= charMax - val) - c += val; - else { - message(ParserMessages::characterNumber, StringMessageArg(currentToken())); - valid = 0; - break; - } - } - if (valid && !sd().docCharsetDecl().charDeclared(c)) { - valid = 0; - message(ParserMessages::characterNumber, StringMessageArg(currentToken())); - } - Owner markupPtr; - if (wantMarkup()) { - markupPtr = new Markup; - markupPtr->addDelim(Syntax::dCRO); - markupPtr->addNumber(in); - switch (getToken(refMode)) { - case tokenRefc: - markupPtr->addDelim(Syntax::dREFC); - break; - case tokenRe: - markupPtr->addRefEndRe(); - break; - default: - break; - } - } - else - (void)getToken(refMode); - if (valid) { - ch = c; - loc = Location(new NumericCharRefOrigin(startLocation, - currentLocation().index() - + currentInput()->currentTokenLength() - - startLocation.index(), - markupPtr), - 0); - } - return valid; -} - -// ignoreLevel: 0 means don't ignore; -// 1 means parse name group and ignore if inactive -// 2 means ignore - -Boolean Parser::parseEntityReference(Boolean isParameter, - int ignoreLevel, - ConstPtr &entity, - Ptr &origin) -{ - InputSource *in = currentInput(); - Location startLocation(in->currentLocation()); - Owner markupPtr; - if (wantMarkup()) { - markupPtr = new Markup; - markupPtr->addDelim(isParameter ? Syntax::dPERO : Syntax::dERO); - } - if (ignoreLevel == 1) { - Markup savedMarkup; - Markup *savedCurrentMarkup = currentMarkup(); - if (savedCurrentMarkup) - savedCurrentMarkup->swap(savedMarkup); - Location savedMarkupLocation(markupLocation()); - startMarkup(markupPtr != 0, startLocation); - if (markupPtr) { - markupPtr->addDelim(Syntax::dGRPO); - markupPtr->swap(*currentMarkup()); - } - Boolean ignore; - if (!parseEntityReferenceNameGroup(ignore)) - return 0; - if (markupPtr) - currentMarkup()->swap(*markupPtr); - startMarkup(savedCurrentMarkup != 0, savedMarkupLocation); - if (savedCurrentMarkup) - savedMarkup.swap(*currentMarkup()); - if (!ignore) - ignoreLevel = 0; - in->startToken(); - Xchar c = in->tokenChar(messenger()); - if (!syntax().isNameStartCharacter(c)) { - message(ParserMessages::entityReferenceMissingName); - return 0; - } - } - in->discardInitial(); - if (isParameter) - extendNameToken(syntax().penamelen(), ParserMessages::parameterEntityNameLength); - else - extendNameToken(syntax().namelen(), ParserMessages::nameLength); - StringC &name = nameBuffer(); - getCurrentToken(syntax().entitySubstTable(), name); - if (ignoreLevel) - entity = new IgnoredEntity(name, - isParameter - ? Entity::parameterEntity - : Entity::generalEntity); - else { - entity = lookupEntity(isParameter, name, startLocation, 1); - if (entity.isNull()) { - if (haveApplicableDtd()) - message(isParameter - ? ParserMessages::parameterEntityUndefined - : ParserMessages::entityUndefined, - StringMessageArg(name)); - else - message(ParserMessages::entityApplicableDtd); - } - else if (entity->defaulted() && options().warnDefaultEntityReference) - message(ParserMessages::defaultEntityReference, StringMessageArg(name)); - } - if (markupPtr) { - markupPtr->addName(in); - switch (getToken(refMode)) { - case tokenRefc: - markupPtr->addDelim(Syntax::dREFC); - break; - case tokenRe: - markupPtr->addRefEndRe(); - break; - default: - break; - } - } - else - (void)getToken(refMode); - if (!entity.isNull()) - origin = new (internalAllocator()) - EntityOrigin(entity, startLocation, - currentLocation().index() - + currentInput()->currentTokenLength() - - startLocation.index(), - markupPtr); - else - origin = (EntityOrigin *)0; - return 1; -} - -Boolean Parser::parseComment(Mode mode) -{ - Location startLoc(currentLocation()); - Markup *markup = currentMarkup(); - if (markup) - markup->addCommentStart(); - Token token; - while ((token = getToken(mode)) != tokenCom) - switch (token) { - case tokenUnrecognized: - if (!reportNonSgmlCharacter()) - message(ParserMessages::sdCommentSignificant, - StringMessageArg(currentToken())); - break; - case tokenEe: - message(ParserMessages::commentEntityEnd, startLoc); - return 0; - default: - if (markup) - markup->addCommentChar(currentChar()); - break; - } - return 1; -} - -void Parser::extendNameToken(size_t maxLength, - const MessageType1 &tooLongMessage) -{ - InputSource *in = currentInput(); - size_t length = in->currentTokenLength(); - const Syntax &syn = syntax(); - while (syn.isNameCharacter(in->tokenChar(messenger()))) - length++; - if (length > maxLength) - message(tooLongMessage, NumberMessageArg(maxLength)); - in->endToken(length); -} - - -void Parser::extendNumber(size_t maxLength, const MessageType1 &tooLongMessage) -{ - InputSource *in = currentInput(); - size_t length = in->currentTokenLength(); - while (syntax().isDigit(in->tokenChar(messenger()))) - length++; - if (length > maxLength) - message(tooLongMessage, NumberMessageArg(maxLength)); - in->endToken(length); -} - -Boolean Parser::reportNonSgmlCharacter() -{ - Char c = getChar(); - if (!syntax().isSgmlChar(c)) { - message(ParserMessages::nonSgmlCharacter, NumberMessageArg(c)); - return 1; - } - return 0; -} - -void Parser::extendS() -{ - InputSource *in = currentInput(); - size_t length = in->currentTokenLength(); - while (syntax().isS(in->tokenChar(messenger()))) - length++; - in->endToken(length); -} - -#ifdef SP_NAMESPACE -} -#endif diff --git a/cde/programs/nsgmls/parseDecl.C b/cde/programs/nsgmls/parseDecl.C deleted file mode 100644 index ad10c20ed..000000000 --- a/cde/programs/nsgmls/parseDecl.C +++ /dev/null @@ -1,3166 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: parseDecl.C /main/1 1996/07/29 17:09:16 cde-hp $ */ -// Copyright (c) 1994, 1995 James Clark -// See the file COPYING for copying permission. - -// Prolog, dtd and declaration parsing. - -#include "splib.h" -#include "Parser.h" -#include "Param.h" -#include "Markup.h" -#include "ParserMessages.h" -#include "MessageArg.h" -#include "TokenMessageArg.h" -#include "token.h" -#include "macros.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -static const AllowedParams allowMdc(Param::mdc); -static const AllowedParams allowName(Param::name); -static const AllowedParams allowParamLiteral(Param::paramLiteral); -static const AllowedParams allowNameNameGroup(Param::name, Param::nameGroup); -static const AllowedParams allowDsoMdc(Param::dso, Param::mdc); -static AllowedParams allowNameMdc(Param::name, Param::mdc); -static AllowedParams - allowExplicitLinkRuleMdc(Param::mdc, - Param::name, - Param::nameGroup, - Param::indicatedReservedName + Syntax::rIMPLIED); -static AllowedParams - allowNameNameGroupMdc(Param::name, Param::nameGroup, Param::mdc); - -static const AllowedParams - allowLinkSetSpec(Param::name, - Param::indicatedReservedName + Syntax::rINITIAL, - Param::indicatedReservedName + Syntax::rEMPTY, - Param::indicatedReservedName + Syntax::rRESTORE); - -void Parser::doProlog() -{ - const unsigned maxTries = 10; - unsigned tries = 0; - do { - if (cancelled()) { - allDone(); - return; - } - Token token = getToken(proMode); - switch (token) { - case tokenUnrecognized: - if (reportNonSgmlCharacter()) - break; - if (hadDtd()) { - currentInput()->ungetToken(); - endProlog(); - return; - } - { - StringC gi; - if (lookingAtStartTag(gi)) { - currentInput()->ungetToken(); - if (!implyDtd(gi)) { - message(ParserMessages::noDtd); - giveUp(); - } - return; - } - } - - if (++tries >= maxTries) { - message(ParserMessages::noDtd); - giveUp(); - return; - } - message(ParserMessages::prologCharacter, StringMessageArg(currentToken())); - prologRecover(); - break; - case tokenEe: - if (hadDtd()) { - endProlog(); - return; - } - message(ParserMessages::documentEndProlog); - allDone(); - return; - case tokenMdoMdc: - // empty comment - emptyCommentDecl(); - break; - case tokenMdoCom: - if (!parseCommentDecl()) - prologRecover(); - break; - case tokenMdoNameStart: - setPass2Start(); - if (startMarkup(eventsWanted().wantPrologMarkup(), currentLocation())) - currentMarkup()->addDelim(Syntax::dMDO); - Syntax::ReservedName name; - if (parseDeclarationName(&name)) { - switch (name) { - case Syntax::rDOCTYPE: - if (!parseDoctypeDeclStart()) - giveUp(); - return; - case Syntax::rLINKTYPE: - if (!parseLinktypeDeclStart()) - giveUp(); - return; - case Syntax::rELEMENT: - case Syntax::rATTLIST: - case Syntax::rENTITY: - case Syntax::rNOTATION: - case Syntax::rSHORTREF: - case Syntax::rUSEMAP: - case Syntax::rUSELINK: - case Syntax::rLINK: - case Syntax::rIDLINK: - message(ParserMessages::prologDeclaration, - StringMessageArg(syntax().reservedName(name))); - if (!hadDtd()) - tries++; - prologRecover(); - break; - default: - message(ParserMessages::noSuchDeclarationType, - StringMessageArg(syntax().reservedName(name))); - prologRecover(); - break; - } - } - else - prologRecover(); - break; - case tokenPio: - if (!parseProcessingInstruction()) - prologRecover(); - break; - case tokenS: - if (eventsWanted().wantPrologMarkup()) { - extendS(); - eventHandler().sSep(new (eventAllocator()) - SSepEvent(currentInput()->currentTokenStart(), - currentInput()->currentTokenLength(), - currentLocation(), - 1)); - } - break; - default: - CANNOT_HAPPEN(); - } - } while (eventQueueEmpty()); -} - -void Parser::endProlog() -{ - if (baseDtd().isNull() - || baseDtd()->documentElementType()->definition()->undefined()) { - // We could continue, but there's not a lot of point. - giveUp(); - return; - } - if (maybeStartPass2()) - setPhase(prologPhase); - else { - if (inputLevel() == 0) { - allDone(); - return; - } - if (pass2()) - checkEntityStability(); - setPhase(instanceStartPhase); - startInstance(); - ConstPtr lpd; - Vector simpleLinkAtts; - Vector simpleLinkNames; - for (size_t i = 0; i < nActiveLink(); i++) - if (activeLpd(i).type() == Lpd::simpleLink) { - const SimpleLpd &lpd = (SimpleLpd &)activeLpd(i); - simpleLinkNames.push_back(lpd.name()); - simpleLinkAtts.resize(simpleLinkAtts.size() + 1); - simpleLinkAtts.back().init(lpd.attributeDef()); - simpleLinkAtts.back().finish(*this); - } - else - lpd = (ComplexLpd *)&activeLpd(i); - eventHandler().endProlog(new (eventAllocator()) - EndPrologEvent(baseDtd(), - lpd, - simpleLinkNames, - simpleLinkAtts, - currentLocation())); - } -} - -void Parser::prologRecover() -{ - unsigned skipCount = 0; - const unsigned skipMax = 250; - for (;;) { - Token token = getToken(proMode); - skipCount++; - if (token == tokenUnrecognized) { - token = getToken(mdMode); - if (token == tokenMdc) { - token = getToken(proMode); - if (token == tokenS) - return; - } - } - switch (token) { - case tokenUnrecognized: - (void)getChar(); - break; - case tokenEe: - return; - case tokenMdoMdc: - case tokenMdoCom: - case tokenMdoNameStart: - case tokenPio: - currentInput()->ungetToken(); - return; - case tokenS: - if (currentChar() == syntax().standardFunction(Syntax::fRE) - && skipCount >= skipMax) - return; - default: - break; - } - } -} - -void Parser::doDeclSubset() -{ - do { - if (cancelled()) { - allDone(); - return; - } - Token token = getToken(currentMode()); - unsigned startLevel = inputLevel(); - Boolean inDtd = !haveDefLpd(); - switch (token) { - case tokenUnrecognized: - if (reportNonSgmlCharacter()) - break; - message(ParserMessages::declSubsetCharacter, StringMessageArg(currentToken())); - declSubsetRecover(startLevel); - break; - case tokenEe: - if (inputLevel() == specialParseInputLevel()) { - // FIXME have separate messages for each type of special parse - message(ParserMessages::specialParseEntityEnd); - } - if (eventsWanted().wantPrologMarkup()) - eventHandler().entityEnd(new (eventAllocator()) - EntityEndEvent(currentLocation())); - if (inputLevel() == 2) { - ConstPtr e - = currentLocation().origin()->asEntityOrigin()->entity(); - if (!e.isNull() - && (e->declType() == Entity::doctype - || e->declType() == Entity::linktype)) { - popInputStack(); - if (!(inDtd - ? parseDoctypeDeclEnd(e->defLocation().origin().isNull()) - : parseLinktypeDeclEnd())) - ; // FIXME recover - setPhase(prologPhase); - return; - } - } - if (inputLevel() == 1) { - if (finalPhase() == declSubsetPhase) { - checkDtd(defDtd()); - endDtd(); - } - else - // Give message before popping stack. - message(inDtd - ? ParserMessages::documentEndDtdSubset - : ParserMessages::documentEndLpdSubset); - popInputStack(); - allDone(); - } - else - popInputStack(); - return; - case tokenDsc: // end of declaration subset - // FIXME what's the right location? - if (!referenceDsEntity(currentLocation())) { - if (!(inDtd ? parseDoctypeDeclEnd() : parseLinktypeDeclEnd())) - ; // FIXME recover - setPhase(prologPhase); - } - return; - case tokenMdoNameStart: // named markup declaration - if (startMarkup(eventsWanted().wantPrologMarkup(), currentLocation())) - currentMarkup()->addDelim(Syntax::dMDO); - Syntax::ReservedName name; - Boolean result; - if (parseDeclarationName(&name, - inDtd && !options().errorAfdr)) { - switch (name) { - case Syntax::rANY: // used for entity; - Ptr origin; - if (parseEntityReference(1, token == tokenPeroGrpo, entity, origin)) { - if (!entity.isNull()) - entity->dsReference(*this, origin); - } - else - declSubsetRecover(startLevel); - } - break; - case tokenPio: // processing instruction - if (!parseProcessingInstruction()) - declSubsetRecover(startLevel); - break; - case tokenS: // white space - if (eventsWanted().wantPrologMarkup()) { - extendS(); - eventHandler().sSep(new (eventAllocator()) - SSepEvent(currentInput()->currentTokenStart(), - currentInput()->currentTokenLength(), - currentLocation(), - 1)); - } - break; - case tokenIgnoredChar: - // from an ignored marked section - if (eventsWanted().wantPrologMarkup()) - eventHandler().ignoredChars(new (eventAllocator()) - IgnoredCharsEvent(currentInput()->currentTokenStart(), - currentInput()->currentTokenLength(), - currentLocation(), - 1)); - break; - case tokenRe: - case tokenRs: - case tokenCroDigit: - case tokenCroNameStart: - case tokenEroNameStart: - case tokenEroGrpo: - case tokenChar: - // these can occur in a cdata or rcdata marked section - message(ParserMessages::dataMarkedSectionDeclSubset); - declSubsetRecover(startLevel); - break; - default: - CANNOT_HAPPEN(); - } - } while (eventQueueEmpty()); -} - -void Parser::declSubsetRecover(unsigned startLevel) -{ - for (;;) { - Token token = getToken(currentMode()); - switch (token) { - case tokenUnrecognized: - (void)getChar(); - break; - case tokenEe: - if (inputLevel() <= startLevel) - return; - popInputStack(); - break; - case tokenMdoCom: - case tokenDsc: - case tokenMdoNameStart: - case tokenMdoMdc: - case tokenMdoDso: - case tokenMscMdc: - case tokenPio: - if (inputLevel() == startLevel) { - currentInput()->ungetToken(); - return; - } - break; - default: - break; - } - } -} - -Boolean Parser::lookingAtStartTag(StringC &gi) -{ - // This is harder than might be expected since we may not have compiled - // the recognizers for the instance yet. - const StringC &stago = instanceSyntax().delimGeneral(Syntax::dSTAGO); - for (size_t i = currentInput()->currentTokenLength(); - i < stago.size(); - i++) - if (currentInput()->tokenChar(messenger()) == InputSource::eE) - return 0; - StringC delim; - getCurrentToken(instanceSyntax().generalSubstTable(), delim); - if (delim != stago) - return 0; - Xchar c = currentInput()->tokenChar(messenger()); - if (!instanceSyntax().isNameStartCharacter(c)) - return 0; - do { - gi += Char(c); - c = currentInput()->tokenChar(messenger()); - } while (instanceSyntax().isNameCharacter(c)); - return 1; -} - -Boolean Parser::parseDeclarationName(Syntax::ReservedName *result, - Boolean allowAfdr) -{ - currentInput()->discardInitial(); - extendNameToken(syntax().namelen(), ParserMessages::nameLength); - StringC &name = nameBuffer(); - getCurrentToken(syntax().generalSubstTable(), name); - if (!syntax().lookupReservedName(name, result)) { - if (allowAfdr && name == sd().execToDoc("AFDR")) { - *result = Syntax::rANY; - if (currentMarkup()) - currentMarkup()->addName(currentInput()); - } - else { - message(ParserMessages::noSuchDeclarationType, StringMessageArg(name)); - return 0; - } - } - else if (currentMarkup()) - currentMarkup()->addReservedName(*result, currentInput()); - return 1; -} - -Boolean Parser::parseElementDecl() -{ - unsigned declInputLevel = inputLevel(); - Param parm; - if (!parseParam(allowNameNameGroup, declInputLevel, parm)) - return 0; - Vector nameVector; - if (parm.type == Param::nameGroup) - parm.nameTokenVector.swap(nameVector); - else { - nameVector.resize(1); - parm.token.swap(nameVector[0].name); - } - static AllowedParams - allowRankOmissionContent(Param::number, - Param::reservedName + Syntax::rO, - Param::minus, - Param::reservedName + Syntax::rCDATA, - Param::reservedName + Syntax::rRCDATA, - Param::reservedName + Syntax::rEMPTY, - Param::reservedName + Syntax::rANY, - Param::modelGroup); - if (!parseParam(allowRankOmissionContent, declInputLevel, parm)) - return 0; - StringC rankSuffix; - Vector elements(nameVector.size()); - Vector rankStems; - Vector constRankStems; - size_t i; - if (parm.type == Param::number) { - parm.token.swap(rankSuffix); - rankStems.resize(nameVector.size()); - constRankStems.resize(nameVector.size()); - for (i = 0; i < elements.size(); i++) { - StringC name(nameVector[i].name); - name += rankSuffix; - if (name.size() > syntax().namelen() - && nameVector[i].name.size() <= syntax().namelen()) - message(ParserMessages::genericIdentifierLength, - NumberMessageArg(syntax().namelen())); - elements[i] = lookupCreateElement(name); - rankStems[i] = lookupCreateRankStem(nameVector[i].name); - constRankStems[i] = rankStems[i]; - } - static AllowedParams - allowOmissionContent(Param::reservedName + Syntax::rO, - Param::minus, - Param::reservedName + Syntax::rCDATA, - Param::reservedName + Syntax::rRCDATA, - Param::reservedName + Syntax::rEMPTY, - Param::reservedName + Syntax::rANY, - Param::modelGroup); - Token token = getToken(mdMinusMode); - if (token == tokenNameStart) - message(ParserMessages::psRequired); - currentInput()->ungetToken(); - if (!parseParam(allowOmissionContent, declInputLevel, parm)) - return 0; - } - else { - for (i = 0; i < elements.size(); i++) - elements[i] = lookupCreateElement(nameVector[i].name); - } - for (i = 0; i < elements.size(); i++) - if (defDtd().lookupRankStem(elements[i]->name())) - message(ParserMessages::rankStemGenericIdentifier, - StringMessageArg(elements[i]->name())); - unsigned char omitFlags = 0; - if (parm.type == Param::minus - || parm.type == Param::reservedName + Syntax::rO) { - omitFlags |= ElementDefinition::omitSpec; - if (parm.type != Param::minus) - omitFlags |= ElementDefinition::omitStart; - static AllowedParams allowOmission(Param::reservedName + Syntax::rO, - Param::minus); - if (!parseParam(allowOmission, declInputLevel, parm)) - return 0; - if (parm.type != Param::minus) - omitFlags |= ElementDefinition::omitEnd; - static AllowedParams allowContent(Param::reservedName + Syntax::rCDATA, - Param::reservedName + Syntax::rRCDATA, - Param::reservedName + Syntax::rEMPTY, - Param::reservedName + Syntax::rANY, - Param::modelGroup); - if (!parseParam(allowContent, declInputLevel, parm)) - return 0; - } - else { - if (sd().omittag()) - message(ParserMessages::missingTagMinimization); - } - Ptr def; - switch (parm.type) { - case Param::reservedName + Syntax::rCDATA: - def = new ElementDefinition(markupLocation(), - defDtd().allocElementDefinitionIndex(), - omitFlags, - ElementDefinition::cdata); - if (!parseParam(allowMdc, declInputLevel, parm)) - return 0; - break; - case Param::reservedName + Syntax::rRCDATA: - def = new ElementDefinition(markupLocation(), - defDtd().allocElementDefinitionIndex(), - omitFlags, - ElementDefinition::rcdata); - if (!parseParam(allowMdc, declInputLevel, parm)) - return 0; - break; - case Param::reservedName + Syntax::rEMPTY: - def = new ElementDefinition(markupLocation(), - defDtd().allocElementDefinitionIndex(), - omitFlags, - ElementDefinition::empty); - if ((omitFlags & ElementDefinition::omitSpec) - && !(omitFlags & ElementDefinition::omitEnd) - && options().warnShould) - message(ParserMessages::emptyOmitEndTag); - if (!parseParam(allowMdc, declInputLevel, parm)) - return 0; - break; - case Param::reservedName + Syntax::rANY: - def = new ElementDefinition(markupLocation(), - defDtd().allocElementDefinitionIndex(), - omitFlags, - ElementDefinition::any); - if (!parseExceptions(declInputLevel, def)) - return 0; - break; - case Param::modelGroup: - { - unsigned long cnt = parm.modelGroupPtr->grpgtcnt(); - // The outermost model group isn't formally a content token. - if (cnt - 1 > syntax().grpgtcnt()) - message(ParserMessages::grpgtcnt, NumberMessageArg(syntax().grpgtcnt())); - Owner - modelGroup(new CompiledModelGroup(parm.modelGroupPtr)); - Vector ambiguities; - Boolean pcdataUnreachable; - modelGroup->compile(currentDtd().nElementTypeIndex(), ambiguities, - pcdataUnreachable); - if (pcdataUnreachable && options().warnMixedContent) - message(ParserMessages::pcdataUnreachable); - for (i = 0; i < ambiguities.size(); i++) { - const ContentModelAmbiguity &a = ambiguities[i]; - reportAmbiguity(a.from, a.to1, a.to2, a.andDepth); - } - def = new ElementDefinition(markupLocation(), - defDtd().allocElementDefinitionIndex(), - omitFlags, - ElementDefinition::modelGroup, - modelGroup); - if (!parseExceptions(declInputLevel, def)) - return 0; - } - break; - } - if (rankSuffix.size() > 0) - def->setRank(rankSuffix, constRankStems); - ConstPtr constDef(def); - for (i = 0; i < elements.size(); i++) { - if (elements[i]->definition() != 0) - message(ParserMessages::duplicateElementDefinition, - StringMessageArg(elements[i]->name())); - else { - elements[i]->setElementDefinition(constDef, i); - if (!elements[i]->attributeDef().isNull()) - checkElementAttribute(elements[i]); - } - if (rankStems.size() > 0) - rankStems[i]->addDefinition(constDef); - } - if (currentMarkup()) { - Vector v(elements.size()); - for (i = 0; i < elements.size(); i++) - v[i] = elements[i]; - eventHandler().elementDecl(new (eventAllocator()) - ElementDeclEvent(v, currentDtdPointer(), - markupLocation(), - currentMarkup())); - } - return 1; -} - -void Parser::reportAmbiguity(const LeafContentToken *from, - const LeafContentToken *to1, - const LeafContentToken *to2, - unsigned ambigAndDepth) -{ - StringC toName; - const ElementType *toType = to1->elementType(); - if (toType) - toName = toType->name(); - else { - toName = syntax().delimGeneral(Syntax::dRNI); - toName += syntax().reservedName(Syntax::rPCDATA); - } - unsigned to1Index = to1->typeIndex() + 1; - unsigned to2Index = to2->typeIndex() + 1; - if (from->isInitial()) - message(ParserMessages::ambiguousModelInitial, - StringMessageArg(toName), - OrdinalMessageArg(to1Index), - OrdinalMessageArg(to2Index)); - else { - StringC fromName; - const ElementType *fromType = from->elementType(); - if (fromType) - fromName = fromType->name(); - else { - fromName = syntax().delimGeneral(Syntax::dRNI); - fromName += syntax().reservedName(Syntax::rPCDATA); - } - unsigned fromIndex = from->typeIndex() + 1; - unsigned andMatches = from->andDepth() - ambigAndDepth; - if (andMatches == 0) - message(ParserMessages::ambiguousModel, - StringMessageArg(fromName), - OrdinalMessageArg(fromIndex), - StringMessageArg(toName), - OrdinalMessageArg(to1Index), - OrdinalMessageArg(to2Index)); - else if (andMatches == 1) - message(ParserMessages::ambiguousModelSingleAnd, - StringMessageArg(fromName), - OrdinalMessageArg(fromIndex), - StringMessageArg(toName), - OrdinalMessageArg(to1Index), - OrdinalMessageArg(to2Index)); - else - message(ParserMessages::ambiguousModelMultipleAnd, - StringMessageArg(fromName), - OrdinalMessageArg(fromIndex), - NumberMessageArg(andMatches), - StringMessageArg(toName), - OrdinalMessageArg(to1Index), - OrdinalMessageArg(to2Index)); - } -} - - -// Check the compatibility of the attribute definition with -// the element definition. - -void Parser::checkElementAttribute(const ElementType *e, size_t checkFrom) -{ - const AttributeDefinitionList *attDef = e->attributeDef().pointer(); - Boolean conref = 0; - ASSERT(e != 0); - const ElementDefinition *edef = e->definition(); - ASSERT(edef != 0); - ASSERT(attDef != 0); - size_t attDefLength = attDef->size(); - for (size_t i = checkFrom; i < attDefLength; i++) { - const AttributeDefinition *p = attDef->def(i); - if (p->isConref()) - conref = 1; - if (p->isNotation() - && edef->declaredContent() == ElementDefinition::empty) - message(ParserMessages::notationEmpty, StringMessageArg(e->name())); - } - if (conref) { -#if 0 - if (edef->omittedTagSpec() && !edef->canOmitEndTag() - && options().warnShould) - message(ParserMessages::conrefOmitEndTag, StringMessageArg(e->name())); -#endif - if (edef->declaredContent() == ElementDefinition::empty) - message(ParserMessages::conrefEmpty, StringMessageArg(e->name())); - } -} - -ElementType *Parser::lookupCreateElement(const StringC &name) -{ - ElementType *e = defDtd().lookupElementType(name); - if (!e) { - if (haveDefLpd()) - message(ParserMessages::noSuchSourceElement, StringMessageArg(name)); - else { - e = new ElementType(name, defDtd().nElementTypeIndex()); - defDtd().insertElementType(e); - } - } - return e; -} - -RankStem *Parser::lookupCreateRankStem(const StringC &name) -{ - RankStem *r = defDtd().lookupRankStem(name); - if (!r) { - r = new RankStem(name, defDtd().nRankStem()); - defDtd().insertRankStem(r); - const ElementType *e = defDtd().lookupElementType(name); - if (e && e->definition() != 0) - message(ParserMessages::rankStemGenericIdentifier, StringMessageArg(name)); - } - return r; -} - -Boolean Parser::parseExceptions(unsigned declInputLevel, - Ptr &def) -{ - Param parm; - static AllowedParams - allowExceptionsMdc(Param::mdc, Param::exclusions, Param::inclusions); - if (!parseParam(allowExceptionsMdc, declInputLevel, parm)) - return 0; - if (parm.type == Param::exclusions) { - def->setExclusions(parm.elementVector); - static AllowedParams allowInclusionsMdc(Param::mdc, Param::inclusions); - if (!parseParam(allowInclusionsMdc, declInputLevel, parm)) - return 0; - } - if (parm.type == Param::inclusions) { - def->setInclusions(parm.elementVector); - size_t nI = def->nInclusions(); - size_t nE = def->nExclusions(); - if (nE) { - for (size_t i = 0; i < nI; i++) { - const ElementType *e = def->inclusion(i); - for (size_t j = 0; j < nE; j++) - if (def->exclusion(j) == e) - message(ParserMessages::excludeIncludeSame, - StringMessageArg(e->name())); - } - } - if (!parseParam(allowMdc, declInputLevel, parm)) - return 0; - } - return 1; -} - -Boolean Parser::parseAttlistDecl() -{ - unsigned declInputLevel = inputLevel(); - Param parm; - size_t attcnt = 0; - size_t idIndex = size_t(-1); - size_t notationIndex = size_t(-1); - Boolean anyCurrent = 0; - - Boolean isNotation; - Vector attributed; - if (!parseAttributed(declInputLevel, parm, attributed, isNotation)) - return 0; - Vector > defs; - if (!parseParam(allowName, declInputLevel, parm)) - return 0; - do { - StringC attributeName; - parm.token.swap(attributeName); - attcnt++; - Boolean duplicate = 0; - size_t i; - for (i = 0; i < defs.size(); i++) - if (defs[i]->name() == attributeName) { - message(ParserMessages::duplicateAttributeDef, - StringMessageArg(attributeName)); - duplicate = 1; - break; - } - Owner declaredValue; - if (!parseDeclaredValue(declInputLevel, isNotation, parm, declaredValue)) - return 0; - if (!duplicate) { - if (declaredValue->isId()) { - if (idIndex != size_t(-1)) - message(ParserMessages::multipleIdAttributes, - StringMessageArg(defs[idIndex]->name())); - idIndex = defs.size(); - } - else if (declaredValue->isNotation()) { - if (notationIndex != size_t(-1)) - message(ParserMessages::multipleNotationAttributes, - StringMessageArg(defs[notationIndex]->name())); - notationIndex = defs.size(); - } - } - const Vector *tokensPtr = declaredValue->getTokens(); - if (tokensPtr) { - size_t nTokens = tokensPtr->size(); - Vector::const_iterator tokens = tokensPtr->begin(); - for (i = 0; i < nTokens; i++) { - for (size_t j = 0; j < defs.size(); j++) - if (defs[j]->containsToken(tokens[i])) { - message(ParserMessages::duplicateAttributeToken, - StringMessageArg(tokens[i])); - break; - } - } - attcnt += nTokens; - } - Owner def; - if (!parseDefaultValue(declInputLevel, isNotation, parm, attributeName, - declaredValue, def, anyCurrent)) - return 0; - if (haveDefLpd() && defLpd().type() == Lpd::simpleLink && !def->isFixed()) - message(ParserMessages::simpleLinkFixedAttribute); - if (!duplicate) { - defs.resize(defs.size() + 1); - defs.back() = def.extract(); - } - static AllowedParams allowNameMdc(Param::name, Param::mdc); - if (!parseParam(allowNameMdc, declInputLevel, parm)) - return 0; - } while (parm.type != Param::mdc); - if (attcnt > syntax().attcnt()) - message(ParserMessages::attcnt, - NumberMessageArg(attcnt), - NumberMessageArg(syntax().attcnt())); - if (haveDefLpd() && !isNotation) { - if (defLpd().type() == Lpd::simpleLink) { - for (size_t i = 0; i < attributed.size(); i++) { - const ElementType *e = (const ElementType *)attributed[i]; - if (e) { - if (e->name() == defLpd().sourceDtd()->name()) { - SimpleLpd &lpd = (SimpleLpd &)defLpd(); - if (lpd.attributeDef().isNull()) - lpd.setAttributeDef(new AttributeDefinitionList(defs, 0)); - else - message(ParserMessages::duplicateAttlistElement, - StringMessageArg(e->name())); - } - else - message(ParserMessages::simpleLinkAttlistElement, - StringMessageArg(e->name())); - } - } - } - else { - Ptr - adl(new AttributeDefinitionList(defs, - defComplexLpd() - .allocAttributeDefinitionListIndex())); - for (size_t i = 0; i < attributed.size(); i++) { - const ElementType *e = (const ElementType *)attributed[i]; - if (e) { - if (defComplexLpd().attributeDef(e).isNull()) - defComplexLpd().setAttributeDef(e, adl); - else - message(ParserMessages::duplicateAttlistElement, - StringMessageArg(e->name())); - } - } - } - } - else { - Ptr - adl(new AttributeDefinitionList(defs, - defDtd() - .allocAttributeDefinitionListIndex(), - anyCurrent, - idIndex, - notationIndex)); - for (size_t i = 0; i < attributed.size(); i++) { - if (attributed[i]->attributeDef().isNull()) { - attributed[i]->setAttributeDef(adl); - if (!isNotation) { - ElementType *e = (ElementType *)attributed[i]; - if (e->definition() != 0) - checkElementAttribute(e); - } - } - else if (options().errorAfdr) { - if (!hadAfdrDecl()) { - message(ParserMessages::missingAfdrDecl); - setHadAfdrDecl(); - } - if (isNotation) - message(ParserMessages::duplicateAttlistNotation, - StringMessageArg(((Notation *)attributed[i])->name())); - else - message(ParserMessages::duplicateAttlistElement, - StringMessageArg(((ElementType *)attributed[i])->name())); - } - else { - AttributeDefinitionList *curAdl; - { - // Use block to make sure temporary gets destroyed. - curAdl = attributed[i]->attributeDef().pointer(); - } - size_t oldSize = curAdl->size(); - if (curAdl->count() != 1) { - Vector > copy(oldSize); - for (size_t j = 0; j < oldSize; j++) - copy[j] = curAdl->def(j)->copy(); - Ptr adlCopy - = new AttributeDefinitionList(copy, - defDtd().allocAttributeDefinitionListIndex(), - curAdl->anyCurrent(), - curAdl->idIndex(), - curAdl->notationIndex()); - attributed[i]->setAttributeDef(adlCopy); - curAdl = adlCopy.pointer(); - } - // FIXME check for multiple ID and NOTATION attributes - for (size_t j = 0; j < adl->size(); j++) { - unsigned tem; - if (!curAdl->attributeIndex(adl->def(j)->name(), tem)) - curAdl->append(adl->def(j)->copy()); - } - if (!isNotation) { - ElementType *e = (ElementType *)attributed[i]; - if (e->definition() != 0) - checkElementAttribute(e, oldSize); - } - } - } - } - if (currentMarkup()) { - if (isNotation) { - Vector > v(attributed.size()); - for (size_t i = 0; i < attributed.size(); i++) - v[i] = (Notation *)attributed[i]; - eventHandler() - .attlistNotationDecl(new (eventAllocator()) - AttlistNotationDeclEvent(v, - markupLocation(), - currentMarkup())); - } - else { - Vector v(attributed.size()); - for (size_t i = 0; i < attributed.size(); i++) - v[i] = (ElementType *)attributed[i]; - if (haveDefLpd()) - eventHandler() - .linkAttlistDecl(new (eventAllocator()) - LinkAttlistDeclEvent(v, - defLpdPointer(), - markupLocation(), - currentMarkup())); - else - eventHandler().attlistDecl(new (eventAllocator()) - AttlistDeclEvent(v, - currentDtdPointer(), - markupLocation(), - currentMarkup())); - } - } - if (isNotation) { - Dtd::EntityIter entityIter(defDtd().generalEntityIter()); - for (;;) { - Ptr entity(entityIter.next()); - if (entity.isNull()) - break; - const ExternalDataEntity *external = entity->asExternalDataEntity(); - if (external) { - const Notation *entityNotation = external->notation(); - for (size_t i = 0; i < attributed.size(); i++) - if ((Notation *)attributed[i] == entityNotation) { - AttributeList attributes(entityNotation->attributeDef()); - attributes.finish(*this); - ((ExternalDataEntity *)entity.pointer()) - ->setNotation((Notation *)attributed[i], attributes); - } - } - } - } - return 1; -} - - -Boolean Parser::parseAttributed(unsigned declInputLevel, - Param &parm, - Vector &attributed, - Boolean &isNotation) -{ - // There's a hack in getIndicatedReservedName allows #ALL as #ANY. - static AllowedParams - allowNameGroupNotation(Param::name, - Param::nameGroup, - Param::indicatedReservedName + Syntax::rNOTATION); - static AllowedParams - allowNameGroupNotationAll(Param::name, - Param::nameGroup, - Param::indicatedReservedName - + Syntax::rNOTATION, - Param::indicatedReservedName - + Syntax::rANY); - if (!parseParam(options().errorAfdr || haveDefLpd() - ? allowNameGroupNotation - : allowNameGroupNotationAll, - declInputLevel, parm)) - return 0; - if (parm.type == Param::indicatedReservedName + Syntax::rNOTATION) { - isNotation = 1; - static AllowedParams - allowNameGroupAll(Param::name, - Param::nameGroup, - Param::indicatedReservedName + Syntax::rANY); - if (!parseParam(options().errorAfdr || haveDefLpd() - ? allowNameNameGroup - : allowNameGroupAll, - declInputLevel, parm)) - return 0; - if (parm.type == Param::nameGroup) { - attributed.resize(parm.nameTokenVector.size()); - for (size_t i = 0; i < attributed.size(); i++) - attributed[i] = lookupCreateNotation(parm.nameTokenVector[i].name); - } - else { - if (parm.type != Param::name && !hadAfdrDecl()) { - message(ParserMessages::missingAfdrDecl); - setHadAfdrDecl(); - } - attributed.resize(1); - attributed[0] - = lookupCreateNotation(parm.type == Param::name - ? parm.token - : syntax().rniReservedName(Syntax::rANY)); - } - } - else { - isNotation = 0; - if (parm.type == Param::nameGroup) { - attributed.resize(parm.nameTokenVector.size()); - for (size_t i = 0; i < attributed.size(); i++) - attributed[i] = lookupCreateElement(parm.nameTokenVector[i].name); - } - else { - if (parm.type != Param::name && !hadAfdrDecl()) { - message(ParserMessages::missingAfdrDecl); - setHadAfdrDecl(); - } - attributed.resize(1); - attributed[0] - = lookupCreateElement(parm.type == Param::name - ? parm.token - : syntax().rniReservedName(Syntax::rANY)); - } - } - return 1; -} - -Boolean Parser::parseDeclaredValue(unsigned declInputLevel, - Boolean isNotation, - Param &parm, - Owner &declaredValue) -{ - static Param::Type declaredValues[] = { - Param::reservedName + Syntax::rCDATA, - Param::reservedName + Syntax::rENTITY, - Param::reservedName + Syntax::rENTITIES, - Param::reservedName + Syntax::rID, - Param::reservedName + Syntax::rIDREF, - Param::reservedName + Syntax::rIDREFS, - Param::reservedName + Syntax::rNAME, - Param::reservedName + Syntax::rNAMES, - Param::reservedName + Syntax::rNMTOKEN, - Param::reservedName + Syntax::rNMTOKENS, - Param::reservedName + Syntax::rNUMBER, - Param::reservedName + Syntax::rNUMBERS, - Param::reservedName + Syntax::rNUTOKEN, - Param::reservedName + Syntax::rNUTOKENS, - Param::reservedName + Syntax::rNOTATION, - Param::nameTokenGroup - }; - static AllowedParams allowDeclaredValue(declaredValues, - SIZEOF(declaredValues)); - if (!parseParam(allowDeclaredValue, declInputLevel, parm)) - return 0; - enum { asDataAttribute = 01, asLinkAttribute = 02 }; - unsigned allowedFlags = asDataAttribute|asLinkAttribute; - switch (parm.type) { - case Param::reservedName + Syntax::rCDATA: - declaredValue = new CdataDeclaredValue; - break; - case Param::reservedName + Syntax::rENTITY: - declaredValue = new EntityDeclaredValue(0); - allowedFlags = asLinkAttribute; - break; - case Param::reservedName + Syntax::rENTITIES: - declaredValue = new EntityDeclaredValue(1); - allowedFlags = asLinkAttribute; - break; - case Param::reservedName + Syntax::rID: - declaredValue = new IdDeclaredValue; - allowedFlags = 0; - break; - case Param::reservedName + Syntax::rIDREF: - declaredValue = new IdrefDeclaredValue(0); - allowedFlags = 0; - break; - case Param::reservedName + Syntax::rIDREFS: - declaredValue = new IdrefDeclaredValue(1); - allowedFlags = 0; - break; - case Param::reservedName + Syntax::rNAME: - declaredValue - = new TokenizedDeclaredValue(TokenizedDeclaredValue::name, 0); - break; - case Param::reservedName + Syntax::rNAMES: - declaredValue - = new TokenizedDeclaredValue(TokenizedDeclaredValue::name, 1); - break; - case Param::reservedName + Syntax::rNMTOKEN: - declaredValue - = new TokenizedDeclaredValue(TokenizedDeclaredValue::nameToken, 0); - break; - case Param::reservedName + Syntax::rNMTOKENS: - declaredValue - = new TokenizedDeclaredValue(TokenizedDeclaredValue::nameToken, 1); - break; - case Param::reservedName + Syntax::rNUMBER: - declaredValue - = new TokenizedDeclaredValue(TokenizedDeclaredValue::number, 0); - break; - case Param::reservedName + Syntax::rNUMBERS: - declaredValue - = new TokenizedDeclaredValue(TokenizedDeclaredValue::number, 1); - break; - case Param::reservedName + Syntax::rNUTOKEN: - declaredValue - = new TokenizedDeclaredValue(TokenizedDeclaredValue::numberToken, 0); - break; - case Param::reservedName + Syntax::rNUTOKENS: - declaredValue - = new TokenizedDeclaredValue(TokenizedDeclaredValue::numberToken, 1); - break; - case Param::reservedName + Syntax::rNOTATION: - { - static AllowedParams allowNameGroup(Param::nameGroup); - if (!parseParam(allowNameGroup, declInputLevel, parm)) - return 0; - Vector group(parm.nameTokenVector.size()); - for (size_t i = 0; i < group.size(); i++) - parm.nameTokenVector[i].name.swap(group[i]); - declaredValue = new NotationDeclaredValue(group); - allowedFlags = 0; - } - break; - case Param::nameTokenGroup: - { - Vector group(parm.nameTokenVector.size()); - for (size_t i = 0; i < group.size(); i++) - parm.nameTokenVector[i].name.swap(group[i]); - declaredValue = new NameTokenGroupDeclaredValue(group); - } - break; - default: - CANNOT_HAPPEN(); - } - if (isNotation) { - if (!(allowedFlags & asDataAttribute)) - message(ParserMessages::dataAttributeDeclaredValue); - } - else if (haveDefLpd() && !isNotation && !(allowedFlags & asLinkAttribute)) - message(ParserMessages::linkAttributeDeclaredValue); - return 1; -} - -Boolean Parser::parseDefaultValue(unsigned declInputLevel, - Boolean isNotation, - Param &parm, - const StringC &attributeName, - Owner &declaredValue, - Owner &def, - Boolean &anyCurrent) -{ - // default value - static AllowedParams - allowDefaultValue(Param::indicatedReservedName + Syntax::rFIXED, - Param::indicatedReservedName + Syntax::rREQUIRED, - Param::indicatedReservedName + Syntax::rCURRENT, - Param::indicatedReservedName + Syntax::rCONREF, - Param::indicatedReservedName + Syntax::rIMPLIED, - Param::attributeValue, - Param::attributeValueLiteral); - static AllowedParams - allowTokenDefaultValue(Param::indicatedReservedName + Syntax::rFIXED, - Param::indicatedReservedName + Syntax::rREQUIRED, - Param::indicatedReservedName + Syntax::rCURRENT, - Param::indicatedReservedName + Syntax::rCONREF, - Param::indicatedReservedName + Syntax::rIMPLIED, - Param::attributeValue, - Param::tokenizedAttributeValueLiteral); - if (!parseParam(declaredValue->tokenized() - ? allowTokenDefaultValue - : allowDefaultValue, declInputLevel, parm)) - return 0; - switch (parm.type) { - case Param::indicatedReservedName + Syntax::rFIXED: - { - static AllowedParams allowValue(Param::attributeValue, - Param::attributeValueLiteral); - static AllowedParams - allowTokenValue(Param::attributeValue, - Param::tokenizedAttributeValueLiteral); - if (!parseParam(declaredValue->tokenized() - ? allowTokenValue - : allowValue, declInputLevel, parm)) - return 0; - unsigned specLength = 0; - AttributeValue *value = declaredValue->makeValue(parm.literalText, - *this, - attributeName, - specLength); - if (declaredValue->isId()) - message(ParserMessages::idDeclaredValue); - def = new FixedAttributeDefinition(attributeName, - declaredValue.extract(), - value); - } - break; - case Param::attributeValue: - case Param::attributeValueLiteral: - case Param::tokenizedAttributeValueLiteral: - { - unsigned specLength = 0; - AttributeValue *value = declaredValue->makeValue(parm.literalText, - *this, - attributeName, - specLength); - if (declaredValue->isId()) - message(ParserMessages::idDeclaredValue); - def = new DefaultAttributeDefinition(attributeName, - declaredValue.extract(), - value); - } - break; - case Param::indicatedReservedName + Syntax::rREQUIRED: - def = new RequiredAttributeDefinition(attributeName, - declaredValue.extract()); - break; - case Param::indicatedReservedName + Syntax::rCURRENT: - anyCurrent = 1; - if (declaredValue->isId()) - message(ParserMessages::idDeclaredValue); - def = new CurrentAttributeDefinition(attributeName, - declaredValue.extract(), - defDtd().allocCurrentAttributeIndex()); - if (isNotation) - message(ParserMessages::dataAttributeDefaultValue); - else if (haveDefLpd()) - message(ParserMessages::linkAttributeDefaultValue); - break; - case Param::indicatedReservedName + Syntax::rCONREF: - if (declaredValue->isId()) - message(ParserMessages::idDeclaredValue); - def = new ConrefAttributeDefinition(attributeName, - declaredValue.extract()); - if (isNotation) - message(ParserMessages::dataAttributeDefaultValue); - else if (haveDefLpd()) - message(ParserMessages::linkAttributeDefaultValue); - break; - case Param::indicatedReservedName + Syntax::rIMPLIED: - def = new ImpliedAttributeDefinition(attributeName, - declaredValue.extract()); - break; - default: - CANNOT_HAPPEN(); - } - return 1; -} - -// parm contains either system or public - -Boolean Parser::parseExternalId(const AllowedParams &sysidAllow, - const AllowedParams &endAllow, - unsigned declInputLevel, - Param &parm, - ExternalId &id) -{ - id.setLocation(currentLocation()); - if (parm.type == Param::reservedName + Syntax::rPUBLIC) { - static AllowedParams allowMinimumLiteral(Param::minimumLiteral); - if (!parseParam(allowMinimumLiteral, declInputLevel, parm)) - return 0; - const MessageType1 *err; - if (!id.setPublic(parm.literalText, sd().docCharset(), syntax().space(), - err) - && sd().formal()) - message(*err, - StringMessageArg(*id.publicIdString())); - } - if (!parseParam(sysidAllow, declInputLevel, parm)) - return 0; - if (parm.type == Param::systemIdentifier) { - id.setSystem(parm.literalText); - if (!parseParam(endAllow, declInputLevel, parm)) - return 0; - } - return 1; -} - -Boolean Parser::parseNotationDecl() -{ - unsigned declInputLevel = inputLevel(); - Param parm; - if (!parseParam(allowName, declInputLevel, parm)) - return 0; - Notation *nt = lookupCreateNotation(parm.token); - if (nt->defined()) - message(ParserMessages::duplicateNotationDeclaration, - StringMessageArg(parm.token)); - static AllowedParams - allowPublicSystem(Param::reservedName + Syntax::rPUBLIC, - Param::reservedName + Syntax::rSYSTEM); - if (!parseParam(allowPublicSystem, declInputLevel, parm)) - return 0; - - - static AllowedParams allowSystemIdentifierMdc(Param::systemIdentifier, - Param::mdc); - - ExternalId id; - if (!parseExternalId(allowSystemIdentifierMdc, allowMdc, - declInputLevel, parm, id)) - return 0; - if (sd().formal()) { - PublicId::TextClass textClass; - const PublicId *publicId = id.publicId(); - if (publicId - && publicId->getTextClass(textClass) - && textClass != PublicId::NOTATION) - message(ParserMessages::notationIdentifierTextClass); - } - if (!nt->defined()) { - nt->setExternalId(id, markupLocation()); - nt->generateSystemId(*this); - if (currentMarkup()) - eventHandler().notationDecl(new (eventAllocator()) - NotationDeclEvent(nt, markupLocation(), - currentMarkup())); - } - return 1; -} - -Boolean Parser::parseEntityDecl() -{ - unsigned declInputLevel = inputLevel(); - Param parm; - - static AllowedParams - allowEntityNamePero(Param::entityName, - Param::indicatedReservedName + Syntax::rDEFAULT, - Param::pero); - - if (!parseParam(allowEntityNamePero, declInputLevel, parm)) - return 0; - - Entity::DeclType declType; - StringC name; // empty for default entity - if (parm.type == Param::pero) { - declType = Entity::parameterEntity; - static AllowedParams allowParamEntityName(Param::paramEntityName); - if (!parseParam(allowParamEntityName, declInputLevel, parm)) - return 0; - parm.token.swap(name); - } - else { - declType = Entity::generalEntity; - if (parm.type == Param::entityName) - parm.token.swap(name); - } - static AllowedParams - allowEntityTextType(Param::paramLiteral, - Param::reservedName + Syntax::rCDATA, - Param::reservedName + Syntax::rSDATA, - Param::reservedName + Syntax::rPI, - Param::reservedName + Syntax::rSTARTTAG, - Param::reservedName + Syntax::rENDTAG, - Param::reservedName + Syntax::rMS, - Param::reservedName + Syntax::rMD, - Param::reservedName + Syntax::rSYSTEM, - Param::reservedName + Syntax::rPUBLIC); - - if (!parseParam(allowEntityTextType, declInputLevel, parm)) - return 0; - Location typeLocation(currentLocation()); - Entity::DataType dataType = Entity::sgmlText; - InternalTextEntity::Bracketed bracketed = InternalTextEntity::none; - switch (parm.type) { - case Param::reservedName + Syntax::rSYSTEM: - case Param::reservedName + Syntax::rPUBLIC: - return parseExternalEntity(name, declType, declInputLevel, parm); - case Param::reservedName + Syntax::rCDATA: - dataType = Entity::cdata; - break; - case Param::reservedName + Syntax::rSDATA: - dataType = Entity::sdata; - break; - case Param::reservedName + Syntax::rPI: - dataType = Entity::pi; - break; - case Param::reservedName + Syntax::rSTARTTAG: - bracketed = InternalTextEntity::starttag; - break; - case Param::reservedName + Syntax::rENDTAG: - bracketed = InternalTextEntity::endtag; - break; - case Param::reservedName + Syntax::rMS: - bracketed = InternalTextEntity::ms; - break; - case Param::reservedName + Syntax::rMD: - bracketed = InternalTextEntity::md; - break; - } - if (parm.type != Param::paramLiteral) { - if (!parseParam(allowParamLiteral, declInputLevel, parm)) - return 0; - } - Text text; - parm.literalText.swap(text); - if (bracketed != InternalTextEntity::none) { - StringC open; - StringC close; - switch (bracketed) { - case InternalTextEntity::starttag: - open = syntax().delimGeneral(Syntax::dSTAGO); - close = syntax().delimGeneral(Syntax::dTAGC); - break; - case InternalTextEntity::endtag: - open = syntax().delimGeneral(Syntax::dETAGO); - close = syntax().delimGeneral(Syntax::dTAGC); - break; - case InternalTextEntity::ms: - open = syntax().delimGeneral(Syntax::dMDO); - open += syntax().delimGeneral(Syntax::dDSO); - close = syntax().delimGeneral(Syntax::dMSC); - close += syntax().delimGeneral(Syntax::dMDC); - break; - case InternalTextEntity::md: - open = syntax().delimGeneral(Syntax::dMDO); - close = syntax().delimGeneral(Syntax::dMDC); - break; - default: - CANNOT_HAPPEN(); - } - text.insertChars(open, Location(new BracketOrigin(typeLocation, - BracketOrigin::open), - 0)); - text.addChars(close, Location(new BracketOrigin(typeLocation, - BracketOrigin::close), - 0)); - if (text.size() > syntax().litlen() - && text.size() - open.size() - close.size() <= syntax().litlen()) - message(ParserMessages::bracketedLitlen, - NumberMessageArg(syntax().litlen())); - } - if (!parseParam(allowMdc, declInputLevel, parm)) - return 0; - if (declType == Entity::parameterEntity - && (dataType == Entity::cdata || dataType == Entity::sdata)) { - message(ParserMessages::internalParameterDataEntity, - StringMessageArg(name)); - return 1; - } - Ptr entity; - switch (dataType) { - case Entity::cdata: - entity = new InternalCdataEntity(name, markupLocation(), text); - break; - case Entity::sdata: - entity = new InternalSdataEntity(name, markupLocation(), text); - break; - case Entity::pi: - entity = new PiEntity(name, declType, markupLocation(), text); - break; - case Entity::sgmlText: - entity = new InternalTextEntity(name, declType, markupLocation(), text, bracketed); - break; - default: - CANNOT_HAPPEN(); - break; - } - maybeDefineEntity(entity); - return 1; -} - -Boolean Parser::parseExternalEntity(StringC &name, - Entity::DeclType declType, - unsigned declInputLevel, - Param &parm) -{ - static AllowedParams - allowSystemIdentifierEntityTypeMdc(Param::systemIdentifier, - Param::reservedName + Syntax::rSUBDOC, - Param::reservedName + Syntax::rCDATA, - Param::reservedName + Syntax::rSDATA, - Param::reservedName + Syntax::rNDATA, - Param::mdc); - static AllowedParams - allowEntityTypeMdc(Param::reservedName + Syntax::rSUBDOC, - Param::reservedName + Syntax::rCDATA, - Param::reservedName + Syntax::rSDATA, - Param::reservedName + Syntax::rNDATA, - Param::mdc); - - ExternalId id; - if (!parseExternalId(allowSystemIdentifierEntityTypeMdc, allowEntityTypeMdc, - declInputLevel, parm, id)) - return 0; - if (parm.type == Param::mdc) { - maybeDefineEntity(new ExternalTextEntity(name, declType, markupLocation(), - id)); - return 1; - } - Ptr entity; - if (parm.type == Param::reservedName + Syntax::rSUBDOC) { - if (sd().subdoc() == 0) - message(ParserMessages::subdocEntity, StringMessageArg(name)); - if (!parseParam(allowMdc, declInputLevel, parm)) - return 0; - entity = new SubdocEntity(name, markupLocation(), id); - } - else { - Entity::DataType dataType; - switch (parm.type) { - case Param::reservedName + Syntax::rCDATA: - dataType = Entity::cdata; - break; - case Param::reservedName + Syntax::rSDATA: - dataType = Entity::sdata; - break; - case Param::reservedName + Syntax::rNDATA: - dataType = Entity::ndata; - break; - default: - CANNOT_HAPPEN(); - } - if (!parseParam(allowName, declInputLevel, parm)) - return 0; - ConstPtr notation(lookupCreateNotation(parm.token)); - if (!parseParam(allowDsoMdc, declInputLevel, parm)) - return 0; - AttributeList attributes(notation->attributeDef()); - if (parm.type == Param::dso) { - if (attributes.size() == 0) - message(ParserMessages::notationNoAttributes, - StringMessageArg(notation->name())); - Boolean netEnabling; - if (!parseAttributeSpec(1, attributes, netEnabling)) - return 0; - if (attributes.nSpec() == 0) - message(ParserMessages::emptyDataAttributeSpec); - if (!parseParam(allowMdc, declInputLevel, parm)) - return 0; - } - else - attributes.finish(*this); - entity = new ExternalDataEntity(name, dataType, markupLocation(), id, notation, - attributes); - } - if (declType == Entity::parameterEntity) { - message(ParserMessages::externalParameterDataSubdocEntity, - StringMessageArg(name)); - return 1; - } - maybeDefineEntity(entity); - return 1; -} - -Notation *Parser::lookupCreateNotation(const StringC &name) -{ - Ptr nt = defDtd().lookupNotation(name); - if (nt.isNull()) { - nt = new Notation(name, defDtd().namePointer(), defDtd().isBase()); - defDtd().insertNotation(nt); - } - return nt.pointer(); -} - -void Parser::maybeDefineEntity(const Ptr &entity) -{ - Dtd &dtd = defDtd(); - if (haveDefLpd()) - entity->setDeclIn(dtd.namePointer(), - dtd.isBase(), - defLpd().namePointer(), - defLpd().active()); - else - entity->setDeclIn(dtd.namePointer(), dtd.isBase()); - Boolean ignored = 0; - if (entity->name().size() == 0) { - const Entity *oldEntity = dtd.defaultEntity().pointer(); - if (oldEntity == 0 - || (!oldEntity->declInActiveLpd() && entity->declInActiveLpd())) - dtd.setDefaultEntity(entity, *this); - else { - ignored = 1; - if (options().warnDuplicateEntity) - message(ParserMessages::duplicateEntityDeclaration, - StringMessageArg(syntax().rniReservedName(Syntax::rDEFAULT))); - } - } - else { - Ptr oldEntity = dtd.insertEntity(entity); - if (oldEntity.isNull()) - entity->generateSystemId(*this); - else if (oldEntity->defaulted()) { - dtd.insertEntity(entity, 1); - message(ParserMessages::defaultedEntityDefined, - StringMessageArg(entity->name())); - entity->generateSystemId(*this); - } - else { - if (entity->declInActiveLpd() && !oldEntity->declInActiveLpd()) { - dtd.insertEntity(entity, 1); - entity->generateSystemId(*this); - } - else { - ignored = 1; - if (options().warnDuplicateEntity) - message(entity->declType() == Entity::parameterEntity - ? ParserMessages::duplicateParameterEntityDeclaration - : ParserMessages::duplicateEntityDeclaration, - StringMessageArg(entity->name())); - } - } - } - if (currentMarkup()) - eventHandler().entityDecl(new (eventAllocator()) - EntityDeclEvent(entity, ignored, - markupLocation(), - currentMarkup())); -} - -Boolean Parser::parseShortrefDecl() -{ - if (!defDtd().isBase()) - message(ParserMessages::shortrefOnlyInBaseDtd); - - unsigned declInputLevel = inputLevel(); - Param parm; - - if (!parseParam(allowName, declInputLevel, parm)) - return 0; - ShortReferenceMap *map = lookupCreateMap(parm.token); - int valid = 1; - if (map->defined()) { - message(ParserMessages::duplicateShortrefDeclaration, - StringMessageArg(parm.token), - map->defLocation()); - valid = 0; - } - else - map->setDefLocation(markupLocation()); - if (!parseParam(allowParamLiteral, declInputLevel, parm)) - return 0; - Vector vec; - do { - StringC delim(parm.literalText.string()); - const SubstTable *table = instanceSyntax().generalSubstTable(); - for (size_t i = 0; i < delim.size(); i++) - table->subst(delim[i]); - size_t srIndex; - if (!defDtd().shortrefIndex(delim, instanceSyntax(), srIndex)) { - message(ParserMessages::unknownShortrefDelim, - StringMessageArg(prettifyDelim(delim))); - valid = 0; - } - static AllowedParams allowEntityName(Param::entityName); - if (!parseParam(allowEntityName, declInputLevel, parm)) - return 0; - if (valid) { - if (srIndex >= vec.size()) - vec.resize(srIndex + 1); - if (vec[srIndex].size() > 0) { - message(ParserMessages::delimDuplicateMap, - StringMessageArg(prettifyDelim(delim))); - valid = 0; - } - else - parm.token.swap(vec[srIndex]); - } - static AllowedParams allowParamLiteralMdc(Param::paramLiteral, Param::mdc); - if (!parseParam(allowParamLiteralMdc, declInputLevel, parm)) - return 0; - } while (parm.type != Param::mdc); - if (valid) { - map->setNameMap(vec); - if (currentMarkup()) - eventHandler().shortrefDecl(new (eventAllocator()) - ShortrefDeclEvent(map, - currentDtdPointer(), - markupLocation(), - currentMarkup())); - } - return 1; -} - -StringC Parser::prettifyDelim(const StringC &delim) -{ - StringC prettyDelim; - for (size_t i = 0; i < delim.size(); i++) { - const StringC *nameP; - if (syntax().charFunctionName(delim[i], nameP)) { - prettyDelim += syntax().delimGeneral(Syntax::dCRO); - prettyDelim += *nameP; - prettyDelim += syntax().delimGeneral(Syntax::dREFC); - } - else - prettyDelim += delim[i]; - } - return prettyDelim; -} - -ShortReferenceMap *Parser::lookupCreateMap(const StringC &name) -{ - ShortReferenceMap *map = defDtd().lookupShortReferenceMap(name); - if (!map) { - map = new ShortReferenceMap(name); - defDtd().insertShortReferenceMap(map); - } - return map; -} - -Boolean Parser::parseUsemapDecl() -{ - if (!inInstance() && !defDtd().isBase()) - message(ParserMessages::usemapOnlyInBaseDtd); - - unsigned declInputLevel = inputLevel(); - Param parm; - static AllowedParams - allowNameEmpty(Param::name, - Param::indicatedReservedName + Syntax::rEMPTY); - if (!parseParam(allowNameEmpty, declInputLevel, parm)) - return 0; - const ShortReferenceMap *map; - if (parm.type == Param::name) { - if (inInstance()) { - map = currentDtd().lookupShortReferenceMap(parm.token); - if (!map) - message(ParserMessages::undefinedShortrefMapInstance, - StringMessageArg(parm.token)); - } - else { - ShortReferenceMap *tem = lookupCreateMap(parm.token); - tem->setUsed(); - map = tem; - } - } - else - map = &theEmptyMap; - static AllowedParams - allowNameNameGroupMdc(Param::name, Param::nameGroup, Param::mdc); - if (!parseParam(allowNameNameGroupMdc, declInputLevel, parm)) - return 0; - if (parm.type != Param::mdc) { - if (inInstance()) { - message(ParserMessages::usemapAssociatedElementTypeInstance); - if (!parseParam(allowMdc, declInputLevel, parm)) - return 0; - } - else { - Vector v; - if (parm.type == Param::name) { - ElementType *e = lookupCreateElement(parm.token); - v.push_back(e); - if (!e->map()) - e->setMap(map); - } - else { - v.resize(parm.nameTokenVector.size()); - for (size_t i = 0; i < parm.nameTokenVector.size(); i++) { - ElementType *e - = lookupCreateElement(parm.nameTokenVector[i].name); - v[i] = e; - if (!e->map()) - e->setMap(map); - } - } - if (!parseParam(allowMdc, declInputLevel, parm)) - return 0; - if (currentMarkup()) - eventHandler().usemap(new (eventAllocator()) - UsemapEvent(map, v, - currentDtdPointer(), - markupLocation(), - currentMarkup())); - } - } - else { - if (!inInstance()) - message(ParserMessages::usemapAssociatedElementTypeDtd); - else if (map) { - if (map != &theEmptyMap && !map->defined()) - message(ParserMessages::undefinedShortrefMapInstance, - StringMessageArg(map->name())); - else { - if (currentMarkup()) { - Vector v; - eventHandler().usemap(new (eventAllocator()) - UsemapEvent(map, v, - currentDtdPointer(), - markupLocation(), - currentMarkup())); - } - currentElement().setMap(map); - } - } - } - return 1; -} - -Boolean Parser::parseDoctypeDeclStart() -{ - if (hadDtd() && !sd().concur() && !sd().explicitLink()) - message(ParserMessages::multipleDtds); - if (hadLpd()) - message(ParserMessages::dtdAfterLpd); - unsigned declInputLevel = inputLevel(); - Param parm; - - if (!parseParam(allowName, declInputLevel, parm)) - return 0; - StringC name; - parm.token.swap(name); - if (!lookupDtd(name).isNull()) - message(ParserMessages::duplicateDtd, StringMessageArg(name)); - static AllowedParams - allowPublicSystemDsoMdc(Param::reservedName + Syntax::rPUBLIC, - Param::reservedName + Syntax::rSYSTEM, - Param::dso, - Param::mdc); - if (!parseParam(allowPublicSystemDsoMdc, declInputLevel, parm)) - return 0; - ConstPtr entity; - if (parm.type == Param::reservedName + Syntax::rPUBLIC - || parm.type == Param::reservedName + Syntax::rSYSTEM) { - static AllowedParams allowSystemIdentifierDsoMdc(Param::systemIdentifier, - Param::dso, Param::mdc); - ExternalId id; - if (!parseExternalId(allowSystemIdentifierDsoMdc, allowDsoMdc, - declInputLevel, parm, id)) - return 0; - Ptr tem - = new ExternalTextEntity(name, Entity::doctype, markupLocation(), id); - tem->generateSystemId(*this); - entity = tem; -#if 0 - eventHandler() - .externalEntityDecl(new (eventAllocator()) - ExternalEntityDeclEvent(entity, 0)); -#endif - } - else if (parm.type == Param::mdc) { - message(ParserMessages::noDtdSubset, StringMessageArg(name)); - return 1; - } - // Discard mdc or dso - if (currentMarkup()) - currentMarkup()->resize(currentMarkup()->size() - 1); - eventHandler().startDtd(new (eventAllocator()) - StartDtdEvent(name, entity, parm.type == Param::dso, - markupLocation(), - currentMarkup())); - startDtd(name); - if (parm.type == Param::mdc) { - // unget the mdc - currentInput()->ungetToken(); - // reference the entity - Ptr origin - = new (internalAllocator()) EntityOrigin(entity, currentLocation()); - entity->dsReference(*this, origin); - if (inputLevel() == 1) { // reference failed - (void)parseDoctypeDeclEnd(); - return 1; - } - } - else if (!entity.isNull()) - setDsEntity(entity); - setPhase(declSubsetPhase); - return 1; -} - -Boolean Parser::implyDtd(const StringC &gi) -{ - ExternalId id; - // The null location indicates that this is a fake entity. - ConstPtr entity(new ExternalTextEntity(gi, - Entity::doctype, - Location(), - id)); - // Don't use Entity::generateSystemId because we don't want an error - // if it fails. - StringC str; - StringC name; - if (!entityCatalog().lookup(*entity, syntax(), sd().docCharset(), - messenger(), str)) { - if (!entityCatalog().defaultDoctype(sd().docCharset(), - messenger(), - name, - str)) - return 0; - for (size_t i = 0; i < name.size(); i++) - syntax().generalSubstTable()->subst(name[i]); - } - else - name = gi; - id.setEffectiveSystem(str); - entity = new ExternalTextEntity(name, - Entity::doctype, - Location(), - id); - StringC declStr; - declStr += syntax().delimGeneral(Syntax::dMDO); - declStr += syntax().reservedName(Syntax::rDOCTYPE); - declStr += syntax().space(); - declStr += name; - declStr += syntax().space(); - declStr += syntax().reservedName(Syntax::rSYSTEM); - declStr += syntax().delimGeneral(Syntax::dMDC); - message(ParserMessages::implyingDtd, StringMessageArg(declStr)); - Ptr origin - = new (internalAllocator()) EntityOrigin(entity, currentLocation()); - startMarkup(eventsWanted().wantPrologMarkup(), Location()); - if (currentMarkup()) { - currentMarkup()->addDelim(Syntax::dMDO); - currentMarkup()->addReservedName(Syntax::rDOCTYPE, - syntax().reservedName(Syntax::rDOCTYPE)); - currentMarkup()->addS(syntax().space()); - currentMarkup()->addName(name.data(), name.size()); - currentMarkup()->addS(syntax().space()); - currentMarkup()->addReservedName(Syntax::rSYSTEM, - syntax().reservedName(Syntax::rSYSTEM)); - } - eventHandler().startDtd(new (eventAllocator()) - StartDtdEvent(name, entity, 0, - markupLocation(), - currentMarkup())); - startDtd(name); - entity->dsReference(*this, origin); - if (inputLevel() == 1) { - parseDoctypeDeclEnd(1); - return 1; - } - setPhase(declSubsetPhase); - return 1; -} - -Boolean Parser::parseDoctypeDeclEnd(Boolean fake) -{ - checkDtd(defDtd()); - Ptr tem(defDtdPointer()); - endDtd(); - if (fake) { - startMarkup(eventsWanted().wantPrologMarkup(), Location()); - if (currentMarkup()) - currentMarkup()->addDelim(Syntax::dMDC); - } - else { - startMarkup(eventsWanted().wantPrologMarkup(), currentLocation()); - Param parm; - // End DTD before parsing final param so parameter entity reference - // not allowed between ] and >. - if (!parseParam(allowMdc, inputLevel(), parm)) - return 0; - } - eventHandler().endDtd(new (eventAllocator()) EndDtdEvent(tem, - markupLocation(), - currentMarkup())); - if (fake) { - Char c = syntax().standardFunction(Syntax::fRE); - eventHandler().sSep(new (eventAllocator()) - SSepEvent(&c, 1, Location(), 1)); - } - return 1; -} - -void Parser::checkDtd(Dtd &dtd) -{ - if (dtd.isBase()) - addNeededShortrefs(dtd, instanceSyntax()); - if (!options().errorAfdr) - addCommonAttributes(dtd); - Dtd::ElementTypeIter elementIter(dtd.elementTypeIter()); - ElementType *p; - ConstPtr def; - int i = 0; - while ((p = elementIter.next()) != 0) { - if (p->definition() == 0) { - if (p->name() == dtd.name()) - message(ParserMessages::documentElementUndefined); - else if (options().warnUndefinedElement) - message(ParserMessages::dtdUndefinedElement, StringMessageArg(p->name())); - if (def.isNull()) - def = new ElementDefinition(currentLocation(), - ElementDefinition::undefinedIndex, - (ElementDefinition::omitStart - |ElementDefinition::omitEnd), - ElementDefinition::any); - p->setElementDefinition(def, i++); - } - const ShortReferenceMap *map = p->map(); - if (map != 0 && map != &theEmptyMap && !map->defined()) { - message(ParserMessages::undefinedShortrefMapDtd, - StringMessageArg(map->name()), - StringMessageArg(p->name())); - p->setMap(0); - } - } - Dtd::ConstEntityIter entityIter(((const Dtd &)dtd).generalEntityIter()); - for (;;) { - ConstPtr entity(entityIter.next()); - if (entity.isNull()) - break; - const ExternalDataEntity *external = entity->asExternalDataEntity(); - if (external) { - const Notation *notation = external->notation(); - if (!notation->defined()) { - setNextLocation(external->defLocation()); - message(ParserMessages::entityNotationUndefined, - StringMessageArg(notation->name()), - StringMessageArg(external->name())); - } - } - } - Dtd::NotationIter notationIter(dtd.notationIter()); - for (;;) { - ConstPtr notation(notationIter.next()); - if (notation.isNull()) - break; - if (!notation->defined() && !notation->attributeDef().isNull()) - message(ParserMessages::attlistNotationUndefined, - StringMessageArg(notation->name())); - } - Dtd::ShortReferenceMapIter mapIter(dtd.shortReferenceMapIter()); - int nShortref = dtd.nShortref(); - for (;;) { - ShortReferenceMap *map = mapIter.next(); - if (!map) - break; - Vector > entityMap(nShortref); - for (i = 0; i < nShortref; i++) { - const StringC *entityName = map->entityName(i); - if (entityName) { - ConstPtr entity - = lookupEntity(0, *entityName, map->defLocation(), 0); - if (entity.isNull()) { - setNextLocation(map->defLocation()); - message(ParserMessages::mapEntityUndefined, - StringMessageArg(*entityName), - StringMessageArg(map->name())); - } - else { - if (entity->defaulted() && options().warnDefaultEntityReference) { - setNextLocation(map->defLocation()); - message(ParserMessages::mapDefaultEntity, - StringMessageArg(*entityName), - StringMessageArg(map->name())); - } - entityMap[i] = entity; - } - } - } - map->setEntityMap(entityMap); - if (options().warnUnusedMap && !map->used()) { - setNextLocation(map->defLocation()); - message(ParserMessages::unusedMap, StringMessageArg(map->name())); - } - } - if (options().warnUnusedParam) { - Dtd::ConstEntityIter entityIter(((const Dtd &)dtd).parameterEntityIter()); - for (;;) { - ConstPtr entity(entityIter.next()); - if (entity.isNull()) - break; - if (!entity->used() && !maybeStatusKeyword(*entity)) { - setNextLocation(entity->defLocation()); - message(ParserMessages::unusedParamEntity, - StringMessageArg(entity->name())); - } - } - } -} - -void Parser::addCommonAttributes(Dtd &dtd) -{ - Ptr commonAdl[2]; - { - ElementType *e = dtd.removeElementType(syntax() - .rniReservedName(Syntax::rANY)); - if (e) { - commonAdl[0] = e->attributeDef(); - delete e; - } - } - { - Ptr allNotation - = dtd.removeNotation(syntax().rniReservedName(Syntax::rANY)); - if (!allNotation.isNull()) - commonAdl[1] = allNotation->attributeDef(); - } - Dtd::ElementTypeIter elementIter(dtd.elementTypeIter()); - Dtd::NotationIter notationIter(dtd.notationIter()); - Vector doneAdl(dtd.nAttributeDefinitionList(), - PackedBoolean(0)); - for (int isNotation = 0; isNotation < 2; isNotation++) { - if (!commonAdl[isNotation].isNull()) { - doneAdl[commonAdl[isNotation]->index()] = 1; - for (;;) { - Attributed *a; - if (!isNotation) - a = elementIter.next(); - else - a = notationIter.next().pointer(); - if (!a) - break; - Ptr adl = a->attributeDef(); - if (adl.isNull()) - a->setAttributeDef(commonAdl[isNotation]); - else if (!doneAdl[adl->index()]) { - doneAdl[adl->index()] = 1; - for (size_t j = 0; j < commonAdl[isNotation]->size(); j++) { - unsigned tem; - if (!adl->attributeIndex(commonAdl[isNotation]->def(j)->name(), - tem)) - adl->append(commonAdl[isNotation]->def(j)->copy()); - } - } - } - } - } -} - -Boolean Parser::maybeStatusKeyword(const Entity &entity) -{ - const InternalEntity *internal = entity.asInternalEntity(); - if (!internal) - return 0; - const StringC &text = internal->string(); - static const Syntax::ReservedName statusKeywords[] = { - Syntax::rINCLUDE, Syntax::rIGNORE - }; - for (size_t i = 0; i < SIZEOF(statusKeywords); i++) { - const StringC &keyword = instanceSyntax().reservedName(statusKeywords[i]); - size_t j = 0; - while (j < text.size() && instanceSyntax().isS(text[j])) - j++; - size_t k = 0; - while (j < text.size() - && k < keyword.size() - && ((*instanceSyntax().generalSubstTable())[text[j]] - == keyword[k])) - j++, k++; - if (k == keyword.size()) { - while (j < text.size() && instanceSyntax().isS(text[j])) - j++; - if (j == text.size()) - return 1; - } - } - return 0; -} - -Boolean Parser::parseLinktypeDeclStart() -{ - if (baseDtd().isNull()) - message(ParserMessages::lpdBeforeBaseDtd); - unsigned declInputLevel = inputLevel(); - Param parm; - - if (!parseParam(allowName, declInputLevel, parm)) - return 0; - StringC name; - parm.token.swap(name); - if (!lookupDtd(name).isNull()) - message(ParserMessages::duplicateDtdLpd, StringMessageArg(name)); - else if (!lookupLpd(name).isNull()) - message(ParserMessages::duplicateLpd, StringMessageArg(name)); - static AllowedParams - allowSimpleName(Param::indicatedReservedName + Syntax::rSIMPLE, - Param::name); - if (!parseParam(allowSimpleName, declInputLevel, parm)) - return 0; - Boolean simple; - Ptr sourceDtd; - if (parm.type == Param::indicatedReservedName + Syntax::rSIMPLE) { - simple = 1; - sourceDtd = baseDtd(); - if (sourceDtd.isNull()) - sourceDtd = new Dtd(StringC(), 1); - } - else { - simple = 0; - sourceDtd = lookupDtd(parm.token); - if (sourceDtd.isNull()) { - message(ParserMessages::noSuchDtd, StringMessageArg(parm.token)); - sourceDtd = new Dtd(parm.token, 0); - } - } - static AllowedParams - allowImpliedName(Param::indicatedReservedName + Syntax::rIMPLIED, - Param::name); - if (!parseParam(allowImpliedName, declInputLevel, parm)) - return 0; - Ptr resultDtd; - Boolean implied = 0; - if (parm.type == Param::indicatedReservedName + Syntax::rIMPLIED) { - if (simple) { - if (!sd().simpleLink()) - message(ParserMessages::simpleLinkFeature); - } - else { - implied = 1; - if (!sd().implicitLink()) - message(ParserMessages::implicitLinkFeature); - } - } - else { - if (simple) - message(ParserMessages::simpleLinkResultNotImplied); - else { - if (!sd().explicitLink()) - message(ParserMessages::explicitLinkFeature); - resultDtd = lookupDtd(parm.token); - if (resultDtd.isNull()) - message(ParserMessages::noSuchDtd, StringMessageArg(parm.token)); - } - } - static AllowedParams - allowPublicSystemDsoMdc(Param::reservedName + Syntax::rPUBLIC, - Param::reservedName + Syntax::rSYSTEM, - Param::dso, - Param::mdc); - if (!parseParam(allowPublicSystemDsoMdc, declInputLevel, parm)) - return 0; - ConstPtr entity; - if (parm.type == Param::reservedName + Syntax::rPUBLIC - || parm.type == Param::reservedName + Syntax::rSYSTEM) { - static AllowedParams allowSystemIdentifierDsoMdc(Param::systemIdentifier, - Param::dso, Param::mdc); - ExternalId id; - if (!parseExternalId(allowSystemIdentifierDsoMdc, allowDsoMdc, - declInputLevel, parm, id)) - return 0; - Ptr tem - = new ExternalTextEntity(name, Entity::linktype, markupLocation(), id); - tem->generateSystemId(*this); - entity = tem; -#if 0 - eventHandler() - .externalEntityDecl(new (eventAllocator()) - ExternalEntityDeclEvent(entity, 0)); -#endif - } - Ptr lpd; - if (simple) - lpd = new SimpleLpd(name, markupLocation(), sourceDtd); - else - lpd = new ComplexLpd(name, - implied ? Lpd::implicitLink : Lpd::explicitLink, - markupLocation(), - syntax(), - sourceDtd, - resultDtd); - if (!baseDtd().isNull() && shouldActivateLink(name)) { - size_t nActive = nActiveLink(); - if (simple) { - size_t nSimple = 0; - for (size_t i = 0; i < nActive; i++) - if (activeLpd(i).type() == Lpd::simpleLink) - nSimple++; - if (nSimple == sd().simpleLink()) - message(ParserMessages::simpleLinkCount, - NumberMessageArg(sd().simpleLink())); - lpd->activate(); - } - else { - Boolean haveImplicit = 0; - Boolean haveExplicit = 0; - size_t i; - for (i = 0; i < nActive; i++) { - if (activeLpd(i).type() == Lpd::implicitLink) - haveImplicit = 1; - else if (activeLpd(i).type() == Lpd::explicitLink) - haveExplicit = 1; - } - const Dtd *sourceDtd = lpd->sourceDtd().pointer(); - if (implied && haveImplicit) - message(ParserMessages::oneImplicitLink); - else if (sd().explicitLink() <= 1 && sourceDtd != baseDtd().pointer()) - message(sd().explicitLink() == 0 - ? ParserMessages::explicitNoRequiresSourceTypeBase - : ParserMessages::explicit1RequiresSourceTypeBase, - StringMessageArg(lpd->name())); - else if (sd().explicitLink() == 1 && haveExplicit && !implied) - message(ParserMessages::duplicateExplicitChain); - else if (haveExplicit || haveImplicit - || sourceDtd != baseDtd().pointer()) - message(ParserMessages::sorryLink, StringMessageArg(lpd->name())); - else - lpd->activate(); - } - } - // Discard mdc or dso - if (currentMarkup()) - currentMarkup()->resize(currentMarkup()->size() - 1); - eventHandler().startLpd(new (eventAllocator()) - StartLpdEvent(lpd->active(), - name, - entity, - parm.type == Param::dso, - markupLocation(), - currentMarkup())); - startLpd(lpd); - if (parm.type == Param::mdc) { - // unget the mdc - currentInput()->ungetToken(); - if (entity.isNull()) { - message(ParserMessages::noLpdSubset, StringMessageArg(name)); - (void)parseLinktypeDeclEnd(); - return 1; - } - // reference the entity - Ptr origin - = new (internalAllocator()) EntityOrigin(entity, currentLocation()); - entity->dsReference(*this, origin); - if (inputLevel() == 1) { // reference failed - (void)parseLinktypeDeclEnd(); - return 1; - } - } - else if (!entity.isNull()) - setDsEntity(entity); - setPhase(declSubsetPhase); - return 1; -} - -Boolean Parser::parseLinktypeDeclEnd() -{ - - if (defLpd().type() != Lpd::simpleLink) { - if (!defComplexLpd().initialLinkSet()->defined()) - message(ParserMessages::noInitialLinkSet, - StringMessageArg(defLpd().name())); - ComplexLpd::ConstLinkSetIter iter = defComplexLpd().linkSetIter(); - const LinkSet *linkSet; - while ((linkSet = iter.next()) != 0) - if (!linkSet->defined()) - message(ParserMessages::undefinedLinkSet, StringMessageArg(linkSet->name())); - } - ConstPtr tem(defLpdPointer()); - endLpd(); - startMarkup(eventsWanted().wantPrologMarkup(), currentLocation()); - Param parm; - Boolean result = parseParam(allowMdc, inputLevel(), parm); - eventHandler().endLpd(new (eventAllocator()) EndLpdEvent(tem, - markupLocation(), - currentMarkup())); - return result; -} - -Boolean Parser::parseLinkDecl() -{ - return parseLinkSet(0); -} - -Boolean Parser::parseIdlinkDecl() -{ - return parseLinkSet(1); -} - -// This will only get called if we're defining a complex lpd. - -Boolean Parser::parseLinkSet(Boolean idlink) -{ - if (defLpd().type() == Lpd::simpleLink) { - message(idlink ? ParserMessages::idlinkDeclSimple : ParserMessages::linkDeclSimple); - return 0; - } - if (idlink) { - if (defComplexLpd().hadIdLinkSet()) - message(ParserMessages::duplicateIdLinkSet); - else - defComplexLpd().setHadIdLinkSet(); - } - unsigned declInputLevel = inputLevel(); - Param parm; - - Boolean isExplicit = (defLpd().type() == Lpd::explicitLink); - LinkSet *linkSet; - if (idlink) { - if (!parseParam(allowName, declInputLevel, parm)) - return 0; - linkSet = 0; - } - else { - static AllowedParams - allowNameInitial(Param::name, - Param::indicatedReservedName + Syntax::rINITIAL); - if (!parseParam(allowNameInitial, declInputLevel, parm)) - return 0; - if (parm.type == Param::name) - linkSet = lookupCreateLinkSet(parm.token); - else - linkSet = defComplexLpd().initialLinkSet(); - if (linkSet->defined()) - message(ParserMessages::duplicateLinkSet, StringMessageArg(linkSet->name())); - static AllowedParams - allowExplicitLinkRule(Param::name, - Param::nameGroup, - Param::indicatedReservedName + Syntax::rIMPLIED); - if (!parseParam(isExplicit ? allowExplicitLinkRule : allowNameNameGroup, - declInputLevel, parm)) - return 0; - } - - do { - StringC id; - if (idlink) { - parm.token.swap(id); - if (!parseParam(isExplicit ? allowExplicitLinkRuleMdc : allowNameNameGroupMdc, - declInputLevel, parm)) - return 0; - } - if (parm.type == Param::indicatedReservedName + Syntax::rIMPLIED) { - if (!parseParam(allowName, declInputLevel, parm)) - return 0; - Boolean resultImplied; - const ElementType *resultType; - AttributeList resultAttributes; - if (!parseResultElementSpec(declInputLevel, - parm, - idlink, - resultImplied, - resultType, - resultAttributes)) - return 0; - if (resultType) { - const AttributeList *dummy; - if (linkSet->impliedResultAttributes(resultType, dummy)) - message(ParserMessages::duplicateImpliedResult, - StringMessageArg(resultType->name())); - else - linkSet->addImplied(resultType, resultAttributes); - } - } - else { - SourceLinkRule *linkRule = 0; - IdLinkRule idLinkRule; - Ptr linkRuleResource; - if (idlink) - linkRule = &idLinkRule; - else { - linkRuleResource = new SourceLinkRuleResource; - linkRule = linkRuleResource.pointer(); - } - Vector assocElementTypes; - if (parm.type == Param::name) { - assocElementTypes.resize(1); - assocElementTypes[0] = lookupCreateElement(parm.token); - } - else { - assocElementTypes.resize(parm.nameTokenVector.size()); - for (size_t i = 0; i < assocElementTypes.size(); i++) - assocElementTypes[i] - = lookupCreateElement(parm.nameTokenVector[i].name); - } - static AllowedParams - allow2i(Param::indicatedReservedName + Syntax::rUSELINK, - Param::indicatedReservedName + Syntax::rPOSTLINK, - Param::dso, - Param::mdc, - Param::name, - Param::nameGroup); - static AllowedParams - allow2id(Param::indicatedReservedName + Syntax::rUSELINK, - Param::indicatedReservedName + Syntax::rPOSTLINK, - Param::dso, - Param::mdc, - Param::name); - static AllowedParams - allow2e(Param::indicatedReservedName + Syntax::rUSELINK, - Param::indicatedReservedName + Syntax::rPOSTLINK, - Param::dso, - Param::name, - Param::indicatedReservedName + Syntax::rIMPLIED); - - if (!parseParam(isExplicit - ? allow2e - : (idlink ? allow2id : allow2i), declInputLevel, parm)) - return 0; - if (parm.type == Param::indicatedReservedName + Syntax::rUSELINK) { - static AllowedParams - allowLinkSetEmpty(Param::name, - Param::indicatedReservedName + Syntax::rINITIAL, - Param::indicatedReservedName + Syntax::rEMPTY); - if (!parseParam(allowLinkSetEmpty, declInputLevel, parm)) - return 0; - const LinkSet *uselink; - if (parm.type == Param::name) - uselink = lookupCreateLinkSet(parm.token); - else if (parm.type == Param::indicatedReservedName + Syntax::rINITIAL) - uselink = defComplexLpd().initialLinkSet(); - else - uselink = defComplexLpd().emptyLinkSet(); - linkRule->setUselink(uselink); - static AllowedParams - allow3i(Param::indicatedReservedName + Syntax::rPOSTLINK, - Param::dso, - Param::mdc, - Param::name, - Param::nameGroup); - static AllowedParams - allow3id(Param::indicatedReservedName + Syntax::rPOSTLINK, - Param::dso, - Param::mdc, - Param::name); - static AllowedParams - allow3e(Param::indicatedReservedName + Syntax::rPOSTLINK, - Param::dso, - Param::name, - Param::indicatedReservedName + Syntax::rIMPLIED); - - if (!parseParam(isExplicit - ? allow3e - : (idlink ? allow3id : allow3i), - declInputLevel, parm)) - return 0; - } - if (parm.type == Param::indicatedReservedName + Syntax::rPOSTLINK) { - if (!parseParam(allowLinkSetSpec, declInputLevel, parm)) - return 0; - const LinkSet *postlink; - if (parm.type == Param::indicatedReservedName + Syntax::rRESTORE) - linkRule->setPostlinkRestore(); - else { - if (parm.type == Param::name) - postlink = lookupCreateLinkSet(parm.token); - else if (parm.type - == Param::indicatedReservedName + Syntax::rINITIAL) - postlink = defComplexLpd().initialLinkSet(); - else - postlink = defComplexLpd().emptyLinkSet(); - linkRule->setPostlink(postlink); - } - static AllowedParams - allow4i(Param::dso, - Param::mdc, - Param::name, - Param::nameGroup); - static AllowedParams - allow4id(Param::dso, - Param::mdc, - Param::name); - static AllowedParams - allow4e(Param::dso, - Param::name, - Param::indicatedReservedName + Syntax::rIMPLIED); - if (!parseParam(isExplicit - ? allow4e - : (idlink ? allow4id : allow4i), - declInputLevel, parm)) - return 0; - } - AttributeList attributes; - ConstPtr attDef; - for (size_t i = 0; i < assocElementTypes.size(); i++) { - const ElementType *e = assocElementTypes[i]; - if (e) { - if (i == 0) - attDef = defComplexLpd().attributeDef(e); - else if (attDef != defComplexLpd().attributeDef(e)) - message(ParserMessages::assocElementDifferentAtts); - // FIXME recover from this - } - } - attributes.init(attDef); - - if (parm.type == Param::dso) { - Boolean netEnabling; - if (!parseAttributeSpec(1, attributes, netEnabling)) - return 0; - static AllowedParams - allow5e(Param::name, - Param::indicatedReservedName + Syntax::rIMPLIED); - if (!parseParam(isExplicit - ? allow5e - : (idlink ? allowNameMdc : allowNameNameGroupMdc), - declInputLevel, parm)) - return 0; - } - else - attributes.finish(*this); - linkRule->setLinkAttributes(attributes); - if (isExplicit) { - Boolean resultImplied; - const ElementType *resultType; - AttributeList resultAttributes; - if (!parseResultElementSpec(declInputLevel, - parm, - idlink, - resultImplied, - resultType, - resultAttributes)) - return 0; - if (!resultImplied) - linkRule->setResult(resultType, resultAttributes); - } - // Install the link rule. - if (idlink) { - idLinkRule.setAssocElementTypes(assocElementTypes); - addIdLinkRule(id, idLinkRule); - } - else { - if (!linkSet->defined()) { - for (size_t i = 0; i < assocElementTypes.size(); i++) - if (assocElementTypes[i]) - addLinkRule(linkSet, assocElementTypes[i], linkRuleResource); - } - } - } - } while (parm.type != Param::mdc); - if (linkSet) - linkSet->setDefined(); - if (currentMarkup()) { - if (idlink) - eventHandler().idLinkDecl(new (eventAllocator()) - IdLinkDeclEvent(defComplexLpdPointer(), - markupLocation(), - currentMarkup())); - else - eventHandler().linkDecl(new (eventAllocator()) - LinkDeclEvent(linkSet, - defComplexLpdPointer(), - markupLocation(), - currentMarkup())); - } - return 1; -} - -void Parser::addIdLinkRule(const StringC &id, - IdLinkRule &rule) -{ - IdLinkRuleGroup *group = defComplexLpd().lookupCreateIdLink(id); - size_t nRules = group->nLinkRules(); - if ((nRules == 1 && group->linkRule(0).attributes().nSpec() == 0) - || nRules >= 1 && rule.attributes().nSpec() == 0) - message(ParserMessages::multipleIdLinkRuleAttribute, - StringMessageArg(id)); - group->addLinkRule(rule); -} - -void Parser::addLinkRule(LinkSet *linkSet, - const ElementType *sourceElement, - const ConstPtr &linkRule) -{ - size_t nRules = linkSet->nLinkRules(sourceElement); - if ((nRules == 1 - && linkSet->linkRule(sourceElement, 0).attributes().nSpec() == 0) - || nRules >= 1 && linkRule->attributes().nSpec() == 0) - message(ParserMessages::multipleLinkRuleAttribute, - StringMessageArg(sourceElement->name())); - linkSet->addLinkRule(sourceElement, linkRule); -} - -class ResultAttributeSpecModeSetter { -public: - ResultAttributeSpecModeSetter(ParserState *state) : state_(state) { - state_->setResultAttributeSpecMode(); - } - ~ResultAttributeSpecModeSetter() { clear(); } - void clear() { - if (state_) { - state_->clearResultAttributeSpecMode(); - state_ = 0; - } - } -private: - ParserState *state_; -}; - -Boolean Parser::parseResultElementSpec(unsigned declInputLevel, - Param &parm, - Boolean idlink, - Boolean &implied, - const ElementType *&resultType, - AttributeList &attributes) -{ - if (parm.type == Param::indicatedReservedName + Syntax::rIMPLIED) { - if (!parseParam(idlink ? allowNameMdc : allowExplicitLinkRuleMdc, - declInputLevel, parm)) - return 0; - implied = 1; - } - else { - implied = 0; - resultType = lookupResultElementType(parm.token); - static AllowedParams - allow(Param::dso, - Param::mdc, - Param::name, - Param::nameGroup, - Param::indicatedReservedName + Syntax::rIMPLIED); - static AllowedParams - allowNameDsoMdc(Param::dso, - Param::mdc, - Param::name); - if (!parseParam(idlink ? allowNameDsoMdc : allow, - declInputLevel, parm)) - return 0; - ConstPtr attDef; - if (resultType) - attDef = resultType->attributeDef(); - attributes.init(attDef); - if (parm.type == Param::dso) { - ResultAttributeSpecModeSetter modeSetter(this); - Boolean netEnabling; - if (!parseAttributeSpec(1, attributes, netEnabling)) - return 0; - modeSetter.clear(); - if (attributes.nSpec() == 0) - message(ParserMessages::emptyResultAttributeSpec); - if (!parseParam(idlink ? allowNameMdc : allowExplicitLinkRuleMdc, - declInputLevel, parm)) - return 0; - } - else { - // For entity and notation attributes. - ResultAttributeSpecModeSetter modeSetter(this); - attributes.finish(*this); - modeSetter.clear(); - } - } - return 1; -} - -const ElementType *Parser::lookupResultElementType(const StringC &name) -{ - const Dtd *dtd = defComplexLpd().resultDtd().pointer(); - if (!dtd) - return 0; - const ElementType *e = dtd->lookupElementType(name); - if (!e) - message(ParserMessages::noSuchResultElement, StringMessageArg(name)); - return e; -} - -Boolean Parser::parseUselinkDecl() -{ - unsigned declInputLevel = inputLevel(); - Param parm; - if (!parseParam(allowLinkSetSpec, declInputLevel, parm)) - return 0; - Param parm2; - if (!parseParam(allowName, declInputLevel, parm2)) - return 0; - StringC linkType; - parm2.token.swap(linkType); - if (!parseParam(allowMdc, declInputLevel, parm2)) - return 0; - ConstPtr lpd = lookupLpd(linkType); - if (lpd.isNull()) - message(ParserMessages::uselinkBadLinkType, StringMessageArg(linkType)); - else if (lpd->type() == Lpd::simpleLink) - message(ParserMessages::uselinkSimpleLpd, StringMessageArg(linkType)); - else { - const ComplexLpd *complexLpd = (const ComplexLpd *)lpd.pointer(); - const LinkSet *linkSet; - Boolean restore = 0; - if (parm.type == Param::name) { - linkSet = complexLpd->lookupLinkSet(parm.token); - if (!linkSet) { - message(ParserMessages::uselinkBadLinkSet, - StringMessageArg(complexLpd->name()), - StringMessageArg(parm.token)); - return 1; - } - } - else if (parm.type == Param::indicatedReservedName + Syntax::rINITIAL) - linkSet = complexLpd->initialLinkSet(); - else if (parm.type == Param::indicatedReservedName + Syntax::rEMPTY) - linkSet = complexLpd->emptyLinkSet(); - else { - linkSet = 0; - restore = 1; - } - if (lpd->active()) - eventHandler().uselink(new (eventAllocator()) - UselinkEvent(lpd, linkSet, - restore, markupLocation(), - currentMarkup())); - else - eventHandler().ignoredMarkup(new (eventAllocator()) - IgnoredMarkupEvent(markupLocation(), - currentMarkup())); - } - return 1; -} - -LinkSet *Parser::lookupCreateLinkSet(const StringC &name) -{ - LinkSet *linkSet = defComplexLpd().lookupLinkSet(name); - if (!linkSet) { - linkSet = new LinkSet(name, defComplexLpd().sourceDtd().pointer()); - defComplexLpd().insertLinkSet(linkSet); - } - return linkSet; -} - -Boolean Parser::parseMarkedSectionDeclStart() -{ - if (markedSectionLevel() == syntax().taglvl()) - message(ParserMessages::markedSectionLevel, - NumberMessageArg(syntax().taglvl())); - if (markedSectionSpecialLevel() > 0) { - startMarkedSection(markupLocation()); - if (inInstance() - ? eventsWanted().wantMarkedSections() - : eventsWanted().wantPrologMarkup()) - eventHandler().ignoredChars(new (eventAllocator()) - IgnoredCharsEvent(currentInput()->currentTokenStart(), - currentInput()->currentTokenLength(), - currentLocation(), - 0)); - - return 1; - } - if (startMarkup(inInstance() - ? eventsWanted().wantMarkedSections() - : eventsWanted().wantPrologMarkup(), - currentLocation())) { - currentMarkup()->addDelim(Syntax::dMDO); - currentMarkup()->addDelim(Syntax::dDSO); - } - unsigned declInputLevel = inputLevel(); - static AllowedParams allowStatusDso(Param::dso, - Param::reservedName + Syntax::rCDATA, - Param::reservedName + Syntax::rRCDATA, - Param::reservedName + Syntax::rIGNORE, - Param::reservedName + Syntax::rINCLUDE, - Param::reservedName + Syntax::rTEMP); - Param parm; - MarkedSectionEvent::Status status = MarkedSectionEvent::include; - for (;;) { - if (!parseParam(allowStatusDso, declInputLevel, parm)) - return 0; - if (parm.type == Param::dso) - break; - switch (parm.type) { - case Param::reservedName + Syntax::rCDATA: - if (status < MarkedSectionEvent::cdata) - status = MarkedSectionEvent::cdata; - break; - case Param::reservedName + Syntax::rRCDATA: - if (status < MarkedSectionEvent::rcdata) - status = MarkedSectionEvent::rcdata; - break; - case Param::reservedName + Syntax::rIGNORE: - if (status < MarkedSectionEvent::ignore) - status = MarkedSectionEvent::ignore; - break; - } - } - // FIXME this disallows - // - // ... - // - // which I think is legal. - - if (inputLevel() > declInputLevel) - message(ParserMessages::parameterEntityNotEnded); - switch (status) { - case MarkedSectionEvent::include: - startMarkedSection(markupLocation()); - break; - case MarkedSectionEvent::cdata: - startSpecialMarkedSection(cmsMode, markupLocation()); - break; - case MarkedSectionEvent::rcdata: - startSpecialMarkedSection(rcmsMode, markupLocation()); - break; - case MarkedSectionEvent::ignore: - startSpecialMarkedSection(imsMode, markupLocation()); - break; - } - if (currentMarkup()) - eventHandler().markedSectionStart(new (eventAllocator()) - MarkedSectionStartEvent(status, - markupLocation(), - currentMarkup())); - return 1; -} - -void Parser::handleMarkedSectionEnd() -{ - if (markedSectionLevel() == 0) - message(ParserMessages::markedSectionEnd); - else { - if (inInstance() - ? eventsWanted().wantMarkedSections() - : eventsWanted().wantPrologMarkup()) { - if (markedSectionSpecialLevel() > 1) - eventHandler().ignoredChars(new (eventAllocator()) - IgnoredCharsEvent(currentInput()->currentTokenStart(), - currentInput()->currentTokenLength(), - currentLocation(), - 0)); - else { - MarkedSectionEvent::Status status; - switch (currentMode()) { - case cmsMode: - status = MarkedSectionEvent::cdata; - break; - case rcmsMode: - status = MarkedSectionEvent::rcdata; - break; - case imsMode: - status = MarkedSectionEvent::ignore; - break; - default: - status = MarkedSectionEvent::include; - break; - } - startMarkup(1, currentLocation()); - currentMarkup()->addDelim(Syntax::dMSC); - currentMarkup()->addDelim(Syntax::dMDC); - eventHandler().markedSectionEnd(new (eventAllocator()) - MarkedSectionEndEvent(status, - markupLocation(), - currentMarkup())); - } - } - endMarkedSection(); - } -} - -void Parser::emptyCommentDecl() -{ - if (startMarkup(eventsWanted().wantCommentDecls(), currentLocation())) { - currentMarkup()->addDelim(Syntax::dMDO); - currentMarkup()->addDelim(Syntax::dMDC); - eventHandler().commentDecl(new (eventAllocator()) - CommentDeclEvent(markupLocation(), - currentMarkup())); - } -} - -Boolean Parser::parseCommentDecl() -{ - if (startMarkup(inInstance() - ? eventsWanted().wantCommentDecls() - : eventsWanted().wantPrologMarkup(), - currentLocation())) - currentMarkup()->addDelim(Syntax::dMDO); - if (!parseComment(comMode)) - return 0; - for (;;) { - Token token = getToken(mdMode); - switch (token) { - case tokenS: - if (currentMarkup()) - currentMarkup()->addS(currentChar()); - break; - case tokenCom: - if (!parseComment(comMode)) - return 0; - break; - case tokenMdc: - if (currentMarkup()) - currentMarkup()->addDelim(Syntax::dMDC); - goto done; - case tokenEe: - message(ParserMessages::declarationLevel); - return 0; - case tokenUnrecognized: - if (reportNonSgmlCharacter()) - break; - // braces to work round Sun C++ 4.0 bug - { - message(ParserMessages::commentDeclarationCharacter, - StringMessageArg(currentToken()), - markupLocation()); - } - return 0; - default: - // braces to work round Sun C++ 4.0 bug - { - message(ParserMessages::commentDeclInvalidToken, - TokenMessageArg(token, mdMode, syntaxPointer(), sdPointer()), - markupLocation()); - } - return 0; - } - } - done: - if (currentMarkup()) - eventHandler().commentDecl(new (eventAllocator()) - CommentDeclEvent(markupLocation(), - currentMarkup())); - return 1; -} - -Boolean Parser::parseAfdrDecl() -{ - unsigned declInputLevel = inputLevel(); - static AllowedParams allowMinimumLiteral(Param::minimumLiteral); - Param parm; - setHadAfdrDecl(); - if (!parseParam(allowMinimumLiteral, declInputLevel, parm)) - return 0; - if (parm.literalText.string() != sd().execToDoc("ISO/IEC 10744:1992")) - message(ParserMessages::afdrVersion, - StringMessageArg(parm.literalText.string())); - if (!parseParam(allowMdc, declInputLevel, parm)) - return 0; - eventHandler().ignoredMarkup(new (eventAllocator()) - IgnoredMarkupEvent(markupLocation(), - currentMarkup())); - return 1; -} - -#ifdef SP_NAMESPACE -} -#endif diff --git a/cde/programs/nsgmls/parseInstance.C b/cde/programs/nsgmls/parseInstance.C deleted file mode 100644 index dee6e8166..000000000 --- a/cde/programs/nsgmls/parseInstance.C +++ /dev/null @@ -1,1300 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: parseInstance.C /main/2 1996/08/12 14:05:40 mgreess $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#include "splib.h" -#include "Parser.h" -#include "ParserMessages.C" -#include "MessageArg.h" -#include "TokenMessageArg.h" -#include "StringVectorMessageArg.h" -#include "token.h" -#include "macros.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -void Parser::doInstanceStart() -{ - if (cancelled()) { - allDone(); - return; - } - // FIXME check here that we have a valid dtd - compileInstanceModes(); - setPhase(contentPhase); - Token token = getToken(currentMode()); - switch (token) { - case tokenEe: - case tokenStagoNameStart: - case tokenStagoTagc: - case tokenStagoGrpo: - case tokenEtagoNameStart: - case tokenEtagoTagc: - case tokenEtagoGrpo: - break; - default: - if (sd().omittag()) { - unsigned startImpliedCount = 0; - unsigned attributeListIndex = 0; - IList undoList; - IList eventList; - if (!tryImplyTag(currentLocation(), - startImpliedCount, - attributeListIndex, - undoList, - eventList)) - CANNOT_HAPPEN(); - queueElementEvents(eventList); - } - else - message(ParserMessages::instanceStartOmittag); - } - currentInput()->ungetToken(); -} - -void Parser::endInstance() -{ - // Do checking before popping entity stack so that there's a - // current location for error messages. - endAllElements(); - while (markedSectionLevel() > 0) { - message(ParserMessages::unclosedMarkedSection, - currentMarkedSectionStartLocation()); - endMarkedSection(); - } - checkIdrefs(); - popInputStack(); - allDone(); -} - -void Parser::checkIdrefs() -{ - IdTableIter iter(idTableIter()); - Id *id; - while ((id = iter.next()) != 0) { - for (size_t i = 0; i < id->pendingRefs().size(); i++) { - Messenger::setNextLocation(id->pendingRefs()[i]); - message(ParserMessages::missingId, StringMessageArg(id->name())); - } - } -} - -void Parser::doContent() -{ - do { - if (cancelled()) { - allDone(); - return; - } - Token token = getToken(currentMode()); - switch (token) { - case tokenEe: - if (inputLevel() == 1) { - endInstance(); - return; - } - if (inputLevel() == specialParseInputLevel()) { - // FIXME have separate messages for each type of special parse - // perhaps force end of marked section or element - message(ParserMessages::specialParseEntityEnd); - } - if (eventsWanted().wantInstanceMarkup()) - eventHandler().entityEnd(new (eventAllocator()) - EntityEndEvent(currentLocation())); - if (afterDocumentElement()) - message(ParserMessages::afterDocumentElementEntityEnd); - popInputStack(); - break; - case tokenCroDigit: - { - if (afterDocumentElement()) - message(ParserMessages::characterReferenceAfterDocumentElement); - Char ch; - Location loc; - if (parseNumericCharRef(ch, loc)) { - acceptPcdata(loc); - noteData(); - eventHandler().data(new (eventAllocator()) - ImmediateDataEvent(Event::characterData, - &ch, 1, loc, 1)); - break; - } - } - break; - case tokenCroNameStart: - if (afterDocumentElement()) - message(ParserMessages::characterReferenceAfterDocumentElement); - parseNamedCharRef(); - break; - case tokenEroGrpo: - case tokenEroNameStart: - { - if (afterDocumentElement()) - message(ParserMessages::entityReferenceAfterDocumentElement); - ConstPtr entity; - Ptr origin; - if (parseEntityReference(0, token == tokenEroGrpo, entity, origin)) { - if (!entity.isNull()) { - if (entity->isCharacterData()) - acceptPcdata(Location(origin.pointer(), 0)); - if (inputLevel() == specialParseInputLevel()) - entity->rcdataReference(*this, origin); - else - entity->contentReference(*this, origin); - } - } - noteMarkup(); - } - break; - case tokenEtagoNameStart: - parseEndTag(); - break; - case tokenEtagoTagc: - parseEmptyEndTag(); - break; - case tokenEtagoGrpo: - parseGroupEndTag(); - break; - case tokenMdoNameStart: - if (startMarkup(eventsWanted().wantInstanceMarkup(), currentLocation())) - currentMarkup()->addDelim(Syntax::dMDO); - Syntax::ReservedName name; - Boolean result; - unsigned startLevel; - startLevel = inputLevel(); - if (parseDeclarationName(&name)) { - switch (name) { - case Syntax::rUSEMAP: - if (afterDocumentElement()) - message(ParserMessages::declarationAfterDocumentElement, - StringMessageArg(syntax().reservedName(name))); - result = parseUsemapDecl(); - break; - case Syntax::rUSELINK: - if (afterDocumentElement()) - message(ParserMessages::declarationAfterDocumentElement, - StringMessageArg(syntax().reservedName(name))); - result = parseUselinkDecl(); - break; - case Syntax::rDOCTYPE: - case Syntax::rLINKTYPE: - case Syntax::rELEMENT: - case Syntax::rATTLIST: - case Syntax::rENTITY: - case Syntax::rNOTATION: - case Syntax::rSHORTREF: - case Syntax::rLINK: - case Syntax::rIDLINK: - message(ParserMessages::instanceDeclaration, - StringMessageArg(syntax().reservedName(name))); - result = 0; - break; - default: - message(ParserMessages::noSuchDeclarationType, - StringMessageArg(syntax().reservedName(name))); - result = 0; - break; - } - } - else - result = 0; - if (!result) - skipDeclaration(startLevel); - noteMarkup(); - break; - case tokenMdoMdc: - // empty comment - emptyCommentDecl(); - noteMarkup(); - break; - case tokenMdoCom: - parseCommentDecl(); - noteMarkup(); - break; - case tokenMdoDso: - if (afterDocumentElement()) - message(ParserMessages::markedSectionAfterDocumentElement); - parseMarkedSectionDeclStart(); - noteMarkup(); - break; - case tokenMscMdc: - handleMarkedSectionEnd(); - noteMarkup(); - break; - case tokenNet: - parseNullEndTag(); - break; - case tokenPio: - parseProcessingInstruction(); - break; - case tokenStagoNameStart: - parseStartTag(); - break; - case tokenStagoTagc: - parseEmptyStartTag(); - break; - case tokenStagoGrpo: - parseGroupStartTag(); - break; - case tokenRe: - acceptPcdata(currentLocation()); - queueRe(currentLocation()); - break; - case tokenRs: - acceptPcdata(currentLocation()); - noteRs(); - if (eventsWanted().wantInstanceMarkup()) - eventHandler().ignoredRs(new (eventAllocator()) - IgnoredRsEvent(currentChar(), - currentLocation())); - break; - case tokenS: - extendContentS(); - if (eventsWanted().wantInstanceMarkup()) - eventHandler().sSep(new (eventAllocator()) - SSepEvent(currentInput()->currentTokenStart(), - currentInput()->currentTokenLength(), - currentLocation(), - 0)); - break; - case tokenIgnoredChar: - extendData(); - if (eventsWanted().wantMarkedSections()) - eventHandler().ignoredChars(new (eventAllocator()) - IgnoredCharsEvent(currentInput()->currentTokenStart(), - currentInput()->currentTokenLength(), - currentLocation(), - 0)); - break; - case tokenUnrecognized: - reportNonSgmlCharacter(); - // fall through - case tokenChar: - parsePcdata(); - break; - default: - ASSERT(token >= tokenFirstShortref); - handleShortref(token - tokenFirstShortref); - break; - } - } while (eventQueueEmpty()); -} - -void Parser::skipDeclaration(unsigned startLevel) -{ - const unsigned skipMax = 250; - unsigned skipCount = 0; - for (;;) { - Token token = getToken(mdMode); - if (inputLevel() == startLevel) - skipCount++; - switch (token) { - case tokenUnrecognized: - (void)getChar(); - break; - case tokenEe: - if (inputLevel() <= startLevel) - return; - popInputStack(); - return; - case tokenMdc: - if (inputLevel() == startLevel) - return; - break; - case tokenS: - if (inputLevel() == startLevel && skipCount >= skipMax - && currentChar() == syntax().standardFunction(Syntax::fRE)) - return; - break; - default: - break; - } - } -} - -void Parser::handleShortref(int index) -{ - const ConstPtr &entity - = currentElement().map()->entity(index); - if (!entity.isNull()) { - Owner markupPtr; - if (eventsWanted().wantInstanceMarkup()) { - markupPtr = new Markup; - markupPtr->addShortref(currentInput()); - } - Ptr origin - = new (internalAllocator()) - EntityOrigin(entity, - currentLocation(), - currentInput()->currentTokenLength(), - markupPtr); - entity->contentReference(*this, origin); - return; - } - InputSource *in = currentInput(); - size_t length = in->currentTokenLength(); - const Char *s = in->currentTokenStart(); - size_t i = 0; - if (currentMode() == econMode || currentMode() == econnetMode) { - // FIXME do this in advance (what about B sequence?) - for (i = 0; i < length && syntax().isS(s[i]); i++) - ; - if (i > 0 && eventsWanted().wantInstanceMarkup()) - eventHandler().sSep(new (eventAllocator()) - SSepEvent(s, i, currentLocation(), 0)); - } - if (i < length) { - Location location(currentLocation()); - location += i; - s += i; - length -= i; - acceptPcdata(location); - // FIXME speed this up - for (; length > 0; location += 1, length--, s++) { - if (*s == syntax().standardFunction(Syntax::fRS)) { - noteRs(); - if (eventsWanted().wantInstanceMarkup()) - eventHandler().ignoredRs(new (eventAllocator()) - IgnoredRsEvent(*s, location)); - } - else if (*s == syntax().standardFunction(Syntax::fRE)) - queueRe(location); - else { - noteData(); - eventHandler().data(new (eventAllocator()) - ImmediateDataEvent(Event::characterData, s, 1, - location, 0)); - } - } - } -} - -void Parser::parsePcdata() -{ - extendData(); - acceptPcdata(currentLocation()); - noteData(); - eventHandler().data(new (eventAllocator()) - ImmediateDataEvent(Event::characterData, - currentInput()->currentTokenStart(), - currentInput()->currentTokenLength(), - currentLocation(), - 0)); -} - -void Parser::parseStartTag() -{ - InputSource *in = currentInput(); - Markup *markup = startMarkup(eventsWanted().wantInstanceMarkup(), - in->currentLocation()); - in->discardInitial(); - extendNameToken(syntax().namelen(), ParserMessages::nameLength); - if (markup) { - markup->addDelim(Syntax::dSTAGO); - markup->addName(in); - } - StringC &name = nameBuffer(); - getCurrentToken(syntax().generalSubstTable(), name); - const ElementType *e = currentDtd().lookupElementType(name); - if (sd().rank()) { - if (!e) - e = completeRankStem(name); - else if (e->isRankedElement()) - handleRankedElement(e); - } - if (!e) - e = lookupCreateUndefinedElement(name, currentLocation()); - Boolean netEnabling; - AttributeList *attributes = allocAttributeList(e->attributeDef(), 0); - Token closeToken = getToken(tagMode); - if (closeToken == tokenTagc) { - if (name.size() > syntax().taglen()) - checkTaglen(markupLocation().index()); - attributes->finish(*this); - netEnabling = 0; - if (markup) - markup->addDelim(Syntax::dTAGC); - } - else { - in->ungetToken(); - if (parseAttributeSpec(0, *attributes, netEnabling)) { - // The difference between the indices will be the difference - // in offsets plus 1 for each named character reference. - if (in->currentLocation().index() - markupLocation().index() - > syntax().taglen()) - checkTaglen(markupLocation().index()); - } - else - netEnabling = 0; - } - acceptStartTag(e, - new (eventAllocator()) - StartElementEvent(e, - currentDtdPointer(), - attributes, - markupLocation(), - markup), - netEnabling); -} - -const ElementType *Parser::completeRankStem(const StringC &name) -{ - const RankStem *rankStem = currentDtd().lookupRankStem(name); - if (rankStem) { - StringC name(rankStem->name()); - if (!appendCurrentRank(name, rankStem)) - message(ParserMessages::noCurrentRank, StringMessageArg(name)); - else - return currentDtd().lookupElementType(name); - } - return 0; -} - -void Parser::handleRankedElement(const ElementType *e) -{ - StringC rankSuffix(e->definition()->rankSuffix()); - const RankStem *rankStem = e->rankedElementRankStem(); - for (size_t i = 0; i < rankStem->nDefinitions(); i++) { - const ElementDefinition *def = rankStem->definition(i); - for (size_t j = 0; j < def->nRankStems(); j++) - setCurrentRank(def->rankStem(j), rankSuffix); - } -} - -void Parser::checkTaglen(Index tagStartIndex) -{ - const InputSourceOrigin *origin - = currentLocation().origin()->asInputSourceOrigin(); - ASSERT(origin != 0); - if (origin->startOffset(currentLocation().index()) - - origin->startOffset(tagStartIndex - + syntax().delimGeneral(Syntax::dSTAGO).size()) - > syntax().taglen()) - message(ParserMessages::taglen, NumberMessageArg(syntax().taglen())); -} - -void Parser::parseEmptyStartTag() -{ - if (options().warnEmptyTag) - message(ParserMessages::emptyStartTag); - // FIXME error if not in base. - const ElementType *e = 0; - if (!sd().omittag()) - e = lastEndedElementType(); - else if (tagLevel() > 0) - e = currentElement().type(); - if (!e) - e = currentDtd().documentElementType(); - AttributeList *attributes = allocAttributeList(e->attributeDef(), 0); - attributes->finish(*this); - Markup *markup = startMarkup(eventsWanted().wantInstanceMarkup(), - currentLocation()); - if (markup) { - markup->addDelim(Syntax::dSTAGO); - markup->addDelim(Syntax::dTAGC); - } - acceptStartTag(e, - new (eventAllocator()) - StartElementEvent(e, - currentDtdPointer(), - attributes, - markupLocation(), - markup), - 0); -} - -void Parser::parseGroupStartTag() -{ - if (startMarkup(eventsWanted().wantInstanceMarkup(), currentLocation())) { - currentMarkup()->addDelim(Syntax::dSTAGO); - currentMarkup()->addDelim(Syntax::dGRPO); - } - Boolean active; - if (!parseTagNameGroup(active)) - return; - InputSource *in = currentInput(); - // Location startLocation = in->currentLocation(); - in->startToken(); - Xchar c = in->tokenChar(messenger()); - if (!syntax().isNameStartCharacter(c)) { - message(ParserMessages::startTagMissingName); - return; - } - in->discardInitial(); - extendNameToken(syntax().namelen(), ParserMessages::nameLength); - if (currentMarkup()) - currentMarkup()->addName(currentInput()); - skipAttributeSpec(); - if (currentMarkup()) - eventHandler().ignoredMarkup(new (eventAllocator()) - IgnoredMarkupEvent(markupLocation(), - currentMarkup())); - noteMarkup(); -} - -void Parser::parseGroupEndTag() -{ - if (startMarkup(eventsWanted().wantInstanceMarkup(), currentLocation())) { - currentMarkup()->addDelim(Syntax::dSTAGO); - currentMarkup()->addDelim(Syntax::dGRPO); - } - Boolean active; - if (!parseTagNameGroup(active)) - return; - InputSource *in = currentInput(); - // Location startLocation = in->currentLocation(); - in->startToken(); - Xchar c = in->tokenChar(messenger()); - if (!syntax().isNameStartCharacter(c)) { - message(ParserMessages::endTagMissingName); - return; - } - in->discardInitial(); - extendNameToken(syntax().namelen(), ParserMessages::nameLength); - if (currentMarkup()) - currentMarkup()->addName(currentInput()); - parseEndTagClose(); - if (currentMarkup()) - eventHandler().ignoredMarkup(new (eventAllocator()) - IgnoredMarkupEvent(markupLocation(), - currentMarkup())); - noteMarkup(); -} - -void Parser::acceptPcdata(const Location &startLocation) -{ - if (currentElement().tryTransitionPcdata()) - return; - // Need to test here since implying tags may turn off pcdataRecovering. - if (pcdataRecovering()) - return; - IList undoList; - IList eventList; - unsigned startImpliedCount = 0; - unsigned attributeListIndex = 0; - keepMessages(); - while (tryImplyTag(startLocation, startImpliedCount, attributeListIndex, - undoList, eventList)) - if (currentElement().tryTransitionPcdata()) { - queueElementEvents(eventList); - return; - } - discardKeptMessages(); - undo(undoList); - message(ParserMessages::pcdataNotAllowed); - pcdataRecover(); -} - -void Parser::acceptStartTag(const ElementType *e, - StartElementEvent *event, - Boolean netEnabling) -{ - if (e->definition()->undefined()) { - message(ParserMessages::undefinedElement, StringMessageArg(e->name())); - pushElementCheck(e, event, netEnabling); - return; - } - if (elementIsExcluded(e)) { - keepMessages(); - checkExclusion(e); - } - else { - if (currentElement().tryTransition(e)) { - pushElementCheck(e, event, netEnabling); - return; - } - if (elementIsIncluded(e)) { - event->setIncluded(); - pushElementCheck(e, event, netEnabling); - return; - } - keepMessages(); - } - IList undoList; - IList eventList; - unsigned startImpliedCount = 0; - unsigned attributeListIndex = 1; - while (tryImplyTag(event->location(), startImpliedCount, - attributeListIndex, undoList, eventList)) - if (tryStartTag(e, event, netEnabling, eventList)) - return; - discardKeptMessages(); - undo(undoList); - handleBadStartTag(e, event, netEnabling); -} - -void Parser::undo(IList &undoList) -{ - while (!undoList.empty()) { - Undo *p = undoList.get(); - p->undo(this); - delete p; - } -} - -void Parser::queueElementEvents(IList &events) -{ - releaseKeptMessages(); - // FIXME provide IList::reverse function - // reverse it - IList tem; - while (!events.empty()) - tem.insert(events.get()); - while (!tem.empty()) { - Event *e = tem.get(); - if (e->type() == Event::startElement) { - noteStartElement(((StartElementEvent *)e)->included()); - eventHandler().startElement((StartElementEvent *)e); - } - else { - noteEndElement(((EndElementEvent *)e)->included()); - eventHandler().endElement((EndElementEvent *)e); - } - } - -} - -void Parser::checkExclusion(const ElementType *e) -{ - const LeafContentToken *token = currentElement().invalidExclusion(e); - if (token) - message(ParserMessages::invalidExclusion, - OrdinalMessageArg(token->typeIndex() + 1), - StringMessageArg(token->elementType()->name()), - StringMessageArg(currentElement().type()->name())); -} - -Boolean Parser::tryStartTag(const ElementType *e, - StartElementEvent *event, - Boolean netEnabling, - IList &impliedEvents) -{ - if (elementIsExcluded(e)) { - checkExclusion(e); - return 0; - } - if (currentElement().tryTransition(e)) { - queueElementEvents(impliedEvents); - pushElementCheck(e, event, netEnabling); - return 1; - } - if (elementIsIncluded(e)) { - queueElementEvents(impliedEvents); - event->setIncluded(); - pushElementCheck(e, event, netEnabling); - return 1; - } - return 0; -} - -Boolean Parser::tryImplyTag(const Location &loc, - unsigned &startImpliedCount, - unsigned &attributeListIndex, - IList &undo, - IList &eventList) -{ - if (!sd().omittag()) - return 0; - if (currentElement().isFinished()) { - if (tagLevel() == 0) - return 0; -#if 1 - const ElementDefinition *def = currentElement().type()->definition(); - if (def && !def->canOmitEndTag()) - return 0; -#endif - // imply an end tag - if (startImpliedCount > 0) { - message(ParserMessages::startTagEmptyElement, - StringMessageArg(currentElement().type()->name())); - startImpliedCount--; - } -#if 0 - const ElementDefinition *def = currentElement().type()->definition(); - if (def && !def->canOmitEndTag()) - message(ParserMessages::omitEndTagDeclare, - StringMessageArg(currentElement().type()->name()), - currentElement().startLocation()); -#endif - EndElementEvent *event - = new (eventAllocator()) EndElementEvent(currentElement().type(), - currentDtdPointer(), - loc, - 0); - eventList.insert(event); - undo.insert(new (internalAllocator()) UndoEndTag(popSaveElement())); - return 1; - } - const LeafContentToken *token = currentElement().impliedStartTag(); - if (!token) - return 0; - const ElementType *e = token->elementType(); - if (elementIsExcluded(e)) - message(ParserMessages::requiredElementExcluded, - OrdinalMessageArg(token->typeIndex() + 1), - StringMessageArg(e->name()), - StringMessageArg(currentElement().type()->name())); - if (tagLevel() != 0) - undo.insert(new (internalAllocator()) - UndoTransition(currentElement().matchState())); - currentElement().doRequiredTransition(); - const ElementDefinition *def = e->definition(); - if (def->declaredContent() != ElementDefinition::modelGroup - && def->declaredContent() != ElementDefinition::any) - message(ParserMessages::omitStartTagDeclaredContent, - StringMessageArg(e->name())); - if (def->undefined()) - message(ParserMessages::undefinedElement, StringMessageArg(e->name())); - else if (!def->canOmitStartTag()) - message(ParserMessages::omitStartTagDeclare, StringMessageArg(e->name())); - AttributeList *attributes - = allocAttributeList(e->attributeDef(), - attributeListIndex++); - // this will give an error if the element has a required attribute - attributes->finish(*this); - startImpliedCount++; - StartElementEvent *event - = new (eventAllocator()) StartElementEvent(e, - currentDtdPointer(), - attributes, - loc, - 0); - pushElementCheck(e, event, undo, eventList); - const int implyCheckLimit = 30; // this is fairly arbitrary - if (startImpliedCount > implyCheckLimit - && !checkImplyLoop(startImpliedCount)) - return 0; - return 1; -} - -void Parser::pushElementCheck(const ElementType *e, StartElementEvent *event, - Boolean netEnabling) -{ - if (tagLevel() == syntax().taglvl()) - message(ParserMessages::taglvlOpenElements, NumberMessageArg(syntax().taglvl())); - noteStartElement(event->included()); - if (event->mustOmitEnd()) { - EndElementEvent *end - = new (eventAllocator()) EndElementEvent(e, - currentDtdPointer(), - event->location(), - 0); - if (event->included()) { - end->setIncluded(); - noteEndElement(1); - } - else - noteEndElement(0); - eventHandler().startElement(event); - eventHandler().endElement(end); - } - else { - const ShortReferenceMap *map = e->map(); - if (!map) - map = currentElement().map(); - pushElement(new (internalAllocator()) OpenElement(e, - netEnabling, - event->included(), - map, - event->location())); - // Can't access event after it's passed to the event handler. - eventHandler().startElement(event); - } -} - -void Parser::pushElementCheck(const ElementType *e, StartElementEvent *event, - IList &undoList, - IList &eventList) -{ - if (tagLevel() == syntax().taglvl()) - message(ParserMessages::taglvlOpenElements, NumberMessageArg(syntax().taglvl())); - eventList.insert(event); - if (event->mustOmitEnd()) { - EndElementEvent *end - = new (eventAllocator()) EndElementEvent(e, - currentDtdPointer(), - event->location(), - 0); - if (event->included()) - end->setIncluded(); - eventList.insert(end); - } - else { - undoList.insert(new (internalAllocator()) UndoStartTag); - const ShortReferenceMap *map = e->map(); - if (!map) - map = currentElement().map(); - pushElement(new (internalAllocator()) OpenElement(e, - 0, - event->included(), - map, - event->location())); - } -} - -void Parser::parseEndTag() -{ - Markup *markup = startMarkup(eventsWanted().wantInstanceMarkup(), - currentLocation()); - currentInput()->discardInitial(); - extendNameToken(syntax().namelen(), ParserMessages::nameLength); - if (markup) { - markup->addDelim(Syntax::dETAGO); - markup->addName(currentInput()); - } - StringC &name = nameBuffer(); - getCurrentToken(syntax().generalSubstTable(), name); - const ElementType *e = currentDtd().lookupElementType(name); - if (sd().rank()) { - if (!e) - e = completeRankStem(name); - } - if (!e) - e = lookupCreateUndefinedElement(name, currentLocation()); - parseEndTagClose(); - acceptEndTag(e, - new (eventAllocator()) - EndElementEvent(e, - currentDtdPointer(), - markupLocation(), - markup)); -} - -void Parser::parseEndTagClose() -{ - for (;;) { - Token token = getToken(tagMode); - switch (token) { - case tokenUnrecognized: - if (!reportNonSgmlCharacter()) - message(ParserMessages::endTagCharacter, StringMessageArg(currentToken())); - return; - case tokenEe: - message(ParserMessages::endTagEntityEnd); - return; - case tokenEtago: - case tokenStago: - if (!sd().shorttag()) - message(ParserMessages::minimizedEndTag); - else if (options().warnUnclosedTag) - message(ParserMessages::unclosedEndTag); - currentInput()->ungetToken(); - return; - case tokenTagc: - if (currentMarkup()) - currentMarkup()->addDelim(Syntax::dTAGC); - return; - case tokenS: - if (currentMarkup()) - currentMarkup()->addS(currentChar()); - break; - default: - message(ParserMessages::endTagInvalidToken, - TokenMessageArg(token, tagMode, syntaxPointer(), sdPointer())); - return; - } - } -} - -void Parser::parseEmptyEndTag() -{ - if (options().warnEmptyTag) - message(ParserMessages::emptyEndTag); - // FIXME what to do if not in base - if (tagLevel() == 0) - message(ParserMessages::emptyEndTagNoOpenElements); - else { - Markup *markup = startMarkup(eventsWanted().wantInstanceMarkup(), - currentLocation()); - if (markup) { - markup->addDelim(Syntax::dETAGO); - markup->addDelim(Syntax::dTAGC); - } - acceptEndTag(currentElement().type(), - new (eventAllocator()) EndElementEvent(currentElement().type(), - currentDtdPointer(), - currentLocation(), - markup)); - } -} - -void Parser::parseNullEndTag() -{ - if (options().warnNet) - message(ParserMessages::nullEndTag); - // If a null end tag was recognized, then there must be a net enabling - // element on the stack. - for (;;) { - ASSERT(tagLevel() > 0); - if (currentElement().netEnabling()) - break; - if (!currentElement().isFinished()) - message(ParserMessages::elementNotFinished, - StringMessageArg(currentElement().type()->name())); - implyCurrentElementEnd(currentLocation()); - } - if (!currentElement().isFinished()) - message(ParserMessages::elementEndTagNotFinished, - StringMessageArg(currentElement().type()->name())); - Markup *markup = startMarkup(eventsWanted().wantInstanceMarkup(), - currentLocation()); - if (markup) - markup->addDelim(Syntax::dNET); - acceptEndTag(currentElement().type(), - new (eventAllocator()) EndElementEvent(currentElement().type(), - currentDtdPointer(), - currentLocation(), - markup)); -} - -void Parser::endAllElements() -{ - while (tagLevel() > 0) { - if (!currentElement().isFinished()) - message(ParserMessages::elementNotFinishedDocumentEnd, - StringMessageArg(currentElement().type()->name())); - implyCurrentElementEnd(currentLocation()); - } - if (!currentElement().isFinished()) - message(ParserMessages::noDocumentElement); -} - -void Parser::acceptEndTag(const ElementType *e, - EndElementEvent *event) -{ - if (!elementIsOpen(e)) { - message(ParserMessages::elementNotOpen, StringMessageArg(e->name())); - delete event; - return; - } - for (;;){ - if (currentElement().type() == e) - break; - if (!currentElement().isFinished()) - message(ParserMessages::elementNotFinished, - StringMessageArg(currentElement().type()->name())); - implyCurrentElementEnd(event->location()); - } - if (!currentElement().isFinished()) - message(ParserMessages::elementEndTagNotFinished, - StringMessageArg(currentElement().type()->name())); - if (currentElement().included()) - event->setIncluded(); - noteEndElement(event->included()); - eventHandler().endElement(event); - popElement(); -} - -void Parser::implyCurrentElementEnd(const Location &loc) -{ - if (!sd().omittag()) - message(ParserMessages::omitEndTagOmittag, - StringMessageArg(currentElement().type()->name()), - currentElement().startLocation()); - else { - const ElementDefinition *def = currentElement().type()->definition(); - if (def && !def->canOmitEndTag()) - message(ParserMessages::omitEndTagDeclare, - StringMessageArg(currentElement().type()->name()), - currentElement().startLocation()); - } - EndElementEvent *event - = new (eventAllocator()) EndElementEvent(currentElement().type(), - currentDtdPointer(), - loc, - 0); - if (currentElement().included()) - event->setIncluded(); - noteEndElement(event->included()); - eventHandler().endElement(event); - popElement(); -} - -void Parser::extendData() -{ - XcharMap isNormal(normalMap()); - InputSource *in = currentInput(); - size_t length = in->currentTokenLength(); - // This is one of the parser's inner loops, so it needs to be fast. - while (isNormal[in->tokenChar(messenger())]) - length++; - in->endToken(length); -} - -void Parser::extendContentS() -{ - InputSource *in = currentInput(); - size_t length = in->currentTokenLength(); - XcharMap isNormal(normalMap()); - for (;;) { - Xchar ch = in->tokenChar(messenger()); - if (!syntax().isS(ch) || !isNormal[ch]) - break; - length++; - } - in->endToken(length); -} - -void Parser::handleBadStartTag(const ElementType *e, - StartElementEvent *event, - Boolean netEnabling) -{ - IList undoList; - IList eventList; - keepMessages(); - for (;;) { - Vector missing; - findMissingTag(e, missing); - if (missing.size() == 1) { - queueElementEvents(eventList); - const ElementType *m = missing[0]; - message(ParserMessages::missingElementInferred, - StringMessageArg(e->name()), - StringMessageArg(m->name())); - AttributeList *attributes - = allocAttributeList(m->attributeDef(), 1); - // this will give an error if the element has a required attribute - attributes->finish(*this); - StartElementEvent *inferEvent - = new (eventAllocator()) StartElementEvent(m, - currentDtdPointer(), - attributes, - event->location(), - 0); - if (!currentElement().tryTransition(m)) - inferEvent->setIncluded(); - pushElementCheck(m, inferEvent, 0); - if (!currentElement().tryTransition(e)) - event->setIncluded(); - pushElementCheck(e, event, netEnabling); - return; - } - if (missing.size() > 0) { - queueElementEvents(eventList); - Vector missingNames; - for (size_t i = 0; i < missing.size(); i++) - missingNames.push_back(missing[i]->name()); - message(ParserMessages::missingElementMultiple, - StringMessageArg(e->name()), - StringVectorMessageArg(missingNames)); - pushElementCheck(e, event, netEnabling); - return; - } - if (!sd().omittag() - || !currentElement().isFinished() - || tagLevel() == 0 - || !currentElement().type()->definition()->canOmitEndTag()) - break; - EndElementEvent *endEvent - = new (eventAllocator()) EndElementEvent(currentElement().type(), - currentDtdPointer(), - event->location(), - 0); - eventList.insert(endEvent); - undoList.insert(new (internalAllocator()) UndoEndTag(popSaveElement())); - } - discardKeptMessages(); - undo(undoList); - message(ParserMessages::elementNotAllowed, StringMessageArg(e->name())); - // If element couldn't occur because it was excluded, then - // do the transition here. - (void)currentElement().tryTransition(e); - pushElementCheck(e, event, netEnabling); -} - -void Parser::findMissingTag(const ElementType *e, - Vector &v) -{ - size_t i; - - if (!currentElement().currentPosition()) { - if (!e) - v.push_back((const ElementType *)0); - return; - } - if (elementIsExcluded(e)) - return; - size_t newSize = 0; - currentElement().matchState().possibleTransitions(v); - // FIXME also get currentInclusions - for (i = 0; i < v.size(); i++) { - if (v[i] && !elementIsExcluded(v[i])) { - Boolean success = 0; - switch (v[i]->definition()->declaredContent()) { - case ElementDefinition::modelGroup: - { - const CompiledModelGroup *grp - = v[i]->definition()->compiledModelGroup(); - MatchState state(grp); - if (!e) { - if (state.tryTransitionPcdata()) - success = 1; - } - else { - if (state.tryTransition(e)) - success = 1; - if (!success) { - for (size_t j = 0; j < v[i]->definition()->nInclusions(); j++) - if (v[i]->definition()->inclusion(j) == e) { - success = 1; - break; - } - } - if (success) { - for (size_t j = 0; j < v[i]->definition()->nExclusions(); j++) - if (v[i]->definition()->exclusion(j) == e) { - success = 0; - break; - } - } - } - } - break; -#if 0 - case ElementDefinition::any: - success = 1; - break; -#endif - case ElementDefinition::cdata: - case ElementDefinition::rcdata: - if (e == 0) - success = 1; - break; - default: - break; - } - if (success) - v[newSize++] = v[i]; - } - } - v.resize(newSize); - // Sort them according to the order of their occurrence in the DTD. - // Do an insertion sort. - for (i = 1; i < v.size(); i++) { - const ElementType *tem = v[i]; - size_t j; - for (j = i; j > 0 && v[j - 1]->index() > tem->index(); j--) - v[j] = v[j - 1]; - v[j] = tem; - } -} - -#if 0 -// This produces messages that are too verbose -// This doesn't try to be very efficient. -// 0 for #pcdata - -void Parser::getAllowedElementTypes(Vector &v) -{ - v.clear(); - // FIXME get a list of all inclusions first - // getCurrentInclusions(v); - // x says whether each element of v was excluded - Vector x(v.size(), 0); - unsigned startImpliedCount = 0; - IList undoList; - for (;;) { - if (currentElement().currentPosition()) { - // have a model group - size_t i = v.size(); - currentElement().matchState().possibleTransitions(v); - x.resize(v.size()); - for (size_t j = i; j < v.size(); j++) - x[j] = (v[j] && elementIsExcluded(v[j])); - if (!sd().omittag()) - break; - // Try to imply a tag - if (currentElement().isFinished()) { - if (tagLevel() == 0) - break; - if (startImpliedCount) - break; - const ElementDefinition *def = currentElement().type()->definition(); - if (def && def->canOmitEndTag()) - undoList.insert(new (internalAllocator()) - UndoEndTag(popSaveElement())); - else - break; - } - else { - const LeafContentToken *token = currentElement().impliedStartTag(); - if (!token) - break; - const ElementType *e = token->elementType(); - if (elementIsExcluded(e)) - break; - const ElementDefinition *def = e->definition(); - if (!def - || def->undefined() - || (def->declaredContent() != ElementDefinition::modelGroup - && def->declaredContent() != ElementDefinition::any) - || !def->canOmitStartTag()) - break; - undoList.insert(new (internalAllocator()) UndoStartTag); - startImpliedCount++; - pushElement(new (internalAllocator()) OpenElement(e, - 0, - 0, - 0, - Location())); - if (checkImplyLoop(startImpliedCount)) - break; - for (size_t i = 0; i < def->nInclusions(); i++) - if (!elementIsExcluded(def->inclusion(i))) { - v.push_back(def->inclusion(i)); - x.push_back(0); - } - } - } - else { - // must be allowed #pcdata - v.push_back((const ElementType *)0); - x.push_back((PackedBoolean)0); - break; - } - } - undo(undoList); - // Remove exclusions and duplicates and undefined - size_t newSize = 0; - for (size_t i = 0; i < v.size(); i++) - if (!x[i] && (!v[i] || !v[i]->definition()->undefined())) { - Boolean dup = 0; - for (size_t j = 0; j < newSize; j++) - if (v[i] == v[j]) { - dup = 1; - break; - } - if (!dup) - v[newSize++] = v[i]; - } - v.resize(newSize); -} -#endif - -#ifdef SP_NAMESPACE -} -#endif diff --git a/cde/programs/nsgmls/parseMode.C b/cde/programs/nsgmls/parseMode.C deleted file mode 100644 index 5d66b52f7..000000000 --- a/cde/programs/nsgmls/parseMode.C +++ /dev/null @@ -1,536 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: parseMode.C /main/1 1996/07/29 17:09:27 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#include "splib.h" -#include "Parser.h" -#include "ParserMessages.h" -#include "MessageArg.h" -#include "TokenMessageArg.h" -#include "ModeInfo.h" -#include "Partition.h" -#include "SrInfo.h" -#include "Vector.h" -#include "ISetIter.h" -#include "token.h" -#include "TrieBuilder.h" -#include "macros.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -enum { - modeUsedInSd = 01, - modeUsedInProlog = 02, - modeUsedInInstance = 04, - modeUsesSr = 010 -}; - -static struct { - Mode mode; - unsigned flags; -} modeTable[] = { - { grpMode, modeUsedInProlog|modeUsedInInstance }, - { alitMode, modeUsedInProlog|modeUsedInInstance }, - { alitaMode, modeUsedInProlog|modeUsedInInstance }, - { aliteMode, modeUsedInProlog|modeUsedInInstance }, - { talitMode, modeUsedInProlog|modeUsedInInstance }, - { talitaMode, modeUsedInProlog|modeUsedInInstance }, - { taliteMode, modeUsedInProlog|modeUsedInInstance }, - { mdMode, modeUsedInProlog|modeUsedInInstance|modeUsedInSd }, - { mdMinusMode, modeUsedInProlog }, - { mdPeroMode, modeUsedInProlog }, - { comMode, modeUsedInProlog|modeUsedInInstance }, - { sdcomMode, modeUsedInSd }, - { piMode, modeUsedInProlog|modeUsedInInstance }, - { refMode, modeUsedInProlog|modeUsedInInstance|modeUsedInSd }, - { imsMode, modeUsedInProlog|modeUsedInInstance }, - { cmsMode, modeUsedInProlog|modeUsedInInstance }, - { rcmsMode, modeUsedInProlog|modeUsedInInstance }, - { proMode, modeUsedInProlog }, - { dsMode, modeUsedInProlog }, - { dsiMode, modeUsedInProlog }, - { plitMode, modeUsedInProlog }, - { plitaMode, modeUsedInProlog }, - { pliteMode, modeUsedInProlog }, - { sdplitMode, modeUsedInSd }, - { sdplitaMode, modeUsedInSd }, - { grpsufMode, modeUsedInProlog }, - { mlitMode, modeUsedInProlog|modeUsedInSd }, - { mlitaMode, modeUsedInProlog|modeUsedInSd }, - { asMode, modeUsedInProlog }, - { slitMode, modeUsedInProlog }, - { slitaMode, modeUsedInProlog }, - { cconMode, modeUsedInInstance }, - { rcconMode, modeUsedInInstance }, - { cconnetMode, modeUsedInInstance }, - { rcconnetMode, modeUsedInInstance }, - { rcconeMode, modeUsedInInstance }, - { tagMode, modeUsedInInstance }, - { econMode, modeUsedInInstance|modeUsesSr }, - { mconMode, modeUsedInInstance|modeUsesSr }, - { econnetMode, modeUsedInInstance|modeUsesSr }, - { mconnetMode, modeUsedInInstance|modeUsesSr }, -}; - -void Parser::compileSdModes() -{ - Mode modes[nModes]; - int n = 0; - for (size_t i = 0; i < SIZEOF(modeTable); i++) - if (modeTable[i].flags & modeUsedInSd) - modes[n++] = modeTable[i].mode; - compileModes(modes, n, 0); -} - -void Parser::compilePrologModes() -{ - Boolean scopeInstance = sd().scopeInstance(); - Boolean haveSr = syntax().hasShortrefs(); - Mode modes[nModes]; - int n = 0; - for (size_t i = 0; i < SIZEOF(modeTable); i++) { - if (scopeInstance) { - if (modeTable[i].flags & modeUsedInProlog) - modes[n++] = modeTable[i].mode; - } - else if (haveSr) { - if ((modeTable[i].flags & (modeUsedInInstance|modeUsedInProlog)) - && !(modeTable[i].flags & modeUsesSr)) - modes[n++] = modeTable[i].mode; - } - else { - if (modeTable[i].flags & (modeUsedInInstance|modeUsedInProlog)) - modes[n++] = modeTable[i].mode; - } - } - compileModes(modes, n, 0); -} - -void Parser::compileInstanceModes() -{ - Boolean scopeInstance = sd().scopeInstance(); - compileNormalMap(); - if (!scopeInstance && !syntax().hasShortrefs()) - return; - Mode modes[nModes]; - int n = 0; - for (size_t i = 0; i < SIZEOF(modeTable); i++) { - if (scopeInstance) { - if (modeTable[i].flags & modeUsedInInstance) - modes[n++] = modeTable[i].mode; - } - else { - if (modeTable[i].flags & modeUsesSr) - modes[n++] = modeTable[i].mode; - } - } - compileModes(modes, n, ¤tDtd()); -} - -void Parser::compileModes(const Mode *modes, - int n, - const Dtd *dtd) -{ - PackedBoolean sets[Syntax::nSet]; - PackedBoolean delims[Syntax::nDelimGeneral]; - PackedBoolean functions[3]; - int i; - Boolean includesShortref = 0; - for (i = 0; i < Syntax::nSet; i++) - sets[i] = 0; - for (i = 0; i < Syntax::nDelimGeneral; i++) - delims[i] = 0; - for (i = 0; i < 3; i++) - functions[i] = 0; - - for (i = 0; i < n; i++) { - ModeInfo iter(modes[i], sd()); - TokenInfo ti; - while (iter.nextToken(&ti)) { - switch (ti.type) { - case TokenInfo::delimType: - delims[ti.delim1] = 1; - break; - case TokenInfo::delimDelimType: - delims[ti.delim1] = 1; - delims[ti.delim2] = 1; - break; - case TokenInfo::delimSetType: - delims[ti.delim1] = 1; - // fall through - case TokenInfo::setType: - sets[ti.set] = 1; - break; - case TokenInfo::functionType: - functions[ti.function] = 1; - break; - } - } - if (!includesShortref && iter.includesShortref()) - includesShortref = 1; - } - - ISet chars; - - for (i = 0; i < 3; i++) - if (functions[i]) - chars.add(syntax().standardFunction(i)); - for (i = 0; i < Syntax::nDelimGeneral; i++) - if (delims[i]) { - const StringC &str = syntax().delimGeneral(i); - for (size_t j = 0; j < str.size(); j++) - chars.add(str[j]); - } - if (includesShortref && dtd) { - size_t n = dtd->nShortref(); - for (size_t i = 0; i < n; i++) { - const StringC &delim = dtd->shortref(i); - size_t len = delim.size(); - for (size_t j = 0; j < len; j++) - if (delim[j] == sd().execToDoc('B')) - sets[Syntax::blank] = 1; - else - chars.add(delim[j]); - } - } - - const ISet *csets[Syntax::nSet]; - int usedSets = 0; - for (i = 0; i < Syntax::nSet; i++) - if (sets[i]) - csets[usedSets++] = syntax().charSet(i); - - Partition partition(chars, csets, usedSets, *syntax().generalSubstTable()); - - String setCodes[Syntax::nSet]; - - int nCodes = 0; - for (i = 0; i < Syntax::nSet; i++) - if (sets[i]) - setCodes[i] = partition.setCodes(nCodes++); - - String delimCodes[Syntax::nDelimGeneral]; - for (i = 0; i < Syntax::nDelimGeneral; i++) - if (delims[i]) { - StringC str = syntax().delimGeneral(i); - for (size_t j = 0; j < str.size(); j++) - delimCodes[i] += partition.charCode(str[j]); - } - - String functionCode[3]; - for (i = 0; i < 3; i++) - if (functions[i]) - functionCode[i] += partition.charCode(syntax().standardFunction(i)); - - Vector srInfo; - - int nShortref; - if (!includesShortref || !dtd) - nShortref = 0; - else { - nShortref = dtd->nShortref(); - srInfo.resize(nShortref); - - for (i = 0; i < nShortref; i++) { - const StringC delim = dtd->shortref(i); - SrInfo *p = &srInfo[i]; - size_t j; - for (j = 0; j < delim.size(); j++) { - if (delim[j] == sd().execToDoc('B')) - break; - p->chars += partition.charCode(delim[j]); - } - if (j < delim.size()) { - p->bSequenceLength = 1; - for (++j; j < delim.size(); j++) { - if (delim[j] != sd().execToDoc('B')) - break; - p->bSequenceLength += 1; - } - for (; j < delim.size(); j++) - p->chars2 += partition.charCode(delim[j]); - } - else - p->bSequenceLength = 0; - } - } - - const String emptyString; - Boolean multicode = syntax().multicode(); - for (i = 0; i < n; i++) { - TrieBuilder tb(partition.maxCode() + 1); - TrieBuilder::TokenVector ambiguities; - Vector suppressTokens; - if (multicode) { - suppressTokens.assign(partition.maxCode() + 1, 0); - suppressTokens[partition.eECode()] = tokenEe; - } - tb.recognizeEE(partition.eECode(), tokenEe); - ModeInfo iter(modes[i], sd()); - TokenInfo ti; - // We try to handle the possibility that some delimiters may be empty; - // this might happen when compiling recognizers for the SGML declaration. - while (iter.nextToken(&ti)) { - switch (ti.type) { - case TokenInfo::delimType: - if (delimCodes[ti.delim1].size() > 0) - tb.recognize(delimCodes[ti.delim1], ti.token, - ti.priority, ambiguities); - break; - case TokenInfo::delimDelimType: - { - String str(delimCodes[ti.delim1]); - if (str.size() > 0 && delimCodes[ti.delim2].size() > 0) { - str += delimCodes[ti.delim2]; - tb.recognize(str, ti.token, ti.priority, ambiguities); - } - } - break; - case TokenInfo::delimSetType: - if (delimCodes[ti.delim1].size() > 0) - tb.recognize(delimCodes[ti.delim1], setCodes[ti.set], - ti.token, ti.priority, ambiguities); - break; - case TokenInfo::setType: - tb.recognize(emptyString, setCodes[ti.set], ti.token, - ti.priority, ambiguities); - if (multicode) { - const String &equivCodes = setCodes[ti.set]; - for (size_t j = 0; j < equivCodes.size(); j++) - suppressTokens[equivCodes[j]] = ti.token; - } - break; - case TokenInfo::functionType: - tb.recognize(functionCode[ti.function], ti.token, - ti.priority, ambiguities); - if (multicode) - suppressTokens[functionCode[ti.function][0]] = ti.token; - break; - } - } - if (iter.includesShortref()) { - for (int j = 0; j < nShortref; j++) { - const SrInfo *p = &srInfo[j]; - if (p->bSequenceLength > 0) - tb.recognizeB(p->chars, p->bSequenceLength, - syntax().quantity(Syntax::qBSEQLEN), - setCodes[Syntax::blank], - p->chars2, tokenFirstShortref + j, - ambiguities); - else - tb.recognize(p->chars, tokenFirstShortref + j, - Priority::delim, ambiguities); - } - } - setRecognizer(modes[i], - (multicode - ? new Recognizer(tb.extractTrie(), partition.map(), - suppressTokens) - : new Recognizer(tb.extractTrie(), partition.map()))); - // FIXME give more information - for (size_t j = 0; j < ambiguities.size(); j += 2) - message(ParserMessages::lexicalAmbiguity, - TokenMessageArg(ambiguities[j], modes[i], syntaxPointer(), - sdPointer()), - TokenMessageArg(ambiguities[j + 1], modes[i], syntaxPointer(), - sdPointer())); - } -} - -void Parser::compileNormalMap() -{ - XcharMap map(0); - ISetIter sgmlCharIter(*syntax().charSet(Syntax::sgmlChar)); - Char min, max; - while (sgmlCharIter.next(min, max)) - map.setRange(min, max, 1); - ModeInfo iter(mconnetMode, sd()); - TokenInfo ti; - while (iter.nextToken(&ti)) { - switch (ti.type) { - case TokenInfo::delimType: - case TokenInfo::delimDelimType: - case TokenInfo::delimSetType: - { - Char c = syntax().delimGeneral(ti.delim1)[0]; - map.setChar(c, 0); - StringC str(syntax().generalSubstTable()->inverse(c)); - for (size_t i = 0; i < str.size(); i++) - map.setChar(str[i], 0); - } - break; - case TokenInfo::setType: - if (ti.token != tokenChar) { - ISetIter setIter(*syntax().charSet(ti.set)); - Char min, max; - while (setIter.next(min, max)) - map.setRange(min, max, 0); - } - break; - case TokenInfo::functionType: - if (ti.token != tokenChar) - map.setChar(syntax().standardFunction(ti.function), 0); - break; - } - } - int nShortref = currentDtd().nShortref(); - for (int i = 0; i < nShortref; i++) { - Char c = currentDtd().shortref(i)[0]; - if (c == sd().execToDoc('B')) { - ISetIter setIter(*syntax().charSet(Syntax::blank)); - Char min, max; - while (setIter.next(min, max)) - map.setRange(min, max, 0); - } - else { - map.setChar(c, 0); - StringC str(syntax().generalSubstTable()->inverse(c)); - for (size_t j = 0; j < str.size(); j++) - map.setChar(str[j], 0); - } - } - setNormalMap(map); -} - -void Parser::addNeededShortrefs(Dtd &dtd, const Syntax &syntax) -{ - if (!syntax.hasShortrefs()) - return; - PackedBoolean delimRelevant[Syntax::nDelimGeneral]; - size_t i; - for (i = 0; i < Syntax::nDelimGeneral; i++) - delimRelevant[i] = 0; - ModeInfo iter(mconnetMode, sd()); - TokenInfo ti; - while (iter.nextToken(&ti)) { - switch (ti.type) { - case TokenInfo::delimType: - case TokenInfo::delimDelimType: - case TokenInfo::delimSetType: - delimRelevant[ti.delim1] = 1; - break; - default: - break; - } - } - - // PIO and NET are the only delimiters that are recognized in con - // mode without context. If a short reference delimiter is - // identical to one of these delimiters, then we'll have an - // ambiguity. We make such a short reference delimiter needed - // to ensure that this ambiguity is reported. - if (syntax.isValidShortref(syntax.delimGeneral(Syntax::dPIO))) - dtd.addNeededShortref(syntax.delimGeneral(Syntax::dPIO)); - if (syntax.isValidShortref(syntax.delimGeneral(Syntax::dNET))) - dtd.addNeededShortref(syntax.delimGeneral(Syntax::dNET)); - - size_t nShortrefComplex = syntax.nDelimShortrefComplex(); - - // A short reference delimiter is needed if it is used or if it can - // contains some other shorter delimiter that is either a relevant general - // delimiter or a shortref delimiter that is used. - - for (i = 0; i < nShortrefComplex; i++) { - size_t j; - for (j = 0; j < Syntax::nDelimGeneral; j++) - if (delimRelevant[j] - && shortrefCanPreemptDelim(syntax.delimShortrefComplex(i), - syntax.delimGeneral(j), - 0, - syntax)) { - dtd.addNeededShortref(syntax.delimShortrefComplex(i)); - break; - } - for (j = 0; j < dtd.nShortref(); j++) - if (shortrefCanPreemptDelim(syntax.delimShortrefComplex(i), - dtd.shortref(j), - 1, - syntax)) { - dtd.addNeededShortref(syntax.delimShortrefComplex(i)); - break; - } - } - -} - -Boolean Parser::shortrefCanPreemptDelim(const StringC &sr, - const StringC &d, - Boolean dIsSr, - const Syntax &syntax) -{ - Char letterB = sd().execToDoc('B'); - for (size_t i = 0; i < sr.size(); i++) { - size_t j = 0; - size_t k = i; - for (;;) { - if (j == d.size()) - return 1; - if (k >= sr.size()) - break; - if (sr[k] == letterB) { - if (dIsSr && d[j] == letterB) { - j++; - k++; - } - else if (syntax.isB(d[j])) { - j++; - k++; - if (k == sr.size() || sr[k] != letterB) { - // it was the last B in the sequence - while (j < d.size() && syntax.isB(d[j])) - j++; - } - } - else - break; - } - else if (dIsSr && d[j] == letterB) { - if (syntax.isB(sr[k])) { - ++j; - ++k; - if (j < d.size() && d[j] != letterB) { - while (k < sr.size() && syntax.isB(sr[k])) - k++; - } - } - else - break; - } - else if (d[j] == sr[k]) { - j++; - k++; - } - else - break; - } - } - return 0; -} - -#ifdef SP_NAMESPACE -} -#endif diff --git a/cde/programs/nsgmls/parseParam.C b/cde/programs/nsgmls/parseParam.C deleted file mode 100644 index 5d321ae42..000000000 --- a/cde/programs/nsgmls/parseParam.C +++ /dev/null @@ -1,1001 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: parseParam.C /main/1 1996/07/29 17:09:31 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#include "splib.h" -#include "Parser.h" -#include "Param.h" -#include "Group.h" -#include "Markup.h" -#include "ParserMessages.h" -#include "MessageArg.h" -#include "TokenMessageArg.h" -#include "token.h" -#include "macros.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -Boolean Parser::parseParam(const AllowedParams &allow, - unsigned declInputLevel, - Param &parm) -{ - for (;;) { - Token token = getToken(allow.mainMode()); - switch (token) { - case tokenUnrecognized: - if (reportNonSgmlCharacter()) - break; - { - message(ParserMessages::markupDeclarationCharacter, - StringMessageArg(currentToken()), - AllowedParamsMessageArg(allow, syntaxPointer())); - } - return 0; - case tokenEe: - if (inputLevel() <= declInputLevel) { - message(ParserMessages::declarationLevel); - return 0; - } - if (currentMarkup()) - currentMarkup()->addEntityEnd(); - popInputStack(); - break; - case tokenCom: - if (!parseComment(comMode)) - return 0; - break; - case tokenDso: - if (!allow.dso()) { - paramInvalidToken(tokenDso, allow); - return 0; - } - if (currentMarkup()) - currentMarkup()->addDelim(Syntax::dDSO); - parm.type = Param::dso; - return 1; - case tokenGrpo: - if (currentMarkup()) - currentMarkup()->addDelim(Syntax::dGRPO); - switch (allow.group()) { - case Param::invalid: - paramInvalidToken(tokenGrpo, allow); - return 0; - case Param::modelGroup: - { - ModelGroup *group; - if (!parseModelGroup(1, declInputLevel, group, grpsufMode)) - return 0; - parm.type = Param::modelGroup; - parm.modelGroupPtr = group; - } - break; - case Param::nameGroup: - if (!parseNameGroup(declInputLevel, parm)) - return 0; - break; - case Param::nameTokenGroup: - if (!parseNameTokenGroup(declInputLevel, parm)) - return 0; - break; - default: - CANNOT_HAPPEN(); - } - parm.type = allow.group(); - return 1; - case tokenLita: - case tokenLit: - parm.type = allow.literal(); - parm.lita = token == tokenLita; - switch (allow.literal()) { - case Param::invalid: - paramInvalidToken(token, allow); - return 0; - case Param::minimumLiteral: - if (!parseMinimumLiteral(parm.lita, parm.literalText)) - return 0; - break; - case Param::attributeValueLiteral: - if (!parseAttributeValueLiteral(parm.lita, parm.literalText)) - return 0; - break; - case Param::tokenizedAttributeValueLiteral: - if (!parseTokenizedAttributeValueLiteral(parm.lita, parm.literalText)) - return 0; - break; - case Param::systemIdentifier: - if (!parseSystemIdentifier(parm.lita, parm.literalText)) - return 0; - break; - case Param::paramLiteral: - if (!parseParameterLiteral(parm.lita, parm.literalText)) - return 0; - break; - } - if (currentMarkup()) - currentMarkup()->addLiteral(parm.literalText); - return 1; - case tokenMdc: - if (!allow.mdc()) { - paramInvalidToken(tokenMdc, allow); - return 0; - } - if (inputLevel() > declInputLevel) - message(ParserMessages::parameterEntityNotEnded); - if (currentMarkup()) - currentMarkup()->addDelim(Syntax::dMDC); - parm.type = Param::mdc; - return 1; - case tokenMinus: - parm.type = Param::minus; - if (currentMarkup()) - currentMarkup()->addDelim(Syntax::dMINUS); - return 1; - case tokenMinusGrpo: - if (!allow.exclusions()) { - paramInvalidToken(tokenMinusGrpo, allow); - return 0; - } - if (currentMarkup()) { - currentMarkup()->addDelim(Syntax::dMINUS); - currentMarkup()->addDelim(Syntax::dGRPO); - } - parm.type = Param::exclusions; - return parseElementNameGroup(declInputLevel, parm); - case tokenPero: - parm.type = Param::pero; - if (currentMarkup()) - currentMarkup()->addDelim(Syntax::dPERO); - return 1; - case tokenPeroGrpo: - if (!inInstance()) - message(ParserMessages::peroGrpoProlog); - // fall through - case tokenPeroNameStart: - { - ConstPtr entity; - Ptr origin; - if (!parseEntityReference(1, token == tokenPeroGrpo, entity, origin)) - return 0; - if (!entity.isNull()) - entity->declReference(*this, origin); - } - break; - case tokenPlusGrpo: - if (!allow.inclusions()) { - paramInvalidToken(tokenPlusGrpo, allow); - return 0; - } - if (currentMarkup()) { - currentMarkup()->addDelim(Syntax::dPLUS); - currentMarkup()->addDelim(Syntax::dGRPO); - } - parm.type = Param::inclusions; - return parseElementNameGroup(declInputLevel, parm); - case tokenRni: - if (!allow.rni()) { - paramInvalidToken(tokenRni, allow); - return 0; - } - return parseIndicatedReservedName(allow, parm); - case tokenS: - if (currentMarkup()) - currentMarkup()->addS(currentChar()); - break; - case tokenNameStart: - switch (allow.nameStart()) { - case Param::invalid: - paramInvalidToken(tokenNameStart, allow); - return 0; - case Param::reservedName: - return parseReservedName(allow, parm); - case Param::name: - extendNameToken(syntax().namelen(), ParserMessages::nameLength); - parm.type = Param::name; - getCurrentToken(syntax().generalSubstTable(), parm.token); - if (currentMarkup()) - currentMarkup()->addName(currentInput()); - return 1; - case Param::entityName: - extendNameToken(syntax().namelen(), ParserMessages::nameLength); - parm.type = Param::entityName; - getCurrentToken(syntax().entitySubstTable(), parm.token); - if (currentMarkup()) - currentMarkup()->addName(currentInput()); - return 1; - case Param::paramEntityName: - extendNameToken(syntax().penamelen(), - ParserMessages::parameterEntityNameLength); - parm.type = Param::paramEntityName; - getCurrentToken(syntax().entitySubstTable(), parm.token); - if (currentMarkup()) - currentMarkup()->addName(currentInput()); - return 1; - case Param::attributeValue: - return parseAttributeValueParam(parm); - } - break; - case tokenDigit: - switch (allow.digit()) { - case Param::invalid: - paramInvalidToken(tokenDigit, allow); - return 0; - case Param::number: - extendNumber(syntax().namelen(), ParserMessages::numberLength); - parm.type = Param::number; - getCurrentToken(parm.token); - if (currentMarkup()) - currentMarkup()->addNumber(currentInput()); - return 1; - case Param::attributeValue: - return parseAttributeValueParam(parm); - } - break; - case tokenLcUcNmchar: - switch (allow.nmchar()) { - case Param::invalid: - paramInvalidToken(tokenLcUcNmchar, allow); - return 0; - case Param::attributeValue: - return parseAttributeValueParam(parm); - } - break; - default: - CANNOT_HAPPEN(); - } - } -} - -void Parser::paramInvalidToken(Token token, const AllowedParams &allow) -{ - message(ParserMessages::paramInvalidToken, - TokenMessageArg(token, allow.mainMode(), - syntaxPointer(), sdPointer()), - AllowedParamsMessageArg(allow, syntaxPointer())); -} - -Boolean Parser::parseGroupToken(const AllowedGroupTokens &allow, - unsigned nestingLevel, - unsigned declInputLevel, - unsigned groupInputLevel, - GroupToken >) -{ - for (;;) { - Token token = getToken(grpMode); - switch (token) { - case tokenEe: - if (inputLevel() <= groupInputLevel) { - message(ParserMessages::groupLevel); - if (inputLevel() <= declInputLevel) - return 0; - } - else - message(ParserMessages::groupEntityEnd); - if (currentMarkup()) - currentMarkup()->addEntityEnd(); - popInputStack(); - break; - case tokenPeroGrpo: - if (!inInstance()) - message(ParserMessages::peroGrpoProlog); - // fall through - case tokenPeroNameStart: - { - ConstPtr entity; - Ptr origin; - if (!parseEntityReference(1, token == tokenPeroGrpo, entity, origin)) - return 0; - if (!entity.isNull()) - entity->declReference(*this, origin); - } - break; - case tokenUnrecognized: - if (reportNonSgmlCharacter()) - break; - { - message(ParserMessages::groupCharacter, - StringMessageArg(currentToken()), - AllowedGroupTokensMessageArg(allow, syntaxPointer())); - } - return 0; - case tokenDtgo: - if (!allow.groupToken(GroupToken::dataTagGroup)) { - groupTokenInvalidToken(tokenDtgo, allow); - return 0; - } - if (sd().datatag()) - message(ParserMessages::datatagNotImplemented); - if (currentMarkup()) - currentMarkup()->addDelim(Syntax::dDTGO); - return parseDataTagGroup(nestingLevel + 1, declInputLevel, gt); - case tokenGrpo: - if (currentMarkup()) - currentMarkup()->addDelim(Syntax::dGRPO); - switch (allow.group()) { - case GroupToken::modelGroup: - { - ModelGroup *modelGroup; - if (!parseModelGroup(nestingLevel + 1, declInputLevel, modelGroup, - grpMode)) - return 0; - gt.model = modelGroup; - gt.type = GroupToken::modelGroup; - return 1; - } - case GroupToken::dataTagTemplateGroup: - return parseDataTagTemplateGroup(nestingLevel + 1, declInputLevel, gt); - default: - groupTokenInvalidToken(tokenGrpo, allow); - return 0; - } - break; - case tokenRni: - if (!allow.groupToken(GroupToken::pcdata)) { - groupTokenInvalidToken(tokenRni, allow); - return 0; - } - Syntax::ReservedName rn; - if (!getIndicatedReservedName(&rn)) - return 0; - if (rn != Syntax::rPCDATA) { - StringC token(syntax().delimGeneral(Syntax::dRNI)); - token += syntax().reservedName(Syntax::rPCDATA); - message(ParserMessages::invalidToken, StringMessageArg(token)); - return 0; - } - gt.type = GroupToken::pcdata; - gt.contentToken = new PcdataToken; - return 1; - case tokenS: - if (currentMarkup()) { - extendS(); - currentMarkup()->addS(currentInput()); - } - break; - case tokenNameStart: - switch (allow.nameStart()) { - case GroupToken::elementToken: - { - extendNameToken(syntax().namelen(), ParserMessages::nameLength); - gt.type = GroupToken::elementToken; - StringC &buffer = nameBuffer(); - getCurrentToken(syntax().generalSubstTable(), buffer); - if (currentMarkup()) - currentMarkup()->addName(currentInput()); - const ElementType *e = lookupCreateElement(buffer); - ContentToken::OccurrenceIndicator oi - = getOccurrenceIndicator(grpMode); - gt.contentToken = new ElementToken(e, oi); - return 1; - } - case GroupToken::name: - case GroupToken::nameToken: - extendNameToken(syntax().namelen(), - token == GroupToken::name - ? ParserMessages::nameLength - : ParserMessages::nameTokenLength); - getCurrentToken(syntax().generalSubstTable(), gt.token); - gt.type = allow.nameStart(); - if (currentMarkup()) { - if (gt.type == GroupToken::nameToken) - currentMarkup()->addNameToken(currentInput()); - else - currentMarkup()->addName(currentInput()); - } - return 1; - default: - groupTokenInvalidToken(tokenNameStart, allow); - return 0; - } - case tokenDigit: - case tokenLcUcNmchar: - if (!allow.groupToken(GroupToken::nameToken)) { - groupTokenInvalidToken(token, allow); - return 0; - } - extendNameToken(syntax().namelen(), ParserMessages::nameTokenLength); - getCurrentToken(syntax().generalSubstTable(), gt.token); - gt.type = GroupToken::nameToken; - if (currentMarkup()) - currentMarkup()->addNameToken(currentInput()); - return 1; - case tokenLit: - case tokenLita: - // parameter literal in data tag pattern - if (!allow.groupToken(GroupToken::dataTagLiteral)) { - groupTokenInvalidToken(token, allow); - return 0; - } - if (!parseDataTagParameterLiteral(token == tokenLita, gt.text)) - return 0; - gt.type = GroupToken::dataTagLiteral; - if (currentMarkup()) - currentMarkup()->addLiteral(gt.text); - return 1; - case tokenAnd: - case tokenSeq: - case tokenOr: - case tokenDtgc: - case tokenGrpc: - case tokenOpt: - case tokenPlus: - case tokenRep: - groupTokenInvalidToken(token, allow); - return 0; - } - } -} - - -void Parser::groupTokenInvalidToken(Token token, const AllowedGroupTokens &allow) -{ - message(ParserMessages::groupTokenInvalidToken, - TokenMessageArg(token, grpMode, syntaxPointer(), sdPointer()), - AllowedGroupTokensMessageArg(allow, syntaxPointer())); -} - - -Boolean Parser::parseGroupConnector(const AllowedGroupConnectors &allow, - unsigned declInputLevel, - unsigned groupInputLevel, - GroupConnector &gc) -{ - for (;;) { - Token token = getToken(grpMode); - switch (token) { - case tokenEe: - if (inputLevel() <= groupInputLevel) { - message(ParserMessages::groupLevel); - if (inputLevel() <= declInputLevel) - return 0; - } - if (currentMarkup()) - currentMarkup()->addEntityEnd(); - popInputStack(); - break; - case tokenS: - if (currentMarkup()) { - extendS(); - currentMarkup()->addS(currentInput()); - } - break; - case tokenPeroGrpo: - if (inInstance()) { - message(ParserMessages::peroGrpoProlog); - break; - } - // fall through - case tokenPeroNameStart: - message(ParserMessages::groupEntityReference); - break; - case tokenUnrecognized: - if (reportNonSgmlCharacter()) - break; - { - message(ParserMessages::groupCharacter, - StringMessageArg(currentToken()), - AllowedGroupConnectorsMessageArg(allow, syntaxPointer())); - } - return 0; - case tokenAnd: - if (!allow.groupConnector(GroupConnector::andGC)) { - groupConnectorInvalidToken(tokenAnd, allow); - return 0; - } - gc.type = GroupConnector::andGC; - if (currentMarkup()) - currentMarkup()->addDelim(Syntax::dAND); - return 1; - case tokenSeq: - if (!allow.groupConnector(GroupConnector::seqGC)) { - groupConnectorInvalidToken(tokenSeq, allow); - return 0; - } - gc.type = GroupConnector::seqGC; - if (currentMarkup()) - currentMarkup()->addDelim(Syntax::dSEQ); - return 1; - case tokenOr: - if (!allow.groupConnector(GroupConnector::orGC)) { - groupConnectorInvalidToken(tokenOr, allow); - return 0; - } - gc.type = GroupConnector::orGC; - if (currentMarkup()) - currentMarkup()->addDelim(Syntax::dOR); - return 1; - case tokenDtgc: - if (!allow.groupConnector(GroupConnector::dtgcGC)) { - groupConnectorInvalidToken(tokenDtgc, allow); - return 0; - } - gc.type = GroupConnector::dtgcGC; - if (inputLevel() > groupInputLevel) - message(ParserMessages::groupParameterEntityNotEnded); - if (currentMarkup()) - currentMarkup()->addDelim(Syntax::dDTGC); - return 1; - case tokenGrpc: - if (!allow.groupConnector(GroupConnector::grpcGC)) { - groupConnectorInvalidToken(tokenGrpc, allow); - return 0; - } - gc.type = GroupConnector::grpcGC; - if (inputLevel() > groupInputLevel) - message(ParserMessages::groupParameterEntityNotEnded); - if (currentMarkup()) - currentMarkup()->addDelim(Syntax::dGRPC); - return 1; - default: - groupConnectorInvalidToken(token, allow); - return 0; - } - } -} - -void Parser::groupConnectorInvalidToken(Token token, - const AllowedGroupConnectors &allow) -{ - message(ParserMessages::connectorInvalidToken, - TokenMessageArg(token, grpMode, syntaxPointer(), sdPointer()), - AllowedGroupConnectorsMessageArg(allow, syntaxPointer())); -} - -Boolean Parser::parseElementNameGroup(unsigned declInputLevel, Param &parm) -{ - if (!parseNameGroup(declInputLevel, parm)) - return 0; - parm.elementVector.resize(parm.nameTokenVector.size()); - for (size_t i = 0; i < parm.nameTokenVector.size(); i++) - parm.elementVector[i] = lookupCreateElement(parm.nameTokenVector[i].name); - return 1; -} - -Boolean Parser::parseEntityReferenceNameGroup(Boolean &ignore) -{ - Param parm; - if (!parseNameGroup(inputLevel(), parm)) - return 0; - if (inInstance()) { - for (size_t i = 0; i < parm.nameTokenVector.size(); i++) { - const Lpd *lpd = lookupLpd(parm.nameTokenVector[i].name).pointer(); - if (lpd && lpd->active()) { - ignore = 0; - return 1; - } - } - } - ignore = 1; - return 1; -} - -Boolean Parser::parseTagNameGroup(Boolean &active) -{ - Param parm; - if (!parseNameGroup(inputLevel(), parm)) - return 0; - active = 0; - return 1; -} - -Boolean Parser::parseNameGroup(unsigned declInputLevel, Param &parm) -{ - static AllowedGroupTokens allowName(GroupToken::name); - return parseGroup(allowName, declInputLevel, parm); -} - -Boolean Parser::parseNameTokenGroup(unsigned declInputLevel, Param &parm) -{ - static AllowedGroupTokens allowNameToken(GroupToken::nameToken); - return parseGroup(allowNameToken, declInputLevel, parm); -} - -static -Boolean groupContains(const Vector &vec, const StringC &str) -{ - for (size_t i = 0; i < vec.size(); i++) - if (vec[i].name == str) - return 1; - return 0; -} - -Boolean Parser::parseGroup(const AllowedGroupTokens &allowToken, - unsigned declInputLevel, - Param &parm) -{ - unsigned groupInputLevel = inputLevel(); - int nDuplicates = 0; - Vector &vec = parm.nameTokenVector; - vec.clear(); - GroupConnector::Type connector = GroupConnector::grpcGC; - GroupToken gt; - for (;;) { - if (!parseGroupToken(allowToken, 0, declInputLevel, groupInputLevel, gt)) - return 0; - if (groupContains(vec, gt.token)) { - nDuplicates++; - message(ParserMessages::duplicateGroupToken, - StringMessageArg(gt.token)); - } - else { - vec.resize(vec.size() + 1); - gt.token.swap(vec.back().name); - getCurrentToken(vec.back().origName); - vec.back().loc = currentLocation(); - } - GroupConnector gc; - static AllowedGroupConnectors allowAnyConnectorGrpc(GroupConnector::orGC, - GroupConnector::andGC, - GroupConnector::seqGC, - GroupConnector::grpcGC); - - if (!parseGroupConnector(allowAnyConnectorGrpc, declInputLevel, - groupInputLevel, gc)) - return 0; - if (gc.type == GroupConnector::grpcGC) - break; - if (connector == GroupConnector::grpcGC) - connector = gc.type; - else if (gc.type != connector) { - if (options().warnShould) - message(ParserMessages::mixedConnectors); - connector = gc.type; - } - } - if (nDuplicates + vec.size() > syntax().grpcnt()) - message(ParserMessages::groupCount, NumberMessageArg(syntax().grpcnt())); - return 1; -} - -Boolean Parser::parseDataTagGroup(unsigned nestingLevel, - unsigned declInputLevel, GroupToken &result) -{ - if (nestingLevel - 1 == syntax().grplvl()) - message(ParserMessages::grplvl, NumberMessageArg(syntax().grplvl())); - unsigned groupInputLevel = inputLevel(); - GroupToken gt; - static AllowedGroupTokens allowName(GroupToken::name); - if (!parseGroupToken(allowName, nestingLevel, declInputLevel, - groupInputLevel, gt)) - return 0; - const ElementType *element = lookupCreateElement(gt.token); - GroupConnector gc; - static AllowedGroupConnectors allowSeq(GroupConnector::seqGC); - if (!parseGroupConnector(allowSeq, declInputLevel, groupInputLevel, gc)) - return 0; - static AllowedGroupTokens - allowDataTagLiteralDataTagTemplateGroup(GroupToken::dataTagLiteral, - GroupToken::dataTagTemplateGroup); - if (!parseGroupToken(allowDataTagLiteralDataTagTemplateGroup, - nestingLevel, - declInputLevel, - groupInputLevel, - gt)) - return 0; - Vector templates; - if (gt.type == GroupToken::dataTagTemplateGroup) - gt.textVector.swap(templates); - else { - templates.resize(1); - gt.text.swap(templates[0]); - } - static AllowedGroupConnectors allowSeqDtgc(GroupConnector::seqGC, - GroupConnector::dtgcGC); - if (!parseGroupConnector(allowSeqDtgc, declInputLevel, groupInputLevel, gc)) - return 0; - NCVector > vec(2); - vec[1] = new PcdataToken; - if (gc.type != GroupConnector::dtgcGC) { - static AllowedGroupTokens allowDataTagLiteral(GroupToken::dataTagLiteral); - if (!parseGroupToken(allowDataTagLiteral, - nestingLevel, - declInputLevel, - groupInputLevel, - gt)) - return 0; - vec[0] = new DataTagElementToken(element, templates, gt.text); - static AllowedGroupConnectors allowDtgc(GroupConnector::dtgcGC); - if (!parseGroupConnector(allowDtgc, declInputLevel, groupInputLevel, gc)) - return 0; - } - else - vec[0] = new DataTagElementToken(element, templates); - ContentToken::OccurrenceIndicator oi = getOccurrenceIndicator(grpMode); - result.contentToken = new DataTagGroup(vec, oi); - result.type = GroupToken::dataTagGroup; - return 1; -} - -Boolean Parser::parseDataTagTemplateGroup(unsigned nestingLevel, - unsigned declInputLevel, - GroupToken &result) -{ - if (nestingLevel - 1 == syntax().grplvl()) - message(ParserMessages::grplvl, NumberMessageArg(syntax().grplvl())); - unsigned groupInputLevel = inputLevel(); - Vector &vec = result.textVector; - for (;;) { - GroupToken gt; - static AllowedGroupTokens allowDataTagLiteral(GroupToken::dataTagLiteral); - if (!parseGroupToken(allowDataTagLiteral, - nestingLevel, - declInputLevel, - groupInputLevel, - gt)) - return 0; - if (vec.size() == syntax().grpcnt()) - message(ParserMessages::groupCount, NumberMessageArg(syntax().grpcnt())); - vec.resize(vec.size() + 1); - gt.text.swap(vec.back()); - static AllowedGroupConnectors allowOrGrpc(GroupConnector::orGC, - GroupConnector::grpcGC); - GroupConnector gc; - if (!parseGroupConnector(allowOrGrpc, declInputLevel, groupInputLevel, gc)) - return 0; - if (gc.type == GroupConnector::grpcGC) - break; - } - return 1; -} - -Boolean Parser::parseModelGroup(unsigned nestingLevel, unsigned declInputLevel, - ModelGroup *&group, Mode oiMode) -{ - if (nestingLevel - 1 == syntax().grplvl()) - message(ParserMessages::grplvl, NumberMessageArg(syntax().grplvl())); - unsigned groupInputLevel = inputLevel(); - GroupToken gt; - NCVector > tokenVector; - GroupConnector::Type connector = GroupConnector::grpcGC; - - static AllowedGroupTokens allowContentToken(GroupToken::pcdata, - GroupToken::dataTagGroup, - GroupToken::elementToken, - GroupToken::modelGroup); - static AllowedGroupConnectors allowAnyConnectorGrpc(GroupConnector::orGC, - GroupConnector::andGC, - GroupConnector::seqGC, - GroupConnector::grpcGC); - - static AllowedGroupConnectors allowOrGrpc(GroupConnector::orGC, - GroupConnector::grpcGC); - static AllowedGroupConnectors allowAndGrpc(GroupConnector::andGC, - GroupConnector::grpcGC); - static AllowedGroupConnectors allowSeqGrpc(GroupConnector::seqGC, - GroupConnector::grpcGC); - const AllowedGroupConnectors *connectorp = &allowAnyConnectorGrpc; - - GroupConnector gc; - do { - if (!parseGroupToken(allowContentToken, nestingLevel, declInputLevel, - groupInputLevel, gt)) - return 0; - ContentToken *contentToken; - if (gt.type == GroupToken::modelGroup) - contentToken = gt.model.extract(); - else - contentToken = gt.contentToken.extract(); - if (tokenVector.size() == syntax().grpcnt()) - message(ParserMessages::groupCount, NumberMessageArg(syntax().grpcnt())); - tokenVector.resize(tokenVector.size() + 1); - tokenVector.back() = contentToken; - if (!parseGroupConnector(*connectorp, declInputLevel, groupInputLevel, gc)) - return 0; - if (tokenVector.size() == 1) { - connector = gc.type; - switch (gc.type) { - case GroupConnector::orGC: - connectorp = &allowOrGrpc; - break; - case GroupConnector::seqGC: - connectorp = &allowSeqGrpc; - break; - case GroupConnector::andGC: - connectorp = &allowAndGrpc; - break; - default: - break; - } - } - } while (gc.type != GroupConnector::grpcGC); - ContentToken::OccurrenceIndicator oi - = getOccurrenceIndicator(oiMode); - switch (connector) { - case GroupConnector::orGC: - group = new OrModelGroup(tokenVector, oi); - break; - case GroupConnector::grpcGC: - case GroupConnector::seqGC: - group = new SeqModelGroup(tokenVector, oi); - break; - case GroupConnector::andGC: - group = new AndModelGroup(tokenVector, oi); - break; - default: - break; - } - return 1; -} - -ContentToken::OccurrenceIndicator -Parser::getOccurrenceIndicator(Mode oiMode) -{ - Token token = getToken(oiMode); - switch (token) { - case tokenPlus: - if (currentMarkup()) - currentMarkup()->addDelim(Syntax::dPLUS); - return ContentToken::plus; - case tokenOpt: - if (currentMarkup()) - currentMarkup()->addDelim(Syntax::dOPT); - return ContentToken::opt; - case tokenRep: - if (currentMarkup()) - currentMarkup()->addDelim(Syntax::dREP); - return ContentToken::rep; - default: - currentInput()->ungetToken(); - return ContentToken::none; - } -} - -Boolean Parser::parseMinimumLiteral(Boolean lita, Text &text) -{ - return parseLiteral(lita ? mlitaMode : mlitMode, mlitMode, - Syntax::referenceQuantity(Syntax::qLITLEN), - ParserMessages::minimumLiteralLength, - literalSingleSpace|literalMinimumData - |(eventsWanted().wantPrologMarkup() - ? literalDelimInfo - : 0), - text); -} - -Boolean Parser::parseSystemIdentifier(Boolean lita, Text &text) -{ - return parseLiteral(lita ? slitaMode : slitMode, slitMode, syntax().litlen(), - ParserMessages::systemIdentifierLength, - (eventsWanted().wantPrologMarkup() - ? literalDelimInfo - : 0), text); -} - -Boolean Parser::parseParameterLiteral(Boolean lita, Text &text) -{ - return parseLiteral(lita ? plitaMode : plitMode, pliteMode, syntax().litlen(), - ParserMessages::parameterLiteralLength, - (eventsWanted().wantPrologMarkup() - ? literalDelimInfo - : 0), - text); -} - -Boolean Parser::parseDataTagParameterLiteral(Boolean lita, Text &text) -{ - return parseLiteral(lita ? plitaMode : plitMode, pliteMode, - syntax().dtemplen(), - ParserMessages::dataTagPatternLiteralLength, - literalDataTag - | (eventsWanted().wantPrologMarkup() - ? literalDelimInfo - : 0), - text); -} - -Boolean Parser::parseIndicatedReservedName(const AllowedParams &allow, - Param &parm) -{ - Syntax::ReservedName rn; - if (!getIndicatedReservedName(&rn)) - return 0; - if (!allow.reservedName(rn)) { - message(ParserMessages::invalidReservedName, - StringMessageArg(currentToken())); - return 0; - } - parm.type = Param::indicatedReservedName + rn; - return 1; -} - -Boolean Parser::parseReservedName(const AllowedParams &allow, - Param &parm) -{ - Syntax::ReservedName rn; - if (!getReservedName(&rn)) - return 0; - if (!allow.reservedName(rn)) { - message(ParserMessages::invalidReservedName, - StringMessageArg(syntax().reservedName(rn))); - return 0; - } - parm.type = Param::reservedName + rn; - return 1; -} - - -Boolean Parser::parseAttributeValueParam(Param &parm) -{ - extendNameToken(syntax().litlen() > syntax().normsep() - ? syntax().litlen() - syntax().normsep() - : 0, - ParserMessages::attributeValueLength); - parm.type = Param::attributeValue; - Text text; - text.addChars(currentInput()->currentTokenStart(), - currentInput()->currentTokenLength(), - currentLocation()); - text.swap(parm.literalText); - if (currentMarkup()) - currentMarkup()->addAttributeValue(currentInput()); - return 1; -} - -Boolean Parser::getIndicatedReservedName(Syntax::ReservedName *result) -{ - if (currentMarkup()) - currentMarkup()->addDelim(Syntax::dRNI); - InputSource *in = currentInput(); - in->startToken(); - if (!syntax().isNameStartCharacter(in->tokenChar(messenger()))) { - message(ParserMessages::rniNameStart); - return 0; - } - extendNameToken(syntax().namelen(), ParserMessages::nameLength); - StringC &buffer = nameBuffer(); - getCurrentToken(syntax().generalSubstTable(), buffer); - if (!syntax().lookupReservedName(buffer, result)) { - // Hack, hack - if (!options().errorAfdr && buffer == sd().execToDoc("ALL")) - *result = Syntax::rANY; - else { - message(ParserMessages::noSuchReservedName, StringMessageArg(buffer)); - return 0; - } - } - if (currentMarkup()) - currentMarkup()->addReservedName(*result, currentInput()); - return 1; -} - -Boolean Parser::getReservedName(Syntax::ReservedName *result) -{ - extendNameToken(syntax().namelen(), ParserMessages::nameLength); - StringC &buffer = nameBuffer(); - getCurrentToken(syntax().generalSubstTable(), buffer); - if (!syntax().lookupReservedName(buffer, result)) { - message(ParserMessages::noSuchReservedName, StringMessageArg(buffer)); - return 0; - } - if (currentMarkup()) - currentMarkup()->addReservedName(*result, currentInput()); - return 1; -} - - -#ifdef SP_NAMESPACE -} -#endif diff --git a/cde/programs/nsgmls/parseSd.C b/cde/programs/nsgmls/parseSd.C deleted file mode 100644 index efd8532e5..000000000 --- a/cde/programs/nsgmls/parseSd.C +++ /dev/null @@ -1,2843 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: parseSd.C /main/2 1996/08/12 15:47:30 mgreess $ */ -// Copyright (c) 1994, 1995 James Clark -// See the file COPYING for copying permission. - -#include "splib.h" -#include "Parser.h" -#include "macros.h" -#include "SdFormalError.h" -#include "MessageBuilder.h" -#include "ParserMessages.h" -#include "MessageArg.h" -#include "CharsetRegistry.h" -#include "ISetIter.h" -#include "token.h" -#include "TokenMessageArg.h" -#include "constant.h" -#include "SdText.h" -#include "NumericCharRefOrigin.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -class CharSwitcher { -public: - CharSwitcher(); - void addSwitch(WideChar from, WideChar to); - SyntaxChar subst(WideChar c); - size_t nSwitches() const; - Boolean switchUsed(size_t i) const; - WideChar switchFrom(size_t i) const; - WideChar switchTo(size_t i) const; -private: - Vector switchUsed_; - Vector switches_; -}; - -// Information about the SGML declaration being built. - -struct SdBuilder { - SdBuilder(); - void addFormalError(const Location &, const MessageType1 &, const StringC &); - Ptr sd; - Ptr syntax; - CharsetDecl syntaxCharsetDecl; - CharsetInfo syntaxCharset; - CharSwitcher switcher; - Boolean externalSyntax; - Boolean valid; - IList formalErrorList; -}; - -class CharsetMessageArg : public MessageArg { -public: - CharsetMessageArg(const ISet &set); - MessageArg *copy() const; - void append(MessageBuilder &) const; -private: - ISet set_; -}; - -struct SdParam { - typedef unsigned char Type; - enum { - invalid, - eE, - minimumLiteral, - mdc, - ellipsis, - number, - capacityName, - name, - paramLiteral, - generalDelimiterName, - referenceReservedName, - quantityName, - reservedName // Sd::ReservedName is added to this - }; - Type type; - StringC token; - Text literalText; - String paramLiteralText; - union { - Number n; - Sd::Capacity capacityIndex; - Syntax::Quantity quantityIndex; - Syntax::ReservedName reservedNameIndex; - Syntax::DelimGeneral delimGeneralIndex; - }; -}; - -class AllowedSdParams { -public: - AllowedSdParams(SdParam::Type, - SdParam::Type = SdParam::invalid, - SdParam::Type = SdParam::invalid, - SdParam::Type = SdParam::invalid, - SdParam::Type = SdParam::invalid, - SdParam::Type = SdParam::invalid); - Boolean param(SdParam::Type) const; - SdParam::Type get(int i) const; -private: - enum { maxAllow = 6 }; - SdParam::Type allow_[maxAllow]; -}; - -class AllowedSdParamsMessageArg : public MessageArg { -public: - AllowedSdParamsMessageArg(const AllowedSdParams &allow, - const ConstPtr &sd); - MessageArg *copy() const; - void append(MessageBuilder &) const; -private: - AllowedSdParams allow_; - ConstPtr sd_; -}; - -struct StandardSyntaxSpec { - struct AddedFunction { - const char *name; - Syntax::FunctionClass functionClass; - SyntaxChar syntaxChar; - }; - const AddedFunction *addedFunction; - size_t nAddedFunction; - Boolean shortref; -}; - -static StandardSyntaxSpec::AddedFunction coreFunctions[] = { - { "TAB", Syntax::cSEPCHAR, 9 }, -}; - -static StandardSyntaxSpec coreSyntax = { - coreFunctions, SIZEOF(coreFunctions), 0 -}; - -static StandardSyntaxSpec refSyntax = { - coreFunctions, SIZEOF(coreFunctions), 1 -}; - -void Parser::doInit() -{ - if (cancelled()) { - allDone(); - return; - } - // When document entity doesn't exist, don't give any errors - // other than the cannot open error. - if (currentInput()->get(messenger()) == InputSource::eE) { - if (currentInput()->accessError()) { - allDone(); - return; - } - } - else - currentInput()->ungetToken(); - const CharsetInfo &initCharset = sd().docCharset(); - ISet missing; - findMissingMinimum(initCharset, missing); - if (!missing.isEmpty()) { - message(ParserMessages::sdMissingCharacters, CharsetMessageArg(missing)); - giveUp(); - return; - } - Boolean found = 0; - StringC systemId; - if (scanForSgmlDecl(initCharset)) - found = 1; - else { - currentInput()->ungetToken(); - if (entityCatalog().sgmlDecl(initCharset, messenger(), systemId)) { - InputSource *in = entityManager().open(systemId, - initCharset, - new InputSourceOrigin, - 0, - messenger()); - if (in) { - pushInput(in); - if (scanForSgmlDecl(initCharset)) - found = 1; - else { - message(ParserMessages::badDefaultSgmlDecl); - popInputStack(); - } - } - } - } - if (found) { - if (startMarkup(eventsWanted().wantPrologMarkup(), currentLocation())) { - size_t nS = currentInput()->currentTokenLength() - 6; - for (size_t i = 0; i < nS; i++) - currentMarkup()->addS(currentInput()->currentTokenStart()[i]); - currentMarkup()->addDelim(Syntax::dMDO); - currentMarkup()->addSdReservedName(Sd::rSGML, - currentInput()->currentTokenStart() - + (currentInput()->currentTokenLength() - 4), - 4); - } - Syntax *syntaxp = new Syntax(sd()); - CharSwitcher switcher; - if (!setStandardSyntax(*syntaxp, refSyntax, sd().docCharset(), - switcher)) { - giveUp(); - delete syntaxp; - return; - } - syntaxp->implySgmlChar(sd().docCharset()); - setSyntax(syntaxp); - compileSdModes(); - ConstPtr refSd(sdPointer()); - ConstPtr refSyntax(syntaxPointer()); - if (!parseSgmlDecl()) { - giveUp(); - return; - } - // queue an SGML declaration event - eventHandler().sgmlDecl(new (eventAllocator()) - SgmlDeclEvent(sdPointer(), - syntaxPointer(), - instanceSyntaxPointer(), - refSd, - refSyntax, - currentInput()->nextIndex(), - systemId, - markupLocation(), - currentMarkup())); - if (inputLevel() == 2) { - // FIXME perhaps check for junk after SGML declaration - popInputStack(); - } - } - else { - if (!implySgmlDecl()) { - giveUp(); - return; - } - // queue an SGML declaration event - eventHandler().sgmlDecl(new (eventAllocator()) - SgmlDeclEvent(sdPointer(), - syntaxPointer())); - } - - // Now we have sd and syntax set up, prepare to parse the prolog. - compilePrologModes(); - setPhase(prologPhase); -} - -Boolean Parser::implySgmlDecl() -{ - Syntax *syntaxp = new Syntax(sd()); - const StandardSyntaxSpec *spec; - if (options().shortref) - spec = &refSyntax; - else - spec = &coreSyntax; - CharSwitcher switcher; - if (!setStandardSyntax(*syntaxp, *spec, sd().docCharset(), switcher)) { - delete syntaxp; - return 0; - } - syntaxp->implySgmlChar(sd().docCharset()); - for (int i = 0; i < Syntax::nQuantity; i++) - syntaxp->setQuantity(i, options().quantity[i]); - setSyntax(syntaxp); - return 1; -} - -Boolean Parser::setStandardSyntax(Syntax &syn, - const StandardSyntaxSpec &spec, - const CharsetInfo &docCharset, - CharSwitcher &switcher) -{ - static UnivCharsetDesc::Range syntaxCharsetRanges[] = { - { 0, 128, 0 }, - }; - static UnivCharsetDesc syntaxCharsetDesc(syntaxCharsetRanges, - SIZEOF(syntaxCharsetRanges)); - static CharsetInfo syntaxCharset(syntaxCharsetDesc); - - Boolean valid = 1; - if (!checkSwitches(switcher, syntaxCharset)) - valid = 0; - size_t i; - for (i = 0; i < switcher.nSwitches(); i++) - if (switcher.switchTo(i) >= 128) - message(ParserMessages::switchNotInCharset, - NumberMessageArg(switcher.switchTo(i))); - static const Char shunchar[] = { - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, - 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, - 127, 255 - }; - - for (i = 0; i < SIZEOF(shunchar); i++) - syn.addShunchar(shunchar[i]); - syn.setShuncharControls(); - static Syntax::StandardFunction standardFunctions[3] = { - Syntax::fRE, Syntax::fRS, Syntax::fSPACE - }; - static SyntaxChar functionChars[3] = { 13, 10, 32 }; - for (i = 0; i < 3; i++) { - Char docChar; - if (translateSyntax(switcher, - syntaxCharset, - docCharset, - functionChars[i], - docChar) - && checkNotFunction(syn, docChar)) - syn.setStandardFunction(standardFunctions[i], docChar); - else - valid = 0; - } - for (i = 0; i < spec.nAddedFunction; i++) { - Char docChar; - if (translateSyntax(switcher, - syntaxCharset, - docCharset, - spec.addedFunction[i].syntaxChar, - docChar) - && checkNotFunction(syn, docChar)) - syn.addFunctionChar(docCharset.execToDesc(spec.addedFunction[i].name), - spec.addedFunction[i].functionClass, - docChar); - else - valid = 0; - } - - static SyntaxChar nameChars[2] = { 45, 46 }; // '-' '.' - ISet nameCharSet; - for (i = 0; i < 2; i++) { - Char docChar; - if (translateSyntax(switcher, - syntaxCharset, - docCharset, - nameChars[i], - docChar)) - nameCharSet.add(docChar); - else - valid = 0; - } - if (!checkNmchars(nameCharSet, syn)) - valid = 0; - else - syn.addNameCharacters(nameCharSet); - syn.setNamecaseGeneral(1); - syn.setNamecaseEntity(0); - if (!setRefDelimGeneral(syn, syntaxCharset, docCharset, switcher)) - valid = 0; - setRefNames(syn, docCharset); - syn.enterStandardFunctionNames(); - if (spec.shortref - && !addRefDelimShortref(syn, syntaxCharset, docCharset, switcher)) - valid = 0; - return valid; -} - -Boolean Parser::setRefDelimGeneral(Syntax &syntax, - const CharsetInfo &syntaxCharset, - const CharsetInfo &docCharset, - CharSwitcher &switcher) -{ - // Column 3 from Figure 3 - static const char delims[][2] = { - { 38 }, - { 45, 45 }, - { 38, 35 }, - { 93 }, - { 91 }, - { 93 }, - { 91 }, - { 38 }, - { 60, 47 }, - { 41 }, - { 40 }, - { 34 }, - { 39 }, - { 62 }, - { 60, 33 }, - { 45 }, - { 93, 93 }, - { 47 }, - { 63 }, - { 124 }, - { 37 }, - { 62 }, - { 60, 63 }, - { 43 }, - { 59 }, - { 42 }, - { 35 }, - { 44 }, - { 60 }, - { 62 }, - { 61 }, - }; - Boolean valid = 1; - ISet missing; - for (int i = 0; i < Syntax::nDelimGeneral; i++) - if (syntax.delimGeneral(i).size() == 0) { - StringC delim; - size_t j; - for (j = 0; j < 2 && delims[i][j] != '\0'; j++) { - UnivChar univChar = translateUniv(delims[i][j], switcher, - syntaxCharset); - Char c; - if (univToDescCheck(docCharset, univChar, c)) - delim += c; - else { - missing += univChar; - valid = 0; - } - } - if (delim.size() == j) { - if (checkGeneralDelim(syntax, delim)) - syntax.setDelimGeneral(i, delim); - else - valid = 0; - } - } - if (!missing.isEmpty()) - message(ParserMessages::missingSignificant646, CharsetMessageArg(missing)); - return valid; -} - -void Parser::setRefNames(Syntax &syntax, const CharsetInfo &docCharset) -{ - static const char *const referenceNames[] = { - "ANY", - "ATTLIST", - "CDATA", - "CONREF", - "CURRENT", - "DEFAULT", - "DOCTYPE", - "ELEMENT", - "EMPTY", - "ENDTAG", - "ENTITIES", - "ENTITY", - "FIXED", - "ID", - "IDLINK", - "IDREF", - "IDREFS", - "IGNORE", - "IMPLIED", - "INCLUDE", - "INITIAL", - "LINK", - "LINKTYPE", - "MD", - "MS", - "NAME", - "NAMES", - "NDATA", - "NMTOKEN", - "NMTOKENS", - "NOTATION", - "NUMBER", - "NUMBERS", - "NUTOKEN", - "NUTOKENS", - "O", - "PCDATA", - "PI", - "POSTLINK", - "PUBLIC", - "RCDATA", - "RE", - "REQUIRED", - "RESTORE", - "RS", - "SDATA", - "SHORTREF", - "SIMPLE", - "SPACE", - "STARTTAG", - "SUBDOC", - "SYSTEM", - "TEMP", - "USELINK", - "USEMAP" - }; - - int i; - for (i = 0; i < Syntax::nNames; i++) { - StringC docName(docCharset.execToDesc(referenceNames[i])); - Syntax::ReservedName tem; - if (syntax.lookupReservedName(docName, &tem)) - message(ParserMessages::nameReferenceReservedName, - StringMessageArg(docName)); - if (syntax.reservedName(Syntax::ReservedName(i)).size() == 0) - syntax.setName(i, docName); - } -} - -Boolean Parser::addRefDelimShortref(Syntax &syntax, - const CharsetInfo &syntaxCharset, - const CharsetInfo &docCharset, - CharSwitcher &switcher) -{ - // Column 2 from Figure 4 - static const char delimShortref[][3] = { - { 9 }, - { 13 }, - { 10 }, - { 10, 66 }, - { 10, 13 }, - { 10, 66, 13 }, - { 66, 13 }, - { 32 }, - { 66, 66 }, - { 34 }, - { 35 }, - { 37 }, - { 39 }, - { 40 }, - { 41 }, - { 42 }, - { 43 }, - { 44 }, - { 45 }, - { 45, 45 }, - { 58 }, - { 59 }, - { 61 }, - { 64 }, - { 91 }, - { 93 }, - { 94 }, - { 95 }, - { 123 }, - { 124 }, - { 125 }, - { 126 }, - }; - ISet missing; - - for (size_t i = 0; i < SIZEOF(delimShortref); i++) { - StringC delim; - - size_t j; - for (j = 0; j < 3 && delimShortref[i][j] != '\0'; j++) { - Char c; - UnivChar univChar = translateUniv(delimShortref[i][j], switcher, - syntaxCharset); - if (univToDescCheck(docCharset, univChar, c)) - delim += c; - else - missing += univChar; - } - if (delim.size() == j) { - if (switcher.nSwitches() > 0 && syntax.isValidShortref(delim)) - message(ParserMessages::duplicateDelimShortref, - StringMessageArg(delim)); - else - syntax.addDelimShortref(delim, docCharset); - } - } - if (!missing.isEmpty()) - message(ParserMessages::missingSignificant646, CharsetMessageArg(missing)); - return 1; -} - -// Determine whether the document starts with an SGML declaration. -// There is no current syntax at this point. - -Boolean Parser::scanForSgmlDecl(const CharsetInfo &initCharset) -{ - Char rs; - if (!univToDescCheck(initCharset, UnivCharsetDesc::rs, rs)) - return 0; - Char re; - if (!univToDescCheck(initCharset, UnivCharsetDesc::re, re)) - return 0; - Char space; - if (!univToDescCheck(initCharset, UnivCharsetDesc::space, space)) - return 0; - Char tab; - if (!univToDescCheck(initCharset, UnivCharsetDesc::tab, tab)) - return 0; - InputSource *in = currentInput(); - Xchar c = in->get(messenger()); - while (c == rs || c == space || c == re || c == tab) - c = in->tokenChar(messenger()); - if (c != initCharset.execToDesc('<')) - return 0; - if (in->tokenChar(messenger()) != initCharset.execToDesc('!')) - return 0; - c = in->tokenChar(messenger()); - if (c != initCharset.execToDesc('S') - && c != initCharset.execToDesc('s')) - return 0; - c = in->tokenChar(messenger()); - if (c != initCharset.execToDesc('G') - && c != initCharset.execToDesc('g')) - return 0; - c = in->tokenChar(messenger()); - if (c != initCharset.execToDesc('M') - && c != initCharset.execToDesc('m')) - return 0; - c = in->tokenChar(messenger()); - if (c != initCharset.execToDesc('L') - && c != initCharset.execToDesc('l')) - return 0; - c = in->tokenChar(messenger()); - // Don't recognize this if SGML is followed by a name character. - if (c == InputSource::eE) - return 1; - in->endToken(in->currentTokenLength() - 1); - if (c == initCharset.execToDesc('-')) - return 0; - if (c == initCharset.execToDesc('.')) - return 0; - UnivChar univ; - if (!initCharset.descToUniv(c, univ)) - return 1; - if (UnivCharsetDesc::a <= univ && univ < UnivCharsetDesc::a + 26) - return 0; - if (UnivCharsetDesc::A <= univ && univ < UnivCharsetDesc::A + 26) - return 0; - if (UnivCharsetDesc::zero <= univ && univ < UnivCharsetDesc::zero + 10) - return 0; - return 1; -} - -void Parser::findMissingMinimum(const CharsetInfo &charset, - ISet &missing) -{ - Char to; - size_t i; - for (i = 0; i < 26; i++) { - if (!univToDescCheck(charset, UnivCharsetDesc::A + i, to)) - missing += UnivCharsetDesc::A + i; - if (!univToDescCheck(charset, UnivCharsetDesc::a + i, to)) - missing += UnivCharsetDesc::a + i; - } - for (i = 0; i < 10; i++) { - Char to; - if (!univToDescCheck(charset, UnivCharsetDesc::zero + i, to)) - missing += UnivCharsetDesc::zero + i; - } - static const UnivChar special[] = { - 39, 40, 41, 43, 44, 45, 46, 47, 58, 61, 63 - }; - - for (i = 0; i < SIZEOF(special); i++) - if (!univToDescCheck(charset, special[i], to)) - missing += special[i]; -} - - -Boolean Parser::parseSgmlDecl() -{ - SdParam parm; - SdBuilder sdBuilder; - - if (!parseSdParam(AllowedSdParams(SdParam::minimumLiteral), parm)) - return 0; - StringC version(sd().execToDoc("ISO 8879:1986")); - if (parm.literalText.string() != version) - message(ParserMessages::standardVersion, - StringMessageArg(parm.literalText.string())); - sdBuilder.sd = new Sd; - typedef Boolean (Parser::*SdParser)(SdBuilder &, SdParam &); - static SdParser parsers[] = { - &Parser::sdParseDocumentCharset, - &Parser::sdParseCapacity, - &Parser::sdParseScope, - &Parser::sdParseSyntax, - &Parser::sdParseFeatures, - &Parser::sdParseAppinfo, - }; - for (size_t i = 0; i < SIZEOF(parsers); i++) { - if (!(this->*(parsers[i]))(sdBuilder, parm)) - return 0; - if (!sdBuilder.valid) - return 0; - } - if (!parseSdParam(AllowedSdParams(SdParam::mdc), parm)) - return 0; - if (sdBuilder.sd->formal()) { - while (!sdBuilder.formalErrorList.empty()) { - SdFormalError *p = sdBuilder.formalErrorList.get(); - ParserState *state = this; // work around lcc 3.0 bug - p->send(*state); - delete p; - } - } - setSd(sdBuilder.sd.pointer()); - if (sdBuilder.sd->scopeInstance()) { - Syntax *proSyntax = new Syntax(sd()); - CharSwitcher switcher; - setStandardSyntax(*proSyntax, refSyntax, sd().docCharset(), switcher); - proSyntax->setSgmlChar(*sdBuilder.syntax->charSet(Syntax::sgmlChar)); - ISet invalidSgmlChar; - proSyntax->checkSgmlChar(sdBuilder.sd->docCharset(), - sdBuilder.syntax.pointer(), - invalidSgmlChar); - sdBuilder.syntax->checkSgmlChar(sdBuilder.sd->docCharset(), - proSyntax, - invalidSgmlChar); - if (!invalidSgmlChar.isEmpty()) - message(ParserMessages::invalidSgmlChar, CharsetMessageArg(invalidSgmlChar)); - setSyntaxes(proSyntax, sdBuilder.syntax.pointer()); - } - else - setSyntax(sdBuilder.syntax.pointer()); - if (syntax().multicode()) - currentInput()->setMarkupScanTable(syntax().markupScanTable()); - return 1; -} - -Boolean Parser::sdParseDocumentCharset(SdBuilder &sdBuilder, SdParam &parm) -{ - if (!parseSdParam(AllowedSdParams(SdParam::reservedName + Sd::rCHARSET), - parm)) - return 0; - if (!parseSdParam(AllowedSdParams(SdParam::reservedName + Sd::rBASESET), - parm)) - return 0; - CharsetDecl decl; - UnivCharsetDesc desc; - if (!sdParseCharset(sdBuilder, parm, 1, decl, desc)) - return 0; - ISet missing; - findMissingMinimum(desc, missing); - if (!missing.isEmpty()) { - message(ParserMessages::missingMinimumChars, - CharsetMessageArg(missing)); - return 0; - } - ISet sgmlChar; - decl.usedSet(sgmlChar); - sdBuilder.sd->setDocCharsetDesc(desc); - sdBuilder.sd->setDocCharsetDecl(decl); - sdBuilder.syntax = new Syntax(*sdBuilder.sd); - sdBuilder.syntax->setSgmlChar(sgmlChar); - return 1; -} - -Boolean Parser::sdParseCharset(SdBuilder &sdBuilder, - SdParam &parm, - Boolean isDocument, - CharsetDecl &decl, - UnivCharsetDesc &desc) -{ - decl.clear(); - ISet multiplyDeclared; - // This is for checking whether the syntax reference character set - // is ISO 646 when SCOPE is INSTANCE. - Boolean maybeISO646 = 1; - do { - if (!parseSdParam(AllowedSdParams(SdParam::minimumLiteral), parm)) - return 0; - UnivCharsetDesc baseDesc; - PublicId id; - Boolean found; - PublicId::TextClass textClass; - const MessageType1 *err; - if (!id.init(parm.literalText, sd().docCharset(), syntax().space(), err)) - sdBuilder.addFormalError(currentLocation(), - *err, - id.string()); - else if (id.getTextClass(textClass) - && textClass != PublicId::CHARSET) - sdBuilder.addFormalError(currentLocation(), - ParserMessages::basesetTextClass, - id.string()); - Boolean givenError; - if (referencePublic(id, PublicId::CHARSET, givenError)) - found = sdParseExternalCharset(*sdBuilder.sd, baseDesc); - else if (!givenError) { - found = CharsetRegistry::findCharset(id, sd().docCharset(), baseDesc); - if (!found && options().warnSgmlDecl) - message(ParserMessages::unknownBaseset, StringMessageArg(id.string())); - } - else - found = 0; - if (!found) - maybeISO646 = 0; - decl.addSection(id); - if (!parseSdParam(AllowedSdParams(SdParam::reservedName + Sd::rDESCSET), - parm)) - return 0; - if (!parseSdParam(AllowedSdParams(SdParam::number), parm)) - return 0; - do { - WideChar min = parm.n; - if (!parseSdParam(AllowedSdParams(SdParam::number), parm)) - return 0; - Number count = parm.n; - Number adjCount; - if (options().warnSgmlDecl && count == 0) - message(ParserMessages::zeroNumberOfCharacters); - decl.rangeDeclared(min, count, multiplyDeclared); - if (isDocument - && count > 0 - && (min > charMax || count - 1 > charMax - min)) { - message(ParserMessages::documentCharMax, NumberMessageArg(charMax)); - adjCount = min > charMax ? 0 : 1 + (charMax - min); - sdBuilder.valid = 0; - maybeISO646 = 0; - } - else - adjCount = count; - if (!parseSdParam(AllowedSdParams(SdParam::number, - SdParam::minimumLiteral, - SdParam::reservedName + Sd::rUNUSED), - parm)) - return 0; - switch (parm.type) { - case SdParam::number: - decl.addRange(min, count, parm.n); - if (found && adjCount > 0) { - ISet baseMissing; - desc.addBaseRange(baseDesc, min, min + (adjCount - 1), parm.n, - baseMissing); - if (!baseMissing.isEmpty() && options().warnSgmlDecl) - message(ParserMessages::basesetCharsMissing, - CharsetMessageArg(baseMissing)); - } - break; - case SdParam::reservedName + Sd::rUNUSED: - decl.addRange(min, count); - break; - case SdParam::minimumLiteral: - { - UnivChar c = sdBuilder.sd->nameToUniv(parm.literalText.string()); - if (adjCount > 256) { - message(ParserMessages::tooManyCharsMinimumLiteral); - adjCount = 256; - } - for (Number i = 0; i < adjCount; i++) - desc.addRange(min + i, min + i, c); - } - maybeISO646 = 0; - decl.addRange(min, count, parm.literalText.string()); - break; - default: - CANNOT_HAPPEN(); - } - SdParam::Type follow = (isDocument - ? SdParam::reservedName + Sd::rCAPACITY - : SdParam::reservedName + Sd::rFUNCTION); - if (!parseSdParam(AllowedSdParams(SdParam::number, - SdParam::reservedName + Sd::rBASESET, - follow), - parm)) - return 0; - - } while (parm.type == SdParam::number); - } while (parm.type == SdParam::reservedName + Sd::rBASESET); - if (!multiplyDeclared.isEmpty()) - message(ParserMessages::duplicateCharNumbers, - CharsetMessageArg(multiplyDeclared)); - ISet declaredSet; - decl.declaredSet(declaredSet); - ISetIter iter(declaredSet); - WideChar min, max, lastMax; - if (iter.next(min, max)) { - ISet holes; - lastMax = max; - while (iter.next(min, max)) { - if (min - lastMax > 1) - holes.addRange(lastMax + 1, min - 1); - lastMax = max; - } - if (!holes.isEmpty()) - message(ParserMessages::codeSetHoles, CharsetMessageArg(holes)); - } - if (!isDocument && sdBuilder.sd->scopeInstance()) { - // If scope is INSTANCE, syntax reference character set - // must be same as reference. - UnivCharsetDescIter iter(desc); - WideChar descMin, descMax; - UnivChar univMin; - if (!iter.next(descMin, descMax, univMin) - || descMin != 0 - || descMax != 127 - || univMin != 0 - || !maybeISO646) - message(ParserMessages::scopeInstanceSyntaxCharset); - } - return 1; -} - -Boolean Parser::sdParseExternalCharset(Sd &sd, UnivCharsetDesc &desc) -{ - SdParam parm; - for (;;) { - if (!parseSdParam(AllowedSdParams(SdParam::number, SdParam::eE), - parm)) - break; - if (parm.type == SdParam::eE) - return 1; - WideChar min = parm.n; - if (!parseSdParam(AllowedSdParams(SdParam::number), parm)) - break; - Number count = parm.n; - if (!parseSdParam(AllowedSdParams(SdParam::number, - SdParam::minimumLiteral, - SdParam::reservedName + Sd::rUNUSED), - parm)) - break; - if (parm.type == SdParam::number) { - if (count > 0) - desc.addRange(min, min + (count - 1), parm.n); - } - else if (parm.type == SdParam::minimumLiteral) { - UnivChar c = sd.nameToUniv(parm.literalText.string()); - if (count > 256) { - message(ParserMessages::tooManyCharsMinimumLiteral); - count = 256; - } - for (Number i = 0; i < count; i++) - desc.addRange(min + i, min + i, c); - } - } - popInputStack(); - return 0; -} - -Boolean Parser::sdParseCapacity(SdBuilder &sdBuilder, SdParam &parm) -{ - if (!parseSdParam(AllowedSdParams(SdParam::reservedName + Sd::rPUBLIC, - SdParam::reservedName + Sd::rSGMLREF), - parm)) - return 0; - Boolean pushed = 0; - if (parm.type == SdParam::reservedName + Sd::rPUBLIC) { - if (!parseSdParam(AllowedSdParams(SdParam::minimumLiteral), parm)) - return 0; - PublicId id; - PublicId::TextClass textClass; - const MessageType1 *err; - if (!id.init(parm.literalText, sd().docCharset(), syntax().space(), err)) - sdBuilder.addFormalError(currentLocation(), - *err, - id.string()); - else if (id.getTextClass(textClass) - && textClass != PublicId::CAPACITY) - sdBuilder.addFormalError(currentLocation(), - ParserMessages::capacityTextClass, - id.string()); - const StringC &str = id.string(); - if (str != sd().execToDoc("ISO 8879-1986//CAPACITY Reference//EN") - && str != sd().execToDoc("ISO 8879:1986//CAPACITY Reference//EN")) { - Boolean givenError; - if (referencePublic(id, PublicId::CAPACITY, givenError)) - pushed = 1; - else if (!givenError) - message(ParserMessages::unknownCapacitySet, StringMessageArg(str)); - } - if (!pushed) - return parseSdParam(AllowedSdParams(SdParam::reservedName + Sd::rSCOPE), - parm); - } - - PackedBoolean capacitySpecified[Sd::nCapacity]; - int i; - for (i = 0; i < Sd::nCapacity; i++) - capacitySpecified[i] = 0; - if (!parseSdParam(AllowedSdParams(SdParam::capacityName), parm)) - return 0; - do { - Sd::Capacity capacityIndex = parm.capacityIndex; - if (!parseSdParam(AllowedSdParams(SdParam::number), parm)) - return 0; - - if (!capacitySpecified[capacityIndex]) { - sdBuilder.sd->setCapacity(capacityIndex, parm.n); - capacitySpecified[capacityIndex] = 1; - } - else if (options().warnSgmlDecl) - message(ParserMessages::duplicateCapacity, - StringMessageArg(sd().capacityName(i))); - int final = pushed ? int(SdParam::eE) : SdParam::reservedName + Sd::rSCOPE; - if (!parseSdParam(AllowedSdParams(SdParam::capacityName, final), - parm)) - return 0; - } while (parm.type == SdParam::capacityName); - Number totalcap = sdBuilder.sd->capacity(0); - for (i = 1; i < Sd::nCapacity; i++) - if (sdBuilder.sd->capacity(i) > totalcap) - message(ParserMessages::capacityExceedsTotalcap, - StringMessageArg(sd().capacityName(i))); - if (pushed) - return parseSdParam(AllowedSdParams(SdParam::reservedName + Sd::rSCOPE), - parm); - return 1; -} - -Boolean Parser::referencePublic(const PublicId &id, - PublicId::TextClass entityType, - Boolean &givenError) -{ - givenError = 0; - StringC sysid; - if (entityCatalog().lookupPublic(id.string(), - sd().docCharset(), - messenger(), - sysid)) { - Location loc = currentLocation(); - eventHandler().sgmlDeclEntity(new (eventAllocator()) - SgmlDeclEntityEvent(id, - entityType, - sysid, - loc)); - Ptr origin(new EntityOrigin(loc)); - if (currentMarkup()) - currentMarkup()->addEntityStart(origin); - InputSource *in = entityManager().open(sysid, - sd().docCharset(), - origin.pointer(), - 0, - messenger()); - if (!in) { - givenError = 1; - return 0; - } - pushInput(in); - return 1; - } - return 0; -} - -Boolean Parser::sdParseScope(SdBuilder &sdBuilder, SdParam &parm) -{ - if (!parseSdParam(AllowedSdParams(SdParam::reservedName + Sd::rINSTANCE, - SdParam::reservedName + Sd::rDOCUMENT), - parm)) - return 0; - if (parm.type == SdParam::reservedName + Sd::rINSTANCE) - sdBuilder.sd->setScopeInstance(); - return 1; -} - -Boolean Parser::sdParseSyntax(SdBuilder &sdBuilder, SdParam &parm) -{ - if (!parseSdParam(AllowedSdParams(SdParam::reservedName + Sd::rSYNTAX), - parm)) - return 0; - if (!parseSdParam(AllowedSdParams(SdParam::reservedName + Sd::rSHUNCHAR, - SdParam::reservedName + Sd::rPUBLIC), - parm)) - return 0; - - if (parm.type == SdParam::reservedName + Sd::rPUBLIC) { - if (!parseSdParam(AllowedSdParams(SdParam::minimumLiteral), parm)) - return 0; - PublicId id; - const MessageType1 *err; - PublicId::TextClass textClass; - if (!id.init(parm.literalText, sd().docCharset(), syntax().space(), err)) - sdBuilder.addFormalError(currentLocation(), - *err, - id.string()); - else if (id.getTextClass(textClass) - && textClass != PublicId::SYNTAX) - sdBuilder.addFormalError(currentLocation(), - ParserMessages::syntaxTextClass, - id.string()); - if (!parseSdParam(AllowedSdParams(SdParam::reservedName + Sd::rFEATURES, - SdParam::reservedName + Sd::rSWITCHES), - parm)) - return 0; - Vector charSwitches; - if (parm.type == SdParam::reservedName + Sd::rSWITCHES) { - if (!parseSdParam(AllowedSdParams(SdParam::number), parm)) - return 0; - for (;;) { - SyntaxChar c = parm.n; - if (!parseSdParam(AllowedSdParams(SdParam::number), parm)) - return 0; - sdBuilder.switcher.addSwitch(c, parm.n); - if (!parseSdParam(AllowedSdParams(SdParam::number, - SdParam::reservedName - + Sd::rFEATURES), - parm)) - return 0; - if (parm.type != SdParam::number) - break; - } - } - const StandardSyntaxSpec *spec = lookupSyntax(id); - if (spec) { - if (!setStandardSyntax(*sdBuilder.syntax, - *spec, - sdBuilder.sd->docCharset(), - sdBuilder.switcher)) - sdBuilder.valid = 0; - } - else { - Boolean givenError; - if (referencePublic(id, PublicId::SYNTAX, givenError)) { - sdBuilder.externalSyntax = 1; - SdParam parm2; - if (!parseSdParam(AllowedSdParams(SdParam::reservedName - + Sd::rSHUNCHAR), - parm2)) - return 0; - if (!sdParseExplicitSyntax(sdBuilder, parm2)) - return 0; - } - else { - if (!givenError) - message(ParserMessages::unknownPublicSyntax, - StringMessageArg(id.string())); - sdBuilder.valid = 0; - } - } - } - else { - if (!sdParseExplicitSyntax(sdBuilder, parm)) - return 0; - } - if (!sdBuilder.sd->scopeInstance()) { - // we know the significant chars now - ISet invalidSgmlChar; - sdBuilder.syntax->checkSgmlChar(sdBuilder.sd->docCharset(), - 0, - invalidSgmlChar); - if (!invalidSgmlChar.isEmpty()) - message(ParserMessages::invalidSgmlChar, CharsetMessageArg(invalidSgmlChar)); - } - checkSyntaxNamelen(*sdBuilder.syntax); - checkSwitchesMarkup(sdBuilder.switcher); - return 1; -} - -Boolean Parser::sdParseExplicitSyntax(SdBuilder &sdBuilder, - SdParam &parm) -{ - typedef Boolean (Parser::*SdParser)(SdBuilder &, SdParam &); - static SdParser parsers[] = { - &Parser::sdParseShunchar, - &Parser::sdParseSyntaxCharset, - &Parser::sdParseFunction, - &Parser::sdParseNaming, - &Parser::sdParseDelim, - &Parser::sdParseNames, - &Parser::sdParseQuantity - }; - for (size_t i = 0; i < SIZEOF(parsers); i++) - if (!(this->*(parsers[i]))(sdBuilder, parm)) - return 0; - return 1; -} - -const StandardSyntaxSpec *Parser::lookupSyntax(const PublicId &id) -{ - PublicId::OwnerType ownerType; - if (!id.getOwnerType(ownerType) || ownerType != PublicId::ISO) - return 0; - StringC str; - if (!id.getOwner(str)) - return 0; - if (str != sd().execToDoc("ISO 8879:1986") - && str != sd().execToDoc("ISO 8879-1986")) - return 0; - PublicId::TextClass textClass; - if (!id.getTextClass(textClass) || textClass != PublicId::SYNTAX) - return 0; - if (!id.getDescription(str)) - return 0; - if (str == sd().execToDoc("Reference")) - return &refSyntax; - if (str == sd().execToDoc("Core")) - return &coreSyntax; - return 0; -} - -Boolean Parser::sdParseSyntaxCharset(SdBuilder &sdBuilder, SdParam &parm) -{ - UnivCharsetDesc desc; - if (!sdParseCharset(sdBuilder, parm, 0, sdBuilder.syntaxCharsetDecl, desc)) - return 0; - sdBuilder.syntaxCharset.set(desc); - checkSwitches(sdBuilder.switcher, sdBuilder.syntaxCharset); - for (size_t i = 0; i < sdBuilder.switcher.nSwitches(); i++) - if (!sdBuilder.syntaxCharsetDecl.charDeclared(sdBuilder.switcher.switchTo(i))) - message(ParserMessages::switchNotInCharset, - NumberMessageArg(sdBuilder.switcher.switchTo(i))); - ISet missing; - findMissingMinimum(sdBuilder.syntaxCharset, missing); - if (!missing.isEmpty()) - message(ParserMessages::missingMinimumChars, - CharsetMessageArg(missing)); - return 1; -} - -Boolean Parser::sdParseShunchar(SdBuilder &sdBuilder, SdParam &parm) -{ - if (!parseSdParam(AllowedSdParams(SdParam::reservedName + Sd::rNONE, - SdParam::reservedName + Sd::rCONTROLS, - SdParam::number), parm)) - return 0; - if (parm.type == SdParam::reservedName + Sd::rNONE) { - if (!parseSdParam(AllowedSdParams(SdParam::reservedName + Sd::rBASESET), - parm)) - return 0; - return 1; - } - if (parm.type == SdParam::reservedName + Sd::rCONTROLS) - sdBuilder.syntax->setShuncharControls(); - else { - if (parm.n <= charMax) - sdBuilder.syntax->addShunchar(Char(parm.n)); - } - for (;;) { - if (!parseSdParam(AllowedSdParams(SdParam::reservedName + Sd::rBASESET, - SdParam::number), parm)) - return 0; - if (parm.type != SdParam::number) - break; - if (parm.n <= charMax) - sdBuilder.syntax->addShunchar(Char(parm.n)); - } - return 1; -} - -Boolean Parser::sdParseFunction(SdBuilder &sdBuilder, SdParam &parm) -{ - static Sd::ReservedName standardNames[3] = { - Sd::rRE, Sd::rRS, Sd::rSPACE - }; - for (int i = 0; i < 3; i++) { - if (!parseSdParam(AllowedSdParams(SdParam::reservedName - + standardNames[i]), - parm)) - return 0; - if (!parseSdParam(AllowedSdParams(SdParam::number), parm)) - return 0; - Char c; - if (translateSyntax(sdBuilder, parm.n, c)) { - if (checkNotFunction(*sdBuilder.syntax, c)) - sdBuilder.syntax->setStandardFunction(Syntax::StandardFunction(i), c); - else - sdBuilder.valid = 0; - } - } - Boolean haveMsichar = 0; - Boolean haveMsochar = 0; - for (;;) { - if (!parseSdParam(sdBuilder.externalSyntax - ? AllowedSdParams(SdParam::name, SdParam::paramLiteral) - : AllowedSdParams(SdParam::name), - parm)) - return 0; - Boolean nameWasLiteral; - Boolean invalidName = 0; - StringC name; - if (parm.type == SdParam::paramLiteral) { - nameWasLiteral = 1; - if (!translateSyntax(sdBuilder, parm.paramLiteralText, name)) - invalidName = 1; - } - else { - parm.token.swap(name); - nameWasLiteral = 0; - } - if (!parseSdParam(nameWasLiteral - ? AllowedSdParams(SdParam::reservedName + Sd::rFUNCHAR, - SdParam::reservedName + Sd::rMSICHAR, - SdParam::reservedName + Sd::rMSOCHAR, - SdParam::reservedName + Sd::rMSSCHAR, - SdParam::reservedName + Sd::rSEPCHAR) - : AllowedSdParams(SdParam::reservedName + Sd::rFUNCHAR, - SdParam::reservedName + Sd::rMSICHAR, - SdParam::reservedName + Sd::rMSOCHAR, - SdParam::reservedName + Sd::rMSSCHAR, - SdParam::reservedName + Sd::rSEPCHAR, - SdParam::reservedName + Sd::rLCNMSTRT), - parm)) - return 0; - if (parm.type == SdParam::reservedName + Sd::rLCNMSTRT) { - if (name != sd().reservedName(Sd::rNAMING)) - message(ParserMessages::namingBeforeLcnmstrt, - StringMessageArg(name)); - break; - } - if (!nameWasLiteral) { - StringC tem; - name.swap(tem); - if (!translateName(sdBuilder, tem, name)) - invalidName = 1; - } - Syntax::FunctionClass functionClass; - switch (parm.type) { - case SdParam::reservedName + Sd::rFUNCHAR: - functionClass = Syntax::cFUNCHAR; - break; - case SdParam::reservedName + Sd::rMSICHAR: - haveMsichar = 1; - functionClass = Syntax::cMSICHAR; - break; - case SdParam::reservedName + Sd::rMSOCHAR: - haveMsochar = 1; - functionClass = Syntax::cMSOCHAR; - break; - case SdParam::reservedName + Sd::rMSSCHAR: - functionClass = Syntax::cMSSCHAR; - break; - case SdParam::reservedName + Sd::rSEPCHAR: - functionClass = Syntax::cSEPCHAR; - break; - default: - CANNOT_HAPPEN(); - } - if (!parseSdParam(AllowedSdParams(SdParam::number), parm)) - return 0; - Char c; - if (translateSyntax(sdBuilder, parm.n, c) - && checkNotFunction(*sdBuilder.syntax, c) - && !invalidName) { - Char tem; - if (sdBuilder.syntax->lookupFunctionChar(name, &tem)) - message(ParserMessages::duplicateFunctionName, StringMessageArg(name)); - else - sdBuilder.syntax->addFunctionChar(name, functionClass, c); - } - } - if (haveMsochar && !haveMsichar) - message(ParserMessages::msocharRequiresMsichar); - return 1; -} - -Boolean Parser::sdParseNaming(SdBuilder &sdBuilder, SdParam &parm) -{ - static Sd::ReservedName keys[4] = { - Sd::rUCNMSTRT, Sd::rLCNMCHAR, Sd::rUCNMCHAR, Sd::rNAMECASE - }; - int isNamechar = 0; - ISet nameStartChar; - ISet nameChar; - do { - String lc; - Vector rangeIndex; - Boolean first = 1; - Boolean allowThrough = 0; - for (;;) { - if (!parseSdParam(sdBuilder.externalSyntax - ? AllowedSdParams(SdParam::reservedName - + keys[isNamechar * 2], - SdParam::paramLiteral, - SdParam::number, - SdParam::ellipsis) - : (first - ? AllowedSdParams(SdParam::paramLiteral) - : AllowedSdParams(SdParam::reservedName - + keys[isNamechar * 2])), - parm)) - return 0; - first = 0; - Boolean wasRange = 0; - sdParamConvertToLiteral(parm); - if (parm.type == SdParam::ellipsis) { - if (!allowThrough) - message(ParserMessages::sdInvalidEllipsis); - if (!parseSdParam(AllowedSdParams(SdParam::paramLiteral, - SdParam::number), - parm)) - return 0; - sdParamConvertToLiteral(parm); - if (parm.paramLiteralText.size() == 0) - message(ParserMessages::sdInvalidEllipsis); - else if (allowThrough) { - SyntaxChar n = parm.paramLiteralText[0]; - if (n < lc[lc.size() - 1]) - message(ParserMessages::sdInvalidRange); - else if (n > lc[lc.size() - 1] + 1) - rangeIndex.push_back(lc.size() - 1); - } - wasRange = 1; - } - if (parm.type != SdParam::paramLiteral) - break; - lc += parm.paramLiteralText; - allowThrough = (parm.paramLiteralText.size() - wasRange) > 0; - } - size_t lcPos = 0; - size_t rangeIndexPos = 0; - unsigned long rangeLeft = 0; - SyntaxChar nextRangeChar; - ISet &set = isNamechar ? nameChar : nameStartChar; - String chars; - Boolean runOut = 0; - first = 1; - for (;;) { - if (!parseSdParam(sdBuilder.externalSyntax - ? AllowedSdParams(SdParam::reservedName - + keys[isNamechar * 2 + 1], - SdParam::paramLiteral, - SdParam::number, - SdParam::ellipsis) - : (first - ? AllowedSdParams(SdParam::paramLiteral) - : AllowedSdParams(SdParam::reservedName - + keys[isNamechar * 2 + 1])), - parm)) - return 0; - sdParamConvertToLiteral(parm); - first = 0; - Boolean isRange = parm.type == SdParam::ellipsis; - size_t nChars = chars.size(); - if (nChars) - nChars -= isRange; - for (size_t i = 0; i < nChars; i++) { - if (rangeLeft == 0 - && rangeIndexPos < rangeIndex.size() - && rangeIndex[rangeIndexPos] == lcPos) { - rangeLeft = 1 + lc[lcPos + 1] - lc[lcPos]; - nextRangeChar = lc[lcPos]; - lcPos += 2; - rangeIndexPos += 1; - } - Char c; - if (rangeLeft > 0) { - rangeLeft--; - c = nextRangeChar++; - } - else if (lcPos < lc.size()) - c = lc[lcPos++]; - else { - runOut = 1; - c = chars[i]; - } - // map from c to chars[i] - Char transLc, transUc; - if (translateSyntax(sdBuilder, c, transLc) - && translateSyntax(sdBuilder, chars[i], transUc)) { - set.add(transLc); - if (transLc != transUc) { - set.add(transUc); - sdBuilder.syntax->addSubst(transLc, transUc); - } - } - } - if (isRange) { - if (!parseSdParam(AllowedSdParams(SdParam::paramLiteral, - SdParam::number), - parm)) - return 0; - sdParamConvertToLiteral(parm); - if (chars.size() == 0 || parm.paramLiteralText.size() == 0) - message(ParserMessages::sdInvalidEllipsis); - else { - SyntaxChar start = chars[chars.size() - 1]; - SyntaxChar end = parm.paramLiteralText[0]; - if (start > end) - message(ParserMessages::sdInvalidRange); - else { - size_t count = end + 1 - start; - while (count > 0) { - if (rangeLeft == 0 - && rangeIndexPos < rangeIndex.size() - && rangeIndex[rangeIndexPos] == lcPos) { - rangeLeft = 1 + lc[lcPos + 1] - lc[lcPos]; - nextRangeChar = lc[lcPos]; - lcPos += 2; - rangeIndexPos += 1; - } - Char c; - if (rangeLeft > 0) { - rangeLeft--; - c = nextRangeChar++; - } - else if (lcPos < lc.size()) - c = lc[lcPos++]; - else { - c = start; - runOut = 1; - } - if (c == start && count > 1 && (runOut || rangeLeft > 0)) { - size_t n; - if (runOut) - n = count; - else if (rangeLeft < count) - n = rangeLeft + 1; - else - n = count; - translateRange(sdBuilder, start, start + (count - 1), set); - count -= n; - start += n; - } - else { - Char transLc, transUc; - if (translateSyntax(sdBuilder, c, transLc) - && translateSyntax(sdBuilder, start, transUc)) { - set.add(transLc); - if (transLc != transUc) { - set.add(transUc); - sdBuilder.syntax->addSubst(transLc, transUc); - } - } - count--; - start++; - } - } - } - } - chars.resize(0); - if (parm.type != SdParam::paramLiteral) - break; - chars.append(parm.paramLiteralText.data() + 1, - parm.paramLiteralText.size() - 1); - } - else if (parm.type == SdParam::paramLiteral) - parm.paramLiteralText.swap(chars); - else - break; - } - if ((runOut && !sdBuilder.externalSyntax) - || rangeLeft > 0 || lcPos < lc.size()) - message(isNamechar - ? ParserMessages::nmcharLength - : ParserMessages::nmstrtLength); - if (!checkNmchars(set, *sdBuilder.syntax)) - sdBuilder.valid = 0; - } while (!isNamechar++); - ISet bad; - intersectCharSets(nameStartChar, nameChar, bad); - if (!bad.isEmpty()) { - sdBuilder.valid = 0; - message(ParserMessages::nmcharNmstrt, CharsetMessageArg(bad)); - } - sdBuilder.syntax->addNameStartCharacters(nameStartChar); - sdBuilder.syntax->addNameCharacters(nameChar); - if (!parseSdParam(AllowedSdParams(SdParam::reservedName + Sd::rGENERAL), - parm)) - return 0; - if (!parseSdParam(AllowedSdParams(SdParam::reservedName + Sd::rNO, - SdParam::reservedName + Sd::rYES), - parm)) - return 0; - sdBuilder.syntax->setNamecaseGeneral(parm.type - == SdParam::reservedName + Sd::rYES); - - if (!parseSdParam(AllowedSdParams(SdParam::reservedName + Sd::rENTITY), - parm)) - return 0; - if (!parseSdParam(AllowedSdParams(SdParam::reservedName + Sd::rNO, - SdParam::reservedName + Sd::rYES), - parm)) - return 0; - sdBuilder.syntax->setNamecaseEntity(parm.type - == SdParam::reservedName + Sd::rYES); - return 1; -} - -Boolean Parser::checkNmchars(const ISet &set, const Syntax &syntax) -{ - Boolean valid = 1; - ISet bad; - intersectCharSets(set, *syntax.charSet(Syntax::nameStart), bad); - if (!bad.isEmpty()) { - message(ParserMessages::nmcharLetter, CharsetMessageArg(bad)); - valid = 0; - bad.clear(); - } - intersectCharSets(set, *syntax.charSet(Syntax::digit), bad); - if (!bad.isEmpty()) { - message(ParserMessages::nmcharDigit, CharsetMessageArg(bad)); - valid = 0; - bad.clear(); - } - Char funChar; - if (syntax.getStandardFunction(Syntax::fRE, funChar) - && set.contains(funChar)) { - message(ParserMessages::nmcharRe, NumberMessageArg(funChar)); - valid = 0; - } - if (syntax.getStandardFunction(Syntax::fRS, funChar) - && set.contains(funChar)) { - message(ParserMessages::nmcharRs, NumberMessageArg(funChar)); - valid = 0; - } - if (syntax.getStandardFunction(Syntax::fSPACE, funChar) - && set.contains(funChar)) { - message(ParserMessages::nmcharSpace, NumberMessageArg(funChar)); - valid = 0; - } - intersectCharSets(set, *syntax.charSet(Syntax::sepchar), bad); - if (!bad.isEmpty()) { - message(ParserMessages::nmcharSepchar, CharsetMessageArg(bad)); - valid = 0; - } - return valid; -} - -// Result is a ISet, so it can be used with CharsetMessageArg. - -void Parser::intersectCharSets(const ISet &s1, const ISet &s2, - ISet &inter) -{ - ISetIter i1(s1); - ISetIter i2(s2); - Char min1, max1, min2, max2; - if (!i1.next(min1, max1)) - return; - if (!i2.next(min2, max2)) - return; - for (;;) { - if (max1 < min2) { - if (!i1.next(min1, max1)) - break; - } - else if (max2 < min1) { - if (!i2.next(min2, max2)) - break; - } - else { - // min2 <= max1 - // min1 <= max2 - Char min = min1 > min2 ? min1 : min2; - Char max = max1 < max2 ? max1 : max2; - inter.addRange(min, max); - if (!i1.next(min1, max1)) - break; - if (!i2.next(min2, max2)) - break; - } - } -} - -Boolean Parser::sdParseDelim(SdBuilder &sdBuilder, SdParam &parm) -{ - if (!parseSdParam(AllowedSdParams(SdParam::reservedName + Sd::rDELIM), - parm)) - return 0; - if (!parseSdParam(AllowedSdParams(SdParam::reservedName + Sd::rGENERAL), - parm)) - return 0; - if (!parseSdParam(AllowedSdParams(SdParam::reservedName + Sd::rSGMLREF), - parm)) - return 0; - PackedBoolean delimGeneralSpecified[Syntax::nDelimGeneral]; - for (int i = 0; i < Syntax::nDelimGeneral; i++) - delimGeneralSpecified[i] = 0; - for (;;) { - if (!parseSdParam(AllowedSdParams(SdParam::generalDelimiterName, - SdParam::reservedName + Sd::rSHORTREF), - parm)) - return 0; - if (parm.type == SdParam::reservedName + Sd::rSHORTREF) - break; - Syntax::DelimGeneral delimGeneral = parm.delimGeneralIndex; - if (delimGeneralSpecified[delimGeneral]) - message(ParserMessages::duplicateDelimGeneral, - StringMessageArg(sd().generalDelimiterName(delimGeneral))); - if (!parseSdParam(sdBuilder.externalSyntax - ? AllowedSdParams(SdParam::paramLiteral, - SdParam::number) - : AllowedSdParams(SdParam::paramLiteral), - parm)) - return 0; - sdParamConvertToLiteral(parm); - StringC str; - if (parm.paramLiteralText.size() == 0) - message(ParserMessages::sdEmptyDelimiter); - else if (translateSyntax(sdBuilder, parm.paramLiteralText, str)) { - const SubstTable *table = sdBuilder.syntax->generalSubstTable(); - for (size_t i = 0; i < str.size(); i++) - table->subst(str[i]); - if (checkGeneralDelim(*sdBuilder.syntax, str) - && !delimGeneralSpecified[delimGeneral]) - sdBuilder.syntax->setDelimGeneral(delimGeneral, str); - else - sdBuilder.valid = 0; - } - delimGeneralSpecified[delimGeneral] = 1; - } - if (!setRefDelimGeneral(*sdBuilder.syntax, - sdBuilder.syntaxCharset, - sdBuilder.sd->docCharset(), - sdBuilder.switcher)) - sdBuilder.valid = 0; - if (!parseSdParam(AllowedSdParams(SdParam::reservedName + Sd::rSGMLREF, - SdParam::reservedName + Sd::rNONE), - parm)) - return 0; - if (parm.type == SdParam::reservedName + Sd::rSGMLREF) { - if (!addRefDelimShortref(*sdBuilder.syntax, - sdBuilder.syntaxCharset, - sdBuilder.sd->docCharset(), - sdBuilder.switcher)) - sdBuilder.valid = 0; - } - String lastLiteral; - for (;;) { - if (!parseSdParam(sdBuilder.externalSyntax - ? AllowedSdParams(SdParam::paramLiteral, - SdParam::number, - SdParam::ellipsis, - SdParam::reservedName + Sd::rNAMES) - : AllowedSdParams(SdParam::paramLiteral, - SdParam::reservedName + Sd::rNAMES), - parm)) - return 0; - sdParamConvertToLiteral(parm); - if (parm.type == SdParam::ellipsis) { - if (!parseSdParam(AllowedSdParams(SdParam::paramLiteral, - SdParam::number), - parm)) - return 0; - sdParamConvertToLiteral(parm); - if (parm.paramLiteralText.size() == 0) - message(ParserMessages::sdEmptyDelimiter); - else if (lastLiteral.size() != 1 - || parm.paramLiteralText.size() != 1) - message(ParserMessages::sdInvalidEllipsis); - else if (parm.paramLiteralText[0] < lastLiteral[0]) - message(ParserMessages::sdInvalidRange); - else if (parm.paramLiteralText[0] != lastLiteral[0]) { - ISet shortrefChars; - translateRange(sdBuilder, - lastLiteral[0] + 1, - parm.paramLiteralText[0], - shortrefChars); - ISet duplicates; - intersectCharSets(shortrefChars, - sdBuilder.syntax->delimShortrefSimple(), - duplicates); - int nComplexShortrefs = sdBuilder.syntax->nDelimShortrefComplex(); - for (int i = 0; i < nComplexShortrefs; i++) { - const StringC &delim = sdBuilder.syntax->delimShortrefComplex(i); - if (delim.size() == 1 && shortrefChars.contains(delim[0])) - duplicates.add(delim[0]); - } - if (!duplicates.isEmpty()) - message(ParserMessages::duplicateDelimShortrefSet, - CharsetMessageArg(duplicates)); - sdBuilder.syntax->addDelimShortrefs(shortrefChars, - sdBuilder.sd->docCharset()); - } - lastLiteral.resize(0); - } - else if (parm.type == SdParam::paramLiteral) { - parm.paramLiteralText.swap(lastLiteral); - StringC str; - if (lastLiteral.size() == 0) - message(ParserMessages::sdEmptyDelimiter); - else if (translateSyntax(sdBuilder, lastLiteral, str)) { - const SubstTable *table = sdBuilder.syntax->generalSubstTable(); - for (size_t i = 0; i < str.size(); i++) - table->subst(str[i]); - if (str.size() == 1 - || checkShortrefDelim(*sdBuilder.syntax, - sdBuilder.sd->docCharset(), - str)) { - if (sdBuilder.syntax->isValidShortref(str)) - message(ParserMessages::duplicateDelimShortref, - StringMessageArg(str)); - else - sdBuilder.syntax->addDelimShortref(str, - sdBuilder.sd->docCharset()); - } - } - } - else - break; - } - return 1; -} - -Boolean Parser::sdParseNames(SdBuilder &sdBuilder, SdParam &parm) -{ - if (!parseSdParam(AllowedSdParams(SdParam::reservedName + Sd::rSGMLREF), - parm)) - return 0; - for (;;) { - if (!parseSdParam(AllowedSdParams(SdParam::reservedName + Sd::rQUANTITY, - SdParam::referenceReservedName), - parm)) - return 0; - if (parm.type == SdParam::reservedName + Sd::rQUANTITY) - break; - Syntax::ReservedName reservedName = parm.reservedNameIndex; - if (!parseSdParam(sdBuilder.externalSyntax - ? AllowedSdParams(SdParam::name, SdParam::paramLiteral) - : AllowedSdParams(SdParam::name), - parm)) - return 0; - StringC transName; - if (parm.type == SdParam::name - ? translateName(sdBuilder, parm.token, transName) - : translateSyntax(sdBuilder, parm.paramLiteralText, transName)) { - Syntax::ReservedName tem; - if (sdBuilder.syntax->lookupReservedName(transName, &tem)) - message(ParserMessages::ambiguousReservedName, - StringMessageArg(transName)); - else { - if (transName.size() == 0 - || !sdBuilder.syntax->isNameStartCharacter(transName[0])) { - message(ParserMessages::reservedNameSyntax, - StringMessageArg(transName)); - transName.resize(0); - } - size_t i; - // Check that its a valid name in the declared syntax - // (- and . might not be name characters). - for (i = 1; i < transName.size(); i++) - if (!sdBuilder.syntax->isNameCharacter(transName[i])) { - message(ParserMessages::reservedNameSyntax, - StringMessageArg(transName)); - transName.resize(0); - break; - } - for (i = 0; i < transName.size(); i++) - sdBuilder.syntax->generalSubstTable()->subst(transName[i]); - if (sdBuilder.syntax->reservedName(reservedName).size() > 0) - message(ParserMessages::duplicateReservedName, - StringMessageArg(syntax().reservedName(reservedName))); - else if (transName.size() > 0) - sdBuilder.syntax->setName(reservedName, transName); - else - sdBuilder.valid = 0; - } - } - } - setRefNames(*sdBuilder.syntax, sdBuilder.sd->docCharset()); - static Syntax::ReservedName functionNameIndex[3] = { - Syntax::rRE, Syntax::rRS, Syntax::rSPACE - }; - for (int i = 0; i < 3; i++) { - const StringC &functionName - = sdBuilder.syntax->reservedName(functionNameIndex[i]); - Char tem; - if (sdBuilder.syntax->lookupFunctionChar(functionName, &tem)) - message(ParserMessages::duplicateFunctionName, StringMessageArg(functionName)); - } - sdBuilder.syntax->enterStandardFunctionNames(); - return 1; -} - -Boolean Parser::sdParseQuantity(SdBuilder &sdBuilder, SdParam &parm) -{ - if (!parseSdParam(AllowedSdParams(SdParam::reservedName + Sd::rSGMLREF), - parm)) - return 0; - for (;;) { - int final = (sdBuilder.externalSyntax - ? int(SdParam::eE) - : SdParam::reservedName + Sd::rFEATURES); - if (!parseSdParam(AllowedSdParams(SdParam::quantityName, final), parm)) - return 0; - if (parm.type != SdParam::quantityName) - break; - Syntax::Quantity quantity = parm.quantityIndex; - if (!parseSdParam(AllowedSdParams(SdParam::number), parm)) - return 0; - sdBuilder.syntax->setQuantity(quantity, parm.n); - } - if (sdBuilder.sd->scopeInstance()) { - for (int i = 0; i < Syntax::nQuantity; i++) - if (sdBuilder.syntax->quantity(Syntax::Quantity(i)) - < syntax().quantity(Syntax::Quantity(i))) - message(ParserMessages::scopeInstanceQuantity, - StringMessageArg(sd().quantityName(Syntax::Quantity(i)))); - } - return 1; -} - -Boolean Parser::sdParseFeatures(SdBuilder &sdBuilder, SdParam &parm) -{ - struct FeatureInfo { - Sd::ReservedName name; - enum { - __none, - __boolean, - __number - } arg; - }; - static FeatureInfo features[] = { - { Sd::rMINIMIZE, FeatureInfo::__none }, - { Sd::rDATATAG, FeatureInfo::__boolean }, - { Sd::rOMITTAG, FeatureInfo::__boolean }, - { Sd::rRANK, FeatureInfo::__boolean }, - { Sd::rSHORTTAG, FeatureInfo::__boolean }, - { Sd::rLINK, FeatureInfo::__none }, - { Sd::rSIMPLE, FeatureInfo::__number }, - { Sd::rIMPLICIT, FeatureInfo::__boolean }, - { Sd::rEXPLICIT, FeatureInfo::__number }, - { Sd::rOTHER, FeatureInfo::__none }, - { Sd::rCONCUR, FeatureInfo::__number }, - { Sd::rSUBDOC, FeatureInfo::__number }, - { Sd::rFORMAL, FeatureInfo::__boolean } - }; - int booleanFeature = 0; - int numberFeature = 0; - for (size_t i = 0; i < SIZEOF(features); i++) { - if (!parseSdParam(AllowedSdParams(SdParam::reservedName - + features[i].name), parm)) - return 0; - if (features[i].arg != FeatureInfo::__none) { - if (!parseSdParam(AllowedSdParams(SdParam::reservedName + Sd::rNO, - SdParam::reservedName + Sd::rYES), - parm)) - return 0; -#if 0 - if (features[i].name == Sd::rDATATAG - && parm.type == (SdParam::reservedName + Sd::rYES)) - message(ParserMessages::datatagNotImplemented); -#endif - if (features[i].arg == FeatureInfo::__number) { - if (parm.type == SdParam::reservedName + Sd::rYES) { - if (!parseSdParam(AllowedSdParams(SdParam::number), parm)) - return 0; - sdBuilder.sd->setNumberFeature(Sd::NumberFeature(numberFeature++), - parm.n); - } - else - sdBuilder.sd->setNumberFeature(Sd::NumberFeature(numberFeature++), - 0); - } - else - sdBuilder.sd->setBooleanFeature(Sd::BooleanFeature(booleanFeature++), - parm.type == (SdParam::reservedName - + Sd::rYES)); - } - } - return 1; -} - -Boolean Parser::sdParseAppinfo(SdBuilder &, SdParam &parm) -{ - if (!parseSdParam(AllowedSdParams(SdParam::reservedName + Sd::rAPPINFO), - parm)) - return 0; - Location location(currentLocation()); - if (!parseSdParam(AllowedSdParams(SdParam::reservedName + Sd::rNONE, - SdParam::minimumLiteral), - parm)) - return 0; - AppinfoEvent *event; - if (parm.type == SdParam::minimumLiteral) - event = new (eventAllocator()) AppinfoEvent(parm.literalText, location); - else - event = new (eventAllocator()) AppinfoEvent(location); - eventHandler().appinfo(event); - return 1; -} - -Boolean Parser::translateSyntax(CharSwitcher &switcher, - const CharsetInfo &syntaxCharset, - const CharsetInfo &docCharset, - WideChar syntaxChar, - Char &docChar) -{ - syntaxChar = switcher.subst(syntaxChar); - UnivChar univChar; - if (syntaxCharset.descToUniv(syntaxChar, univChar) - && univToDescCheck(docCharset, univChar, docChar)) - return 1; - message(ParserMessages::translateSyntaxChar, NumberMessageArg(syntaxChar)); - return 0; -} - -void Parser::translateRange(SdBuilder &sdBuilder, SyntaxChar start, - SyntaxChar end, ISet &chars) -{ -#if 0 - do { - Char docChar; - if (!translateSyntax(sdBuilder, start, docChar)) - break; - chars.add(docChar); - } while (start++ != end); -#endif - for (;;) { - SyntaxChar doneUpTo = end; - Boolean gotSwitch = 0; - WideChar firstSwitch; - for (size_t i = 0; i < sdBuilder.switcher.nSwitches(); i++) { - WideChar c = sdBuilder.switcher.switchFrom(i); - if (start <= c && c <= end) { - if (!gotSwitch) { - gotSwitch = 1; - firstSwitch = c; - } - else if (c < firstSwitch) - firstSwitch = c; - } - } - if (gotSwitch && firstSwitch == start) { - doneUpTo = start; - Char docChar; - if (translateSyntax(sdBuilder, start, docChar)) - chars.add(docChar); - } - else { - if (gotSwitch) - doneUpTo = firstSwitch - 1; - Char docChar; - Number count; - if (translateSyntaxNoSwitch(sdBuilder, start, docChar, count)) { - if (count - 1 < doneUpTo - start) - doneUpTo = start + (count - 1); - chars.addRange(docChar, docChar + (doneUpTo - start)); - } - } - if (doneUpTo == end) - break; - start = doneUpTo + 1; - } -} - -Boolean Parser::translateSyntax(SdBuilder &sdBuilder, - WideChar syntaxChar, Char &docChar) -{ - Number count; - return translateSyntaxNoSwitch(sdBuilder, - sdBuilder.switcher.subst(syntaxChar), - docChar, - count); -} - -Boolean Parser::translateSyntaxNoSwitch(SdBuilder &sdBuilder, - WideChar syntaxChar, Char &docChar, - Number &count) -{ - Number n; - StringC str; - CharsetDeclRange::Type type; - const PublicId *id; - if (sdBuilder.syntaxCharsetDecl.getCharInfo(syntaxChar, - id, - type, - n, - str, - count)) { - ISet docChars; - switch (type) { - case CharsetDeclRange::unused: - break; - case CharsetDeclRange::string: - sdBuilder.sd->docCharsetDecl().stringToChar(str, docChars); - break; - case CharsetDeclRange::number: - { - Number count2; - sdBuilder.sd->docCharsetDecl().numberToChar(id, n, docChars, count2); - if (!docChars.isEmpty() && count2 < count) - count = count2; - } - break; - default: - CANNOT_HAPPEN(); - } - if (!docChars.isEmpty()) { - if (!docChars.isSingleton() && options().warnSgmlDecl) - message(ParserMessages::ambiguousDocCharacter, - CharsetMessageArg(docChars)); - ISetIter iter(docChars); - WideChar min, max; - if (iter.next(min, max) && min <= charMax) { - docChar = Char(min); - return 1; - } - } - } - UnivChar univChar; - WideChar alsoMax, count2; - if (sdBuilder.syntaxCharset.descToUniv(syntaxChar, univChar, alsoMax) - && univToDescCheck(sdBuilder.sd->docCharset(), univChar, docChar, - count2)) { - count = (alsoMax - syntaxChar) + 1; - if (count2 < count) - count = count2; - return 1; - } - sdBuilder.valid = 0; - message(ParserMessages::translateSyntaxChar, NumberMessageArg(syntaxChar)); - return 0; -} - - -Boolean Parser::translateSyntax(SdBuilder &sdBuilder, - const String &syntaxString, - StringC &docString) -{ - docString.resize(0); - int ret = 1; - for (size_t i = 0; i < syntaxString.size(); i++) { - Char c; - if (translateSyntax(sdBuilder, syntaxString[i], c)) - docString += c; - else - ret = 0; - } - return ret; -} - -Boolean Parser::translateName(SdBuilder &sdBuilder, - const StringC &name, - StringC &str) -{ - str.resize(name.size()); - for (size_t i = 0; i < name.size(); i++) { - UnivChar univChar; - Boolean ret = sd().docCharset().descToUniv(name[i], univChar); - // Might switch hyphen or period. - univChar = translateUniv(univChar, sdBuilder.switcher, - sdBuilder.syntaxCharset); - ASSERT(ret != 0); - if (!univToDescCheck(sdBuilder.sd->docCharset(), univChar, str[i])) { - message(ParserMessages::translateDocChar, NumberMessageArg(univChar)); - sdBuilder.valid = 0; - return 0; - } - } - return 1; -} - -UnivChar Parser::translateUniv(UnivChar univChar, - CharSwitcher &switcher, - const CharsetInfo &syntaxCharset) -{ - WideChar syntaxChar; - ISet syntaxChars; - if (syntaxCharset.univToDesc(univChar, syntaxChar, syntaxChars) != 1) { - message(ParserMessages::missingSyntaxChar, - NumberMessageArg(univChar)); - return univChar; - } - SyntaxChar tem = switcher.subst(syntaxChar); - if (tem != syntaxChar && !syntaxCharset.descToUniv(tem, univChar)) - message(ParserMessages::translateSyntaxChar, NumberMessageArg(tem)); - return univChar; -} - -Boolean Parser::checkNotFunction(const Syntax &syn, Char c) -{ - if (syn.charSet(Syntax::functionChar)->contains(c)) { - message(ParserMessages::oneFunction, NumberMessageArg(c)); - return 0; - } - else - return 1; -} - - -// Check that it has at most one B sequence and that it -// is not adjacent to a blank sequence. - -Boolean Parser::checkShortrefDelim(const Syntax &syn, - const CharsetInfo &charset, - const StringC &delim) -{ - Boolean hadB = 0; - Char letterB = charset.execToDesc('B'); - const ISet *bSet = syn.charSet(Syntax::blank); - for (size_t i = 0; i < delim.size(); i++) - if (delim[i] == letterB) { - if (hadB) { - message(ParserMessages::multipleBSequence, StringMessageArg(delim)); - return 0; - } - hadB = 1; - if (i > 0 && bSet->contains(delim[i - 1])) { - message(ParserMessages::blankAdjacentBSequence, - StringMessageArg(delim)); - return 0; - } - while (i + 1 < delim.size() && delim[i + 1] == letterB) - i++; - if (i < delim.size() - 1 && bSet->contains(delim[i + 1])) { - message(ParserMessages::blankAdjacentBSequence, - StringMessageArg(delim)); - return 0; - } - } - return 1; -} - -Boolean Parser::checkGeneralDelim(const Syntax &syn, const StringC &delim) -{ - const ISet *functionSet = syn.charSet(Syntax::functionChar); - if (delim.size() > 0) { - Boolean allFunction = 1; - for (size_t i = 0; i < delim.size(); i++) - if (!functionSet->contains(delim[i])) - allFunction = 0; - if (allFunction) { - message(ParserMessages::generalDelimAllFunction, - StringMessageArg(delim)); - return 0; - } - } - return 1; -} - -Boolean Parser::checkSwitches(CharSwitcher &switcher, - const CharsetInfo &syntaxCharset) -{ - Boolean valid = 1; - for (size_t i = 0; i < switcher.nSwitches(); i++) { - WideChar c[2]; - c[0] = switcher.switchFrom(i); - c[1] = switcher.switchTo(i); - for (int j = 0; j < 2; j++) { - UnivChar univChar; - if (syntaxCharset.descToUniv(c[j], univChar)) { - // Check that it is not Digit Lcletter or Ucletter - if ((UnivCharsetDesc::a <= univChar - && univChar < UnivCharsetDesc::a + 26) - || (UnivCharsetDesc::A <= univChar - && univChar < UnivCharsetDesc::A + 26) - || (UnivCharsetDesc::zero <= univChar - && univChar < UnivCharsetDesc::zero + 10)) { - message(ParserMessages::switchLetterDigit, - NumberMessageArg(univChar)); - valid = 0; - } - } - } - } - return valid; -} - -Boolean Parser::checkSwitchesMarkup(CharSwitcher &switcher) -{ - Boolean valid = 1; - size_t nSwitches = switcher.nSwitches(); - for (size_t i = 0; i < nSwitches; i++) - if (!switcher.switchUsed(i)) { - // If the switch wasn't used, - // then the character wasn't a markup character. - message(ParserMessages::switchNotMarkup, - NumberMessageArg(switcher.switchFrom(i))); - valid = 0; - } - return valid; -} - -void Parser::checkSyntaxNamelen(const Syntax &syn) -{ - size_t namelen = syn.namelen(); - int i; - for (i = 0; i < Syntax::nDelimGeneral; i++) - if (syn.delimGeneral(i).size() > namelen) - message(ParserMessages::delimiterLength, - StringMessageArg(syn.delimGeneral(i)), - NumberMessageArg(namelen)); - for (i = 0; i < syn.nDelimShortrefComplex(); i++) - if (syn.delimShortrefComplex(i).size() > namelen) - message(ParserMessages::delimiterLength, - StringMessageArg(syn.delimShortrefComplex(i)), - NumberMessageArg(namelen)); - for (i = 0; i < Syntax::nNames; i++) - if (syn.reservedName(Syntax::ReservedName(i)).size() > namelen - && options().warnSgmlDecl) - message(ParserMessages::reservedNameLength, - StringMessageArg(syn.reservedName(Syntax::ReservedName(i))), - NumberMessageArg(namelen)); -} - -Boolean Parser::univToDescCheck(const CharsetInfo &charset, UnivChar from, - Char &to) -{ - WideChar count; - return univToDescCheck(charset, from, to, count); -} - -Boolean Parser::univToDescCheck(const CharsetInfo &charset, UnivChar from, - Char &to, WideChar &count) -{ - WideChar c; - ISet descSet; - unsigned ret = charset.univToDesc(from, c, descSet, count); - if (ret > 1) { - if (options().warnSgmlDecl) - message(ParserMessages::ambiguousDocCharacter, - CharsetMessageArg(descSet)); - ret = 1; - } - if (ret && c <= charMax) { - to = Char(c); - return 1; - } - return 0; -} - -Boolean Parser::parseSdParam(const AllowedSdParams &allow, - SdParam &parm) -{ - for (;;) { - Token token = getToken(mdMode); - switch (token) { - case tokenUnrecognized: - if (reportNonSgmlCharacter()) - break; - { - message(ParserMessages::markupDeclarationCharacter, - StringMessageArg(currentToken()), - AllowedSdParamsMessageArg(allow, sdPointer())); - } - return 0; - case tokenEe: - if (allow.param(SdParam::eE)) { - parm.type = SdParam::eE; - if (currentMarkup()) - currentMarkup()->addEntityEnd(); - popInputStack(); - return 1; - } - message(ParserMessages::sdEntityEnd, - AllowedSdParamsMessageArg(allow, sdPointer())); - return 0; - case tokenS: - if (currentMarkup()) - currentMarkup()->addS(currentChar()); - break; - case tokenCom: - if (!parseComment(sdcomMode)) - return 0; - break; - case tokenDso: - case tokenGrpo: - case tokenMinusGrpo: - case tokenPlusGrpo: - case tokenRni: - case tokenPeroNameStart: - case tokenPeroGrpo: - sdParamInvalidToken(token, allow); - return 0; - case tokenLcUcNmchar: - if (allow.param(SdParam::ellipsis)) { - extendNameToken(syntax().namelen(), ParserMessages::nameLength); - getCurrentToken(syntax().generalSubstTable(), parm.token); - if (parm.token == sd().execToDoc("...")) { - parm.type = SdParam::ellipsis; - return 1; - } - message(ParserMessages::sdInvalidNameToken, - StringMessageArg(parm.token), - AllowedSdParamsMessageArg(allow, sdPointer())); - } - else { - sdParamInvalidToken(token, allow); - return 0; - } - case tokenLita: - case tokenLit: - { - Boolean lita = (token == tokenLita); - if (allow.param(SdParam::minimumLiteral)) { - if (!parseMinimumLiteral(lita, parm.literalText)) - return 0; - parm.type = SdParam::minimumLiteral; - if (currentMarkup()) - currentMarkup()->addLiteral(parm.literalText); - } - else if (allow.param(SdParam::paramLiteral)) { - if (!parseSdParamLiteral(lita, parm.paramLiteralText)) - return 0; - parm.type = SdParam::paramLiteral; - } - else { - sdParamInvalidToken(token, allow); - return 0; - } - return 1; - } - case tokenMdc: - if (allow.param(SdParam::mdc)) { - parm.type = SdParam::mdc; - if (currentMarkup()) - currentMarkup()->addDelim(Syntax::dMDC); - return 1; - } - sdParamInvalidToken(tokenMdc, allow); - return 0; - case tokenNameStart: - { - extendNameToken(syntax().namelen(), ParserMessages::nameLength); - getCurrentToken(syntax().generalSubstTable(), parm.token); - if (allow.param(SdParam::capacityName)) { - if (sd().lookupCapacityName(parm.token, parm.capacityIndex)) { - parm.type = SdParam::capacityName; - if (currentMarkup()) - currentMarkup()->addName(currentInput()); - return 1; - } - } - if (allow.param(SdParam::referenceReservedName)) { - if (syntax().lookupReservedName(parm.token, - &parm.reservedNameIndex)) { - parm.type = SdParam::referenceReservedName; - if (currentMarkup()) - currentMarkup()->addName(currentInput()); - return 1; - } - } - if (allow.param(SdParam::generalDelimiterName)) { - if (sd().lookupGeneralDelimiterName(parm.token, - parm.delimGeneralIndex)) { - parm.type = SdParam::generalDelimiterName; - if (currentMarkup()) - currentMarkup()->addName(currentInput()); - return 1; - } - } - if (allow.param(SdParam::quantityName)) { - if (sd().lookupQuantityName(parm.token, parm.quantityIndex)) { - parm.type = SdParam::quantityName; - if (currentMarkup()) - currentMarkup()->addName(currentInput()); - return 1; - } - } - for (int i = 0;; i++) { - SdParam::Type t = allow.get(i); - if (t == SdParam::invalid) - break; - if (t >= SdParam::reservedName) { - Sd::ReservedName sdReservedName - = Sd::ReservedName(t - SdParam::reservedName); - if (parm.token == sd().reservedName(sdReservedName)) { - parm.type = t; - if (currentMarkup()) - currentMarkup()->addSdReservedName(sdReservedName, - currentInput()); - return 1; - } - } - } - if (allow.param(SdParam::name)) { - parm.type = SdParam::name; - if (currentMarkup()) - currentMarkup()->addName(currentInput()); - return 1; - } - { - message(ParserMessages::sdInvalidNameToken, - StringMessageArg(parm.token), - AllowedSdParamsMessageArg(allow, sdPointer())); - } - return 0; - } - case tokenDigit: - if (allow.param(SdParam::number)) { - extendNumber(syntax().namelen(), ParserMessages::numberLength); - parm.type = SdParam::number; - unsigned long n; - if (!stringToNumber(currentInput()->currentTokenStart(), - currentInput()->currentTokenLength(), - n) - || n > Number(-1)) { - message(ParserMessages::numberTooBig, - StringMessageArg(currentToken())); - parm.n = Number(-1); - } - else { - if (currentMarkup()) - currentMarkup()->addNumber(currentInput()); - parm.n = Number(n); - } - Token token = getToken(mdMode); - if (token == tokenNameStart) - message(ParserMessages::psRequired); - currentInput()->ungetToken(); - return 1; - } - sdParamInvalidToken(tokenDigit, allow); - return 0; - default: - CANNOT_HAPPEN(); - } - } -} - -// This is a separate function, because we might want SyntaxChar -// to be bigger than Char. - -Boolean Parser::parseSdParamLiteral(Boolean lita, String &str) -{ - Location loc(currentLocation()); - loc += 1; - SdText text(loc, lita); // first character of content - str.resize(0); - const unsigned refLitlen = Syntax::referenceQuantity(Syntax::qLITLEN); - - Mode mode = lita ? sdplitaMode : sdplitMode; - int done = 0; - for (;;) { - Token token = getToken(mode); - switch (token) { - case tokenEe: - message(ParserMessages::literalLevel); - return 0; - case tokenUnrecognized: - if (reportNonSgmlCharacter()) - break; - if (options().errorSignificant) - message(ParserMessages::sdLiteralSignificant, - StringMessageArg(currentToken())); - text.addChar(currentChar(), currentLocation()); - break; - case tokenCroDigit: - { - InputSource *in = currentInput(); - Location startLocation = currentLocation(); - in->discardInitial(); - extendNumber(syntax().namelen(), ParserMessages::numberLength); - unsigned long n; - Boolean valid; - if (!stringToNumber(in->currentTokenStart(), - in->currentTokenLength(), - n) - || n > syntaxCharMax) { - message(ParserMessages::syntaxCharacterNumber, - StringMessageArg(currentToken())); - valid = 0; - } - else - valid = 1; - Owner markupPtr; - if (eventsWanted().wantPrologMarkup()) { - markupPtr = new Markup; - markupPtr->addDelim(Syntax::dCRO); - markupPtr->addNumber(in); - switch (getToken(refMode)) { - case tokenRefc: - markupPtr->addDelim(Syntax::dREFC); - break; - case tokenRe: - markupPtr->addRefEndRe(); - break; - default: - break; - } - } - else - (void)getToken(refMode); - if (valid) - text.addChar(SyntaxChar(n), - Location(new NumericCharRefOrigin(startLocation, - currentLocation().index() - + currentInput()->currentTokenLength() - - startLocation.index(), - markupPtr), - 0)); - } - break; - case tokenCroNameStart: - if (!parseNamedCharRef()) - return 0; - break; - case tokenLit: - case tokenLita: - done = 1; - break; - case tokenPeroNameStart: - case tokenPeroGrpo: - message(ParserMessages::sdParameterEntity); - { - Location loc(currentLocation()); - const Char *p = currentInput()->currentTokenStart(); - for (size_t count = currentInput()->currentTokenLength(); - count > 0; - count--) { - text.addChar(*p++, loc); - loc += 1; - } - } - break; - case tokenChar: - if (text.string().size() > refLitlen - && currentChar() == syntax().standardFunction(Syntax::fRE)) { - message(ParserMessages::parameterLiteralLength, NumberMessageArg(refLitlen)); - // guess that the closing delimiter has been omitted - message(ParserMessages::literalClosingDelimiter); - return 0; - } - text.addChar(currentChar(), currentLocation()); - break; - } - if (done) break; - } - if (text.string().size() > refLitlen) - message(ParserMessages::parameterLiteralLength, - NumberMessageArg(refLitlen)); - - str = text.string(); - if (currentMarkup()) - currentMarkup()->addSdLiteral(text); - return 1; -} - -Boolean Parser::stringToNumber(const Char *s, size_t length, - unsigned long &result) -{ - unsigned long n = 0; - for (; length > 0; length--, s++) { - int val = sd().digitWeight(*s); - if (n <= ULONG_MAX/10 && (n *= 10) <= ULONG_MAX - val) - n += val; - else - return 0; - } - result = n; - return 1; -} - -void Parser::sdParamInvalidToken(Token token, - const AllowedSdParams &allow) -{ - message(ParserMessages::sdParamInvalidToken, - TokenMessageArg(token, mdMode, syntaxPointer(), sdPointer()), - AllowedSdParamsMessageArg(allow, sdPointer())); -} - -void Parser::sdParamConvertToLiteral(SdParam &parm) -{ - if (parm.type == SdParam::number) { - parm.type = SdParam::paramLiteral; - parm.paramLiteralText.resize(1); - parm.paramLiteralText[0] = parm.n; - } -} - -AllowedSdParams::AllowedSdParams(SdParam::Type arg1, SdParam::Type arg2, - SdParam::Type arg3, SdParam::Type arg4, - SdParam::Type arg5, SdParam::Type arg6) -{ - allow_[0] = arg1; - allow_[1] = arg2; - allow_[2] = arg3; - allow_[3] = arg4; - allow_[4] = arg5; - allow_[5] = arg6; -} - -Boolean AllowedSdParams::param(SdParam::Type t) const -{ - for (int i = 0; i < maxAllow && allow_[i] != SdParam::invalid; i++) - if (t == allow_[i]) - return 1; - return 0; -} - -SdParam::Type AllowedSdParams::get(int i) const -{ - return i < 0 || i >= maxAllow ? SdParam::Type(SdParam::invalid) : allow_[i]; -} - -AllowedSdParamsMessageArg::AllowedSdParamsMessageArg( - const AllowedSdParams &allow, - const ConstPtr &sd) -: allow_(allow), sd_(sd) -{ -} - -MessageArg *AllowedSdParamsMessageArg::copy() const -{ - return new AllowedSdParamsMessageArg(*this); -} - -void AllowedSdParamsMessageArg::append(MessageBuilder &builder) const -{ - for (int i = 0;; i++) { - SdParam::Type type = allow_.get(i); - if (type == SdParam::invalid) - break; - if (i != 0) - builder.appendFragment(ParserMessages::listSep); - switch (type) { - case SdParam::eE: - builder.appendFragment(ParserMessages::entityEnd); - break; - case SdParam::minimumLiteral: - builder.appendFragment(ParserMessages::minimumLiteral); - break; - case SdParam::mdc: - { - builder.appendFragment(ParserMessages::delimStart); - Char c = sd_->execToDoc('>'); - builder.appendChars(&c, 1); - builder.appendFragment(ParserMessages::delimEnd); - } - break; - case SdParam::number: - builder.appendFragment(ParserMessages::number); - break; - case SdParam::name: - builder.appendFragment(ParserMessages::name); - break; - case SdParam::paramLiteral: - builder.appendFragment(ParserMessages::parameterLiteral); - break; - case SdParam::capacityName: - builder.appendFragment(ParserMessages::capacityName); - break; - case SdParam::generalDelimiterName: - builder.appendFragment(ParserMessages::generalDelimiteRoleName); - break; - case SdParam::referenceReservedName: - builder.appendFragment(ParserMessages::referenceReservedName); - break; - case SdParam::quantityName: - builder.appendFragment(ParserMessages::quantityName); - break; - case SdParam::ellipsis: - { - StringC str(sd_->execToDoc("...")); - builder.appendChars(str.data(), str.size()); - break; - } - default: - { - StringC str(sd_->reservedName(type - SdParam::reservedName)); - builder.appendChars(str.data(), str.size()); - break; - } - } - } -} - -SdBuilder::SdBuilder() -: valid(1), externalSyntax(0) -{ -} - -void SdBuilder::addFormalError(const Location &location, - const MessageType1 &message, - const StringC &id) -{ - formalErrorList.insert(new SdFormalError(location, message, id)); -} - -SdFormalError::SdFormalError(const Location &location, - const MessageType1 &message, - const StringC &id) -: location_(location), - message_(&message), - id_(id) -{ -} - -void SdFormalError::send(ParserState &parser) -{ - parser.Messenger::setNextLocation(location_); - parser.message(*message_, StringMessageArg(id_)); -} - -CharSwitcher::CharSwitcher() -{ -} - -void CharSwitcher::addSwitch(WideChar from, WideChar to) -{ - switches_.push_back(from); - switches_.push_back(to); - switchUsed_.push_back(0); -} - -SyntaxChar CharSwitcher::subst(WideChar c) -{ - for (size_t i = 0; i < switches_.size(); i += 2) - if (switches_[i] == c) { - switchUsed_[i/2] = 1; - return switches_[i + 1]; - } - return c; -} - -size_t CharSwitcher::nSwitches() const -{ - return switchUsed_.size(); -} - -Boolean CharSwitcher::switchUsed(size_t i) const -{ - return switchUsed_[i]; -} - -WideChar CharSwitcher::switchFrom(size_t i) const -{ - return switches_[i*2]; -} - -WideChar CharSwitcher::switchTo(size_t i) const -{ - return switches_[i*2 + 1]; -} - -CharsetMessageArg::CharsetMessageArg(const ISet &set) -: set_(set) -{ -} - -MessageArg *CharsetMessageArg::copy() const -{ - return new CharsetMessageArg(*this); -} - -void CharsetMessageArg::append(MessageBuilder &builder) const -{ - ISetIter iter(set_); - WideChar min, max; - Boolean first = 1; - while (iter.next(min, max)) { - if (first) - first = 0; - else - builder.appendFragment(ParserMessages::listSep); - builder.appendNumber(min); - if (max != min) { - builder.appendFragment(max == min + 1 - ? ParserMessages::listSep - : ParserMessages::rangeSep); - builder.appendNumber(max); - } - } -} - -#ifdef SP_NAMESPACE -} -#endif diff --git a/cde/programs/nsgmls/parser_inst.m4 b/cde/programs/nsgmls/parser_inst.m4 deleted file mode 100644 index 2cfd30e02..000000000 --- a/cde/programs/nsgmls/parser_inst.m4 +++ /dev/null @@ -1,199 +0,0 @@ -/* $XConsortium: parser_inst.m4 /main/2 1996/08/09 15:33:51 mgreess $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#include "splib.h" - -#ifdef SP_MANUAL_INST - -#define SP_DEFINE_TEMPLATES -#include "Owner.h" -#include "CopyOwner.h" -#include "Vector.h" -#include "NCVector.h" -#include "Ptr.h" -#include "IList.h" -#include "IQueue.h" -#include "List.h" -#include "OwnerTable.h" -#include "PointerTable.h" -#include "HashTable.h" -#include "HashTableItemBase.h" -#include "StringOf.h" -#include "IListIter.h" -#include "ListIter.h" -#include "NamedResourceTable.h" -#undef SP_DEFINE_TEMPLATES - -#include -#include "Attribute.h" -#include "Attributed.h" -#include "CharsetDecl.h" -#include "ContentToken.h" -#include "Dtd.h" -#include "ElementType.h" -#include "Entity.h" -#include "EntityCatalog.h" -#include "EntityManager.h" -#include "EquivClass.h" -#include "Event.h" -#include "Hash.h" -#include "HashTable.h" -#include "HashTableItemBase.h" -#include "InputSource.h" -#include "LinkProcess.h" -#include "Lpd.h" -#include "LpdEntityRef.h" -#include "Markup.h" -#include "NamedResource.h" -#include "NamedTable.h" -#include "Named.h" -#include "NameToken.h" -#include "OpenElement.h" -#include "OutputState.h" -#include "Recognizer.h" -#include "Sd.h" -#include "SdText.h" -#include "SdFormalError.h" -#include "SrInfo.h" -#include "StringResource.h" -#include "Syntax.h" -#include "Text.h" -#include "Trie.h" -#include "Undo.h" -#include "Boolean.h" -#include "types.h" -#include "Id.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -__instantiate(Ptr) -__instantiate(ConstPtr) -__instantiate(Ptr) -__instantiate(ConstPtr) -__instantiate(Ptr) -__instantiate(ConstPtr) -__instantiate(Ptr) -__instantiate(ConstPtr) -__instantiate(Ptr) -__instantiate(ConstPtr) -__instantiate(Ptr) -__instantiate(ConstPtr) -__instantiate(Ptr) -__instantiate(ConstPtr) -__instantiate(Ptr) -__instantiate(ConstPtr) -__instantiate(Ptr) -__instantiate(ConstPtr) -__instantiate(Ptr) -__instantiate(ConstPtr) -__instantiate(Ptr) -__instantiate(ConstPtr) -__instantiate(Ptr) -__instantiate(ConstPtr) -__instantiate(Ptr) -__instantiate(ConstPtr) -__instantiate(CopyOwner) -__instantiate(CopyOwner) -__instantiate(CopyOwner) -__instantiate(CopyOwner) -__instantiate(NCVector >) -__instantiate(Vector >) -__instantiate(NCVector >) -__instantiate(Vector) -__instantiate(`HashTableItem') -__instantiate(`HashTable') -__instantiate(`HashTableItem') -__instantiate(`HashTable') -__instantiate(IList) -__instantiate(IList) -__instantiate(IList) -__instantiate(IList) -__instantiate(IList) -__instantiate(IList) -__instantiate(IList) -__instantiate(IQueue) -__instantiate(IQueue) -__instantiate(`OwnerTable') -__instantiate(`OwnerTableIter') -__instantiate(Owner) -__instantiate(Owner) -__instantiate(Owner) -__instantiate(Owner) -__instantiate(Owner) -__instantiate(Owner) -__instantiate(Owner) -__instantiate(Owner) -__instantiate(Owner) -__instantiate(Owner) -__instantiate(Owner) -__instantiate(Owner) -__instantiate(Owner) -__instantiate(Owner) -__instantiate(`PointerTableIter') -__instantiate(`PointerTable') -__instantiate(`PointerTable,StringC,Hash,NamedResourceKeyFunction>') -__instantiate(`PointerTableIter,StringC,Hash,NamedResourceKeyFunction>') -__instantiate(Vector >) -__instantiate(Vector) -__instantiate(Vector) -__instantiate(Vector) -__instantiate(Vector >) -__instantiate(Vector) -__instantiate(Vector) -__instantiate(Vector) -__instantiate(Vector) -__instantiate(Vector) -__instantiate(Vector) -__instantiate(Vector) -__instantiate(Vector) -__instantiate(Vector) -__instantiate(Vector >) -__instantiate(Vector >) -__instantiate(Vector) -__instantiate(Vector >) -__instantiate(Vector) -__instantiate(Vector) -__instantiate(Vector) -__instantiate(Vector) -__instantiate(Vector >) -__instantiate(Vector) -__instantiate(Vector) -__instantiate(Vector >) -__instantiate(Vector) -__instantiate(Vector) -__instantiate(Vector) -__instantiate(Vector) -__instantiate(Vector) - -__instantiate(NamedTable) -__instantiate(NamedTableIter) -__instantiate(IListIter) -__instantiate(IListIter) - -__instantiate(NamedResourceTable) -__instantiate(NamedResourceTable) -__instantiate(NamedResourceTableIter) -__instantiate(ConstNamedResourceTableIter) -__instantiate(ConstNamedResourceTableIter) - -__instantiate(Vector) -__instantiate(Vector >) -__instantiate(Vector > >) -__instantiate(Vector) -__instantiate(Vector >) -__instantiate(Vector >) -__instantiate(Vector) -__instantiate(`PointerTable') -__instantiate(`PointerTableIter') -__instantiate(`OwnerTable') -__instantiate(`OwnerTableIter') -__instantiate(IList) - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* SP_MANUAL_INST */ diff --git a/cde/programs/nsgmls/rtti.h b/cde/programs/nsgmls/rtti.h deleted file mode 100644 index 3d867b12c..000000000 --- a/cde/programs/nsgmls/rtti.h +++ /dev/null @@ -1,82 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: rtti.h /main/1 1996/07/29 17:09:50 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#ifndef rtti_INCLUDED -#define rtti_INCLUDED 1 - -#ifdef SP_HAVE_RTTI - -#define DYNAMIC_CAST_PTR(T, p) dynamic_cast(p) -#define DYNAMIC_CAST_CONST_PTR(T, p) dynamic_cast(p) - -#define RTTI_CLASS - -#define RTTI_DEF0(T) -#define RTTI_DEF1(T, B1) -#define RTTI_DEF2(T, B1, B2) -#define RTTI_DEF3(T, B1, B2, B3) - -#else /* not SP_HAVE_RTTI */ - -#include "TypeId.h" - -#define RTTI_CLASS \ -public: \ - virtual TypeId dynamicType() const; \ - static inline TypeId staticType() { return TypeId(RTTI_bases_); } \ -protected: \ - static const void *RTTI_bases_[]; \ -private: - -#define RTTI_DEF0(T) \ - const void *T::RTTI_bases_[] = { 0 }; \ - TypeId T::dynamicType() const { return staticType(); } - -#define RTTI_DEF1(T, B1) \ - const void *T::RTTI_bases_[] = { B1::RTTI_bases_, 0 }; \ - TypeId T::dynamicType() const { return staticType(); } - -#define RTTI_DEF2(T, B1, B2) \ - const void *T::RTTI_bases_[] = { B1::RTTI_bases_, B2::RTTI_bases_, 0 }; \ - TypeId T::dynamicType() const { return staticType(); } - -#define RTTI_DEF3(T, B1, B2, B3) \ - const void *T::RTTI_bases_[] = { \ - B1::RTTI_bases_, B2::RTTI_bases_, B3::RTTI_bases_, 0 }; \ - TypeId T::dynamicType() const { return staticType(); } - -#define DYNAMIC_CAST_PTR(T, p) \ -((p) && (p)->dynamicType().canCast(T::staticType(), (p)->staticType()) \ - ? (T *)(p) \ - : 0) -#define DYNAMIC_CAST_CONST_PTR(T, p) \ -((p) && (p)->dynamicType().canCast(T::staticType(), (p)->staticType()) \ - ? (const T *)p \ - : 0) - -#endif /* not SP_HAVE_RTTI */ - -#endif /* not rtti_INCLUDED */ diff --git a/cde/programs/nsgmls/splib.C b/cde/programs/nsgmls/splib.C deleted file mode 100644 index 6c3a22c7e..000000000 --- a/cde/programs/nsgmls/splib.C +++ /dev/null @@ -1,27 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: splib.C /main/1 1996/07/29 17:09:55 cde-hp $ */ -// This file is used to build the pre-compiled header on those -// systems that support it. - -#include "splib.h" diff --git a/cde/programs/nsgmls/splib.h b/cde/programs/nsgmls/splib.h deleted file mode 100644 index 361f6563e..000000000 --- a/cde/programs/nsgmls/splib.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: splib.h /main/1 1996/07/29 17:09:59 cde-hp $ */ -// Copyright (c) 1996 James Clark -// See the file COPYING for copying permission. - -// This file must be included first by all files in lib. - -#define BUILD_LIBSP -#include "config.h" -#ifdef SP_PCH -#include "splibpch.h" -#endif /* SP_PCH */ diff --git a/cde/programs/nsgmls/splibpch.h b/cde/programs/nsgmls/splibpch.h deleted file mode 100644 index 05f0bcda2..000000000 --- a/cde/programs/nsgmls/splibpch.h +++ /dev/null @@ -1,174 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: splibpch.h /main/1 1996/07/29 17:10:03 cde-hp $ */ -// Copyright (c) 1996 James Clark -// See the file COPYING for copying permission. - -// Include all header files for systems that support pre-compiled headers. - -#include "Allocator.h" -#include "ArcEngine.h" -#include "Attribute.h" -#include "Attributed.h" -#include "Boolean.h" -#include "CharsetDecl.h" -#include "CharsetInfo.h" -#include "CmdLineApp.h" -#include "CodingSystem.h" -#include "ConsoleOutput.h" -#include "ContentState.h" -#include "ContentToken.h" -#include "CopyOwner.h" -#include "DescriptorManager.h" -#include "Dtd.h" -#include "ElementType.h" -#include "Entity.h" -#include "EntityApp.h" -#include "EntityCatalog.h" -#include "EntityDecl.h" -#include "EntityManager.h" -#include "ErrnoMessageArg.h" -#include "ErrorCountEventHandler.h" -#include "Event.h" -#include "EventsWanted.h" -#include "ExtendEntityManager.h" -#include "ExternalId.h" -#include "GenericEventHandler.h" -#include "Hash.h" -#include "HashTable.h" -#include "HashTableItemBase.h" -#include "IList.h" -#include "IListBase.h" -#include "IListIter.h" -#include "IListIterBase.h" -#include "IQueue.h" -#include "ISet.h" -#include "ISetIter.h" -#include "IdentityCodingSystem.h" -#include "InputSource.h" -#include "Link.h" -#include "LinkProcess.h" -#include "List.h" -#include "ListIter.h" -#include "LiteralStorage.h" -#include "Location.h" -#include "Lpd.h" -#include "Markup.h" -#include "Message.h" -#include "MessageArg.h" -#include "MessageBuilder.h" -#include "MessageEventHandler.h" -#include "MessageReporter.h" -#include "Mode.h" -#include "NCVector.h" -#include "Named.h" -#include "NamedResource.h" -#include "NamedResourceTable.h" -#include "NamedTable.h" -#include "Notation.h" -#include "OpenElement.h" -#include "Options.h" -#include "OutputCharStream.h" -#include "Owner.h" -#include "OwnerTable.h" -#include "ParserApp.h" -#include "ParserOptions.h" -#include "PointerTable.h" -#include "PosixStorage.h" -#include "Ptr.h" -#include "RangeMap.h" -#include "Resource.h" -#include "RewindStorageObject.h" -#include "SOEntityCatalog.h" -#include "Sd.h" -#include "SdText.h" -#include "SearchResultMessageArg.h" -#include "SgmlParser.h" -#include "ShortReferenceMap.h" -#include "StdioStorage.h" -#include "StorageManager.h" -#include "StringC.h" -#include "StringOf.h" -#include "StringResource.h" -#include "SubstTable.h" -#include "Syntax.h" -#include "Text.h" -#include "TranslateInputCodingSystem.h" -#include "TypeId.h" -#include "URLStorage.h" -#include "UnivCharsetDesc.h" -#include "Vector.h" -#include "XcharMap.h" -#include "config.h" -#include "constant.h" -#include "macros.h" -#include "rtti.h" -#include "sptchar.h" -#include "types.h" -#include "xnew.h" -#ifdef SP_MULTI_BYTE -#include "EUCJPCodingSystem.h" -#include "Fixed2CodingSystem.h" -#include "ISO8859InputCodingSystem.h" -#include "SJISCodingSystem.h" -#include "UnicodeCodingSystem.h" -#include "UTF8CodingSystem.h" -#ifdef WIN32 -#include "Win32CodingSystem.h" -#endif -#endif /* SP_MULTI_BYTE */ -#include "EventGenerator.h" -#include "ParserEventGeneratorKit.h" -#include "SGMLApplication.h" -#include "ArcProcessor.h" -#include "CatalogEntry.h" -#include "CharsetRegistry.h" -#include "EquivClass.h" -#include "EventQueue.h" -#include "Group.h" -#include "Id.h" -#include "InternalInputSource.h" -#include "LpdEntityRef.h" -#include "MarkupScan.h" -#include "ModeInfo.h" -#include "NameToken.h" -#include "NumericCharRefOrigin.h" -#include "OffsetOrderedList.h" -#include "OutputState.h" -#include "Param.h" -#include "Parser.h" -#include "ParserMessages.h" -#include "ParserState.h" -#include "Partition.h" -#include "Priority.h" -#include "Recognizer.h" -#include "RegisteredCodingSystem.h" -#include "SdFormalError.h" -#include "SrInfo.h" -#include "StorageObjectPosition.h" -#include "StringVectorMessageArg.h" -#include "TokenMessageArg.h" -#include "Trie.h" -#include "TrieBuilder.h" -#include "Undo.h" -#include "token.h" diff --git a/cde/programs/nsgmls/sptchar.h b/cde/programs/nsgmls/sptchar.h deleted file mode 100644 index ab2e15292..000000000 --- a/cde/programs/nsgmls/sptchar.h +++ /dev/null @@ -1,183 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: sptchar.h /main/1 1996/07/29 17:10:09 cde-hp $ */ -// Copyright (c) 1996 James Clark -// See the file COPYING for copying permission. - -#ifndef sptchar_INCLUDED -#define sptchar_INCLUDED 1 - -#include -#include -#include -#include - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -#ifdef SP_WIDE_SYSTEM - -// typedef wchar_t SP_TCHAR; -// typedef wchar_t SP_TUCHAR; -#define SP_TCHAR wchar_t -#define SP_TUCHAR wchar_t - -#define SP_T(x) L ## x - -inline -wchar_t *tgetenv(const wchar_t *s) -{ - return _wgetenv(s); -} - -inline -int tcscmp(const wchar_t *s1, const wchar_t *s2) -{ - return wcscmp(s1, s2); -} - -inline -int tcsncmp(const wchar_t *s1, const wchar_t *s2, size_t n) -{ - return wcsncmp(s1, s2, n); -} - -inline -unsigned long tcstoul(const wchar_t *s, const wchar_t **sp, int base) -{ - return wcstoul((wchar_t *)s, (wchar_t **)sp, base); -} - -inline -unsigned long tcstoul(wchar_t *s, wchar_t **sp, int base) -{ - return wcstoul(s, sp, base); -} - -inline -const wchar_t *tcschr(const wchar_t *s, wint_t c) -{ - return wcschr(s, c); -} - -inline -wchar_t *tcschr(wchar_t *s, wint_t c) -{ - return wcschr(s, c); -} - -inline -size_t tcslen(const wchar_t *s) -{ - return wcslen(s); -} - -inline -int fputts(const wchar_t *s, FILE *fp) -{ - return fputws(s, fp); -} - -inline -int totupper(wint_t c) -{ - return towupper(c); -} - -#else /* not SP_WIDE_SYSTEM */ - -// typedef char SP_TCHAR; -// typedef unsigned char SP_TUCHAR; -#define SP_TCHAR char -#define SP_TUCHAR unsigned char - -#define SP_T(x) x - -inline -char *tgetenv(const char *s) -{ - return getenv(s); -} - -inline -int tcscmp(const char *s1, const char *s2) -{ - return strcmp(s1, s2); -} - -inline -int tcsncmp(const char *s1, const char *s2, size_t n) -{ - return strncmp(s1, s2, n); -} - -inline -unsigned long tcstoul(const char *s, const char **sp, int base) -{ - return strtoul((char *)s, (char **)sp, base); -} - -inline -unsigned long tcstoul(char *s, char **sp, int base) -{ - return strtoul(s, sp, base); -} - -inline -const char *tcschr(const char *s, int c) -{ - return strchr(s, c); -} - -inline -char *tcschr(char *s, int c) -{ - return strchr(s, c); -} - -inline -size_t tcslen(const char *s) -{ - return strlen(s); -} - -inline -int fputts(const char *s, FILE *fp) -{ - return fputs(s, fp); -} - -inline -int totupper(int c) -{ - return toupper(c); -} - -#endif /* not SP_WIDE_SYSTEM */ - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* not sptchar_INCLUDED */ diff --git a/cde/programs/nsgmls/token.h b/cde/programs/nsgmls/token.h deleted file mode 100644 index 851c9e1b8..000000000 --- a/cde/programs/nsgmls/token.h +++ /dev/null @@ -1,103 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: token.h /main/1 1996/07/29 17:10:14 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#ifndef token_INCLUDED -#define token_INCLUDED 1 - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -enum EnumToken { - // tokenUnrecognized must be 0 - tokenUnrecognized, // no token could be recognized - tokenEe, // end of entity - tokenS, // RS RE SPACE SEPCHAR - tokenRe, // RE - tokenRs, // RS - tokenSpace, // SPACE - tokenSepchar, // SEPCHAR - tokenNameStart, // X - tokenDigit, // 1 - tokenLcUcNmchar, // LCNMCHAR or UCNMCHAR - tokenChar, // a legal data character - tokenIgnoredChar, // character in ignored marked section - // delimiters and delimiters in context - tokenAnd, - tokenCom, - tokenCroDigit, - tokenCroNameStart, - tokenDsc, - tokenDso, - tokenDtgc, - tokenDtgo, - tokenEroNameStart, - tokenEroGrpo, - tokenEtago, - tokenEtagoNameStart, - tokenEtagoTagc, - tokenEtagoGrpo, - tokenGrpc, - tokenGrpo, - tokenLit, - tokenLita, - tokenMdc, - tokenMdoNameStart, - tokenMdoMdc, - tokenMdoCom, - tokenMdoDso, - tokenMinus, - tokenMinusGrpo, - tokenMscMdc, - tokenNet, - tokenOpt, - tokenOr, - tokenPero, - tokenPeroNameStart, - tokenPeroGrpo, - tokenPic, - tokenPio, - tokenPlus, - tokenPlusGrpo, - tokenRefc, - tokenRep, - tokenRni, - tokenSeq, - tokenStago, - tokenStagoNameStart, - tokenStagoTagc, - tokenStagoGrpo, - tokenTagc, - tokenVi, - // short references start here - tokenFirstShortref -}; - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* not token_INCLUDED */ diff --git a/cde/programs/nsgmls/types.h b/cde/programs/nsgmls/types.h deleted file mode 100644 index 32d87eb46..000000000 --- a/cde/programs/nsgmls/types.h +++ /dev/null @@ -1,92 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: types.h /main/1 1996/07/29 17:10:18 cde-hp $ */ -// Copyright (c) 1994 James Clark -// See the file COPYING for copying permission. - -#ifndef types_INCLUDED -#define types_INCLUDED 1 - -#include -#include - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -#if UINT_MAX >= 0xffffffffL /* 2^32 - 1 */ -typedef unsigned int Unsigned32; -#else -typedef unsigned long Unsigned32; -#endif - -// Number holds values between 0 and 99999999 (eight nines). -typedef Unsigned32 Number; -typedef Unsigned32 Offset; -typedef Unsigned32 Index; - -#ifdef SP_MULTI_BYTE - -#ifdef SP_WCHAR_T_USHORT -typedef wchar_t Char; -#else -typedef unsigned short Char; -#endif - -#if INT_MAX > 65535L -typedef int Xchar; -#else /* INT_MAX <= 65535L */ -typedef long Xchar; -#endif /* INT_MAX <= 65535L */ - -#else /* not SP_MULTI_BYTE */ - -typedef unsigned char Char; -// This holds any value of type Char plus InputSource:eE (= -1). -typedef int Xchar; - -#endif /* not SP_MULTI_BYTE */ - -typedef Unsigned32 UnivChar; -typedef Unsigned32 WideChar; - -// A character in a syntax reference character set. -// We might want to compile with wide syntax reference characters -// (since they're cheap) but not with wide document characters. -typedef Unsigned32 SyntaxChar; - -typedef unsigned short CharClassIndex; - -typedef unsigned Token; - -#ifdef SP_MULTI_BYTE -typedef unsigned short EquivCode; -#else -typedef unsigned char EquivCode; -#endif - -#ifdef SP_NAMESPACE -} -#endif - -#endif /* not types_INCLUDED */ diff --git a/cde/programs/nsgmls/version.h b/cde/programs/nsgmls/version.h deleted file mode 100644 index c8497a197..000000000 --- a/cde/programs/nsgmls/version.h +++ /dev/null @@ -1,24 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: version.h /main/1 1996/07/29 17:10:22 cde-hp $ */ -#define SP_VERSION SP_T("1.1") diff --git a/cde/programs/nsgmls/xentmgr_inst.m4 b/cde/programs/nsgmls/xentmgr_inst.m4 deleted file mode 100644 index 3a6c056bf..000000000 --- a/cde/programs/nsgmls/xentmgr_inst.m4 +++ /dev/null @@ -1,75 +0,0 @@ -/* $XConsortium: xentmgr_inst.m4 /main/2 1996/08/09 15:34:03 mgreess $ */ -// Copyright (c) 1994, 1995 James Clark -// See the file COPYING for copying permission. - -#include "splib.h" - -#ifdef SP_MANUAL_INST - -#define SP_DEFINE_TEMPLATES -#include "StringOf.h" -#include "Vector.h" -#include "NCVector.h" -#include "ListIter.h" -#include "IList.h" -#include "List.h" -#include "Owner.h" -#include "OwnerTable.h" -#include "PointerTable.h" -#include "HashTableItemBase.h" -#include "HashTable.h" -#include "Ptr.h" -#undef SP_DEFINE_TEMPLATES - -#include "StorageManager.h" -#include "ExtendEntityManager.h" -#include "OffsetOrderedList.h" -#include "CodingSystem.h" -#include "types.h" -#include "StringOf.h" -#include "DescriptorManager.h" -#include "StorageManager.h" -#include "Boolean.h" -#include "RegisteredCodingSystem.h" -#include "StorageObjectPosition.h" -#include "CatalogEntry.h" - -#ifdef SP_NAMESPACE -namespace SP_NAMESPACE { -#endif - -__instantiate(String) -__instantiate(NCVector >) -__instantiate(Vector) -__instantiate(NCVector >) -__instantiate(NCVector) -__instantiate(IList >) -__instantiate(List) -__instantiate(ListIter) -__instantiate(ListItem) -__instantiate(IListIter >) -__instantiate(Owner) -__instantiate(Owner) -__instantiate(Owner) -__instantiate(Owner) -__instantiate(Owner) -__instantiate(NCVector >) -__instantiate(Vector) -__instantiate(`HashTable,CatalogEntry>') -__instantiate(`HashTableIter,CatalogEntry>') -__instantiate(`HashTableItem,CatalogEntry>') -__instantiate(HashTableItemBase >) -__instantiate(`OwnerTable >,String,Hash,HashTableKeyFunction > >') -__instantiate(`CopyOwnerTable >,String,Hash,HashTableKeyFunction > >') -__instantiate(`OwnerTableIter >, String, Hash, HashTableKeyFunction > >') -__instantiate(`PointerTable >*,String,Hash,HashTableKeyFunction > >') -__instantiate(`PointerTableIter > *, String, Hash, HashTableKeyFunction > >') -__instantiate(Vector >*>) -__instantiate(Ptr) -__instantiate(ConstPtr) -__instantiate(Vector) -#ifdef SP_NAMESPACE -} -#endif - -#endif /* SP_MANUAL_INST */ diff --git a/cde/programs/nsgmls/xnew.h b/cde/programs/nsgmls/xnew.h deleted file mode 100644 index 85a3fe55b..000000000 --- a/cde/programs/nsgmls/xnew.h +++ /dev/null @@ -1,60 +0,0 @@ -/* - * CDE - Common Desktop Environment - * - * Copyright (c) 1993-2012, The Open Group. All rights reserved. - * - * These libraries and programs are free software; you can - * redistribute them and/or modify them under the terms of the GNU - * Lesser General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * These libraries and programs are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with these libraries and programs; if not, write - * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth - * Floor, Boston, MA 02110-1301 USA - */ -/* $XConsortium: xnew.h /main/1 1996/07/29 17:10:33 cde-hp $ */ -#ifndef xnew_INCLUDED -#define xnew_INCLUDED 1 - -#ifdef SP_NEW_H_MISSING - -typedef void (*VFP)(); - -#ifdef SP_SET_NEW_HANDLER_EXTERN_C -extern "C" -#endif -void set_new_handler(VFP); - -#ifndef SP_DECLARE_PLACEMENT_OPERATOR_NEW -#define SP_DECLARE_PLACEMENT_OPERATOR_NEW -#endif - -#else /* not SP_NEW_H_MISSING */ - -#if defined(__linux__) || defined(CSRG_BASED) || defined(sun) -#include -#else -#include -#endif - -#endif /* not SP_NEW_H_MISSING */ - -#ifdef SP_DECLARE_PLACEMENT_OPERATOR_NEW - -inline -void *operator new(size_t, void *p) -{ - return p; -} - -#endif /* SP_DECLARE_PLACEMENT_OPERATOR_NEW */ - -#endif /* not xnew_INCLUDED */