Merge mozilla-central to autoland

This commit is contained in:
Carsten "Tomcat" Book 2016-09-22 13:44:33 +02:00
Родитель 94429143e5 d25a5baeb8
Коммит cae9054451
783 изменённых файлов: 7931 добавлений и 94010 удалений

Просмотреть файл

@ -82,6 +82,7 @@ devtools/client/debugger/**
devtools/client/eyedropper/** devtools/client/eyedropper/**
devtools/client/framework/** devtools/client/framework/**
!devtools/client/framework/selection.js !devtools/client/framework/selection.js
!devtools/client/framework/toolbox.js
devtools/client/jsonview/lib/** devtools/client/jsonview/lib/**
devtools/client/memory/** devtools/client/memory/**
devtools/client/netmonitor/test/** devtools/client/netmonitor/test/**

Просмотреть файл

@ -81,6 +81,10 @@ TreeWalker::Seek(nsIContent* aChildNode)
Reset(); Reset();
if (mAnchorNode == aChildNode) {
return true;
}
nsIContent* childNode = nullptr; nsIContent* childNode = nullptr;
nsINode* parentNode = aChildNode; nsINode* parentNode = aChildNode;
do { do {

Просмотреть файл

@ -132,6 +132,27 @@ public:
bool IsDoc() const { return mIsDoc; } bool IsDoc() const { return mIsDoc; }
DocAccessibleParent* AsDoc() const { return IsDoc() ? mDoc : nullptr; } DocAccessibleParent* AsDoc() const { return IsDoc() ? mDoc : nullptr; }
// XXX checking mRole alone may not result in same behavior as Accessibles
// due to ARIA roles. See bug 1210477.
inline bool IsTable() const
{
return mRole == roles::TABLE || mRole == roles::MATHML_TABLE;
}
inline bool IsTableRow() const
{
return (mRole == roles::ROW ||
mRole == roles::MATHML_TABLE_ROW ||
mRole == roles::MATHML_LABELED_ROW);
}
inline bool IsTableCell() const
{
return (mRole == roles::CELL ||
mRole == roles::COLUMNHEADER ||
mRole == roles::ROWHEADER ||
mRole == roles::GRID_CELL ||
mRole == roles::MATHML_CELL);
}
protected: protected:
ProxyAccessibleBase(uint64_t aID, Derived* aParent, ProxyAccessibleBase(uint64_t aID, Derived* aParent,
DocAccessibleParent* aDoc, role aRole, DocAccessibleParent* aDoc, role aRole,

Просмотреть файл

@ -0,0 +1,272 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef mozilla_a11y_ProxyAccessibleShared_h
#define mozilla_a11y_ProxyAccessibleShared_h
/**
* These are function declarations shared between win/ProxyAccessible.h and
* other/ProxyAccessible.h.
*/
/*
* Return the states for the proxied accessible.
*/
uint64_t State() const;
/*
* Return the native states for the proxied accessible.
*/
uint64_t NativeState() const;
/*
* Set aName to the name of the proxied accessible.
*/
void Name(nsString& aName) const;
/*
* Set aValue to the value of the proxied accessible.
*/
void Value(nsString& aValue) const;
/*
* Set aHelp to the help string of the proxied accessible.
*/
void Help(nsString& aHelp) const;
/**
* Set aDesc to the description of the proxied accessible.
*/
void Description(nsString& aDesc) const;
/**
* Get the set of attributes on the proxied accessible.
*/
void Attributes(nsTArray<Attribute> *aAttrs) const;
/**
* Return set of targets of given relation type.
*/
nsTArray<ProxyAccessible*> RelationByType(RelationType aType) const;
/**
* Get all relations for this accessible.
*/
void Relations(nsTArray<RelationType>* aTypes,
nsTArray<nsTArray<ProxyAccessible*>>* aTargetSets) const;
bool IsSearchbox() const;
nsIAtom* LandmarkRole() const;
nsIAtom* ARIARoleAtom() const;
int32_t GetLevelInternal();
void ScrollTo(uint32_t aScrollType);
void ScrollToPoint(uint32_t aScrollType, int32_t aX, int32_t aY);
int32_t CaretLineNumber();
int32_t CaretOffset();
void SetCaretOffset(int32_t aOffset);
int32_t CharacterCount();
int32_t SelectionCount();
/**
* Get the text between the given offsets.
*/
bool TextSubstring(int32_t aStartOffset, int32_t aEndOfset,
nsString& aText) const;
void GetTextAfterOffset(int32_t aOffset, AccessibleTextBoundary aBoundaryType,
nsString& aText, int32_t* aStartOffset,
int32_t* aEndOffset);
void GetTextAtOffset(int32_t aOffset, AccessibleTextBoundary aBoundaryType,
nsString& aText, int32_t* aStartOffset,
int32_t* aEndOffset);
void GetTextBeforeOffset(int32_t aOffset, AccessibleTextBoundary aBoundaryType,
nsString& aText, int32_t* aStartOffset,
int32_t* aEndOffset);
char16_t CharAt(int32_t aOffset);
void TextAttributes(bool aIncludeDefAttrs,
const int32_t aOffset,
nsTArray<Attribute>* aAttributes,
int32_t* aStartOffset,
int32_t* aEndOffset);
void DefaultTextAttributes(nsTArray<Attribute>* aAttrs);
nsIntRect TextBounds(int32_t aStartOffset, int32_t aEndOffset,
uint32_t aCoordType = nsIAccessibleCoordinateType::COORDTYPE_SCREEN_RELATIVE);
nsIntRect CharBounds(int32_t aOffset, uint32_t aCoordType);
int32_t OffsetAtPoint(int32_t aX, int32_t aY, uint32_t aCoordType);
bool SelectionBoundsAt(int32_t aSelectionNum,
nsString& aData,
int32_t* aStartOffset,
int32_t* aEndOffset);
bool SetSelectionBoundsAt(int32_t aSelectionNum,
int32_t aStartOffset,
int32_t aEndOffset);
bool AddToSelection(int32_t aStartOffset,
int32_t aEndOffset);
bool RemoveFromSelection(int32_t aSelectionNum);
void ScrollSubstringTo(int32_t aStartOffset, int32_t aEndOffset,
uint32_t aScrollType);
void ScrollSubstringToPoint(int32_t aStartOffset,
int32_t aEndOffset,
uint32_t aCoordinateType,
int32_t aX, int32_t aY);
void Text(nsString* aText);
void ReplaceText(const nsString& aText);
bool InsertText(const nsString& aText, int32_t aPosition);
bool CopyText(int32_t aStartPos, int32_t aEndPos);
bool CutText(int32_t aStartPos, int32_t aEndPos);
bool DeleteText(int32_t aStartPos, int32_t aEndPos);
bool PasteText(int32_t aPosition);
nsIntPoint ImagePosition(uint32_t aCoordType);
nsIntSize ImageSize();
uint32_t StartOffset(bool* aOk);
uint32_t EndOffset(bool* aOk);
bool IsLinkValid();
uint32_t AnchorCount(bool* aOk);
void AnchorURIAt(uint32_t aIndex, nsCString& aURI, bool* aOk);
ProxyAccessible* AnchorAt(uint32_t aIndex);
uint32_t LinkCount();
ProxyAccessible* LinkAt(const uint32_t& aIndex);
int32_t LinkIndexOf(ProxyAccessible* aLink);
int32_t LinkIndexAtOffset(uint32_t aOffset);
ProxyAccessible* TableOfACell();
uint32_t ColIdx();
uint32_t RowIdx();
uint32_t ColExtent();
uint32_t RowExtent();
void ColHeaderCells(nsTArray<ProxyAccessible*>* aCells);
void RowHeaderCells(nsTArray<ProxyAccessible*>* aCells);
bool IsCellSelected();
ProxyAccessible* TableCaption();
void TableSummary(nsString& aSummary);
uint32_t TableColumnCount();
uint32_t TableRowCount();
ProxyAccessible* TableCellAt(uint32_t aRow, uint32_t aCol);
int32_t TableCellIndexAt(uint32_t aRow, uint32_t aCol);
int32_t TableColumnIndexAt(uint32_t aCellIndex);
int32_t TableRowIndexAt(uint32_t aCellIndex);
void TableRowAndColumnIndicesAt(uint32_t aCellIndex,
int32_t* aRow, int32_t* aCol);
uint32_t TableColumnExtentAt(uint32_t aRow, uint32_t aCol);
uint32_t TableRowExtentAt(uint32_t aRow, uint32_t aCol);
void TableColumnDescription(uint32_t aCol, nsString& aDescription);
void TableRowDescription(uint32_t aRow, nsString& aDescription);
bool TableColumnSelected(uint32_t aCol);
bool TableRowSelected(uint32_t aRow);
bool TableCellSelected(uint32_t aRow, uint32_t aCol);
uint32_t TableSelectedCellCount();
uint32_t TableSelectedColumnCount();
uint32_t TableSelectedRowCount();
void TableSelectedCells(nsTArray<ProxyAccessible*>* aCellIDs);
void TableSelectedCellIndices(nsTArray<uint32_t>* aCellIndices);
void TableSelectedColumnIndices(nsTArray<uint32_t>* aColumnIndices);
void TableSelectedRowIndices(nsTArray<uint32_t>* aRowIndices);
void TableSelectColumn(uint32_t aCol);
void TableSelectRow(uint32_t aRow);
void TableUnselectColumn(uint32_t aCol);
void TableUnselectRow(uint32_t aRow);
bool TableIsProbablyForLayout();
ProxyAccessible* AtkTableColumnHeader(int32_t aCol);
ProxyAccessible* AtkTableRowHeader(int32_t aRow);
void SelectedItems(nsTArray<ProxyAccessible*>* aSelectedItems);
uint32_t SelectedItemCount();
ProxyAccessible* GetSelectedItem(uint32_t aIndex);
bool IsItemSelected(uint32_t aIndex);
bool AddItemToSelection(uint32_t aIndex);
bool RemoveItemFromSelection(uint32_t aIndex);
bool SelectAll();
bool UnselectAll();
void TakeSelection();
void SetSelected(bool aSelect);
bool DoAction(uint8_t aIndex);
uint8_t ActionCount();
void ActionDescriptionAt(uint8_t aIndex, nsString& aDescription);
void ActionNameAt(uint8_t aIndex, nsString& aName);
KeyBinding AccessKey();
KeyBinding KeyboardShortcut();
void AtkKeyBinding(nsString& aBinding);
double CurValue();
bool SetCurValue(double aValue);
double MinValue();
double MaxValue();
double Step();
void TakeFocus();
ProxyAccessible* FocusedChild();
ProxyAccessible* ChildAtPoint(int32_t aX, int32_t aY,
Accessible::EWhichChildAtPoint aWhichChild);
nsIntRect Bounds();
void Language(nsString& aLocale);
void DocType(nsString& aType);
void Title(nsString& aTitle);
void URL(nsString& aURL);
void MimeType(nsString aMime);
void URLDocTypeMimeType(nsString& aURL, nsString& aDocType,
nsString& aMimeType);
ProxyAccessible* AccessibleAtPoint(int32_t aX, int32_t aY,
bool aNeedsScreenCoords);
void Extents(bool aNeedsScreenCoords, int32_t* aX, int32_t* aY,
int32_t* aWidth, int32_t* aHeight);
/**
* Return the id of the dom node this accessible represents. Note this
* should probably only be used for testing.
*/
void DOMNodeID(nsString& aID);
#endif

Просмотреть файл

@ -37,6 +37,7 @@ if CONFIG['ACCESSIBILITY']:
'DocAccessibleChildBase.h', 'DocAccessibleChildBase.h',
'DocAccessibleParent.h', 'DocAccessibleParent.h',
'ProxyAccessibleBase.h', 'ProxyAccessibleBase.h',
'ProxyAccessibleShared.h',
] ]
UNIFIED_SOURCES += [ UNIFIED_SOURCES += [

Просмотреть файл

@ -36,283 +36,7 @@ public:
MOZ_COUNT_DTOR(ProxyAccessible); MOZ_COUNT_DTOR(ProxyAccessible);
} }
/* #include "mozilla/a11y/ProxyAccessibleShared.h"
* Return the states for the proxied accessible.
*/
uint64_t State() const;
/*
* Return the native states for the proxied accessible.
*/
uint64_t NativeState() const;
/*
* Set aName to the name of the proxied accessible.
*/
void Name(nsString& aName) const;
/*
* Set aValue to the value of the proxied accessible.
*/
void Value(nsString& aValue) const;
/*
* Set aHelp to the help string of the proxied accessible.
*/
void Help(nsString& aHelp) const;
/**
* Set aDesc to the description of the proxied accessible.
*/
void Description(nsString& aDesc) const;
/**
* Get the set of attributes on the proxied accessible.
*/
void Attributes(nsTArray<Attribute> *aAttrs) const;
/**
* Return set of targets of given relation type.
*/
nsTArray<ProxyAccessible*> RelationByType(RelationType aType) const;
/**
* Get all relations for this accessible.
*/
void Relations(nsTArray<RelationType>* aTypes,
nsTArray<nsTArray<ProxyAccessible*>>* aTargetSets) const;
bool IsSearchbox() const;
nsIAtom* LandmarkRole() const;
nsIAtom* ARIARoleAtom() const;
int32_t GetLevelInternal();
void ScrollTo(uint32_t aScrollType);
void ScrollToPoint(uint32_t aScrollType, int32_t aX, int32_t aY);
int32_t CaretLineNumber();
int32_t CaretOffset();
void SetCaretOffset(int32_t aOffset);
int32_t CharacterCount();
int32_t SelectionCount();
/**
* Get the text between the given offsets.
*/
bool TextSubstring(int32_t aStartOffset, int32_t aEndOfset,
nsString& aText) const;
void GetTextAfterOffset(int32_t aOffset, AccessibleTextBoundary aBoundaryType,
nsString& aText, int32_t* aStartOffset,
int32_t* aEndOffset);
void GetTextAtOffset(int32_t aOffset, AccessibleTextBoundary aBoundaryType,
nsString& aText, int32_t* aStartOffset,
int32_t* aEndOffset);
void GetTextBeforeOffset(int32_t aOffset, AccessibleTextBoundary aBoundaryType,
nsString& aText, int32_t* aStartOffset,
int32_t* aEndOffset);
char16_t CharAt(int32_t aOffset);
void TextAttributes(bool aIncludeDefAttrs,
const int32_t aOffset,
nsTArray<Attribute>* aAttributes,
int32_t* aStartOffset,
int32_t* aEndOffset);
void DefaultTextAttributes(nsTArray<Attribute>* aAttrs);
nsIntRect TextBounds(int32_t aStartOffset, int32_t aEndOffset,
uint32_t aCoordType = nsIAccessibleCoordinateType::COORDTYPE_SCREEN_RELATIVE);
nsIntRect CharBounds(int32_t aOffset, uint32_t aCoordType);
int32_t OffsetAtPoint(int32_t aX, int32_t aY, uint32_t aCoordType);
bool SelectionBoundsAt(int32_t aSelectionNum,
nsString& aData,
int32_t* aStartOffset,
int32_t* aEndOffset);
bool SetSelectionBoundsAt(int32_t aSelectionNum,
int32_t aStartOffset,
int32_t aEndOffset);
bool AddToSelection(int32_t aStartOffset,
int32_t aEndOffset);
bool RemoveFromSelection(int32_t aSelectionNum);
void ScrollSubstringTo(int32_t aStartOffset, int32_t aEndOffset,
uint32_t aScrollType);
void ScrollSubstringToPoint(int32_t aStartOffset,
int32_t aEndOffset,
uint32_t aCoordinateType,
int32_t aX, int32_t aY);
void Text(nsString* aText);
void ReplaceText(const nsString& aText);
bool InsertText(const nsString& aText, int32_t aPosition);
bool CopyText(int32_t aStartPos, int32_t aEndPos);
bool CutText(int32_t aStartPos, int32_t aEndPos);
bool DeleteText(int32_t aStartPos, int32_t aEndPos);
bool PasteText(int32_t aPosition);
nsIntPoint ImagePosition(uint32_t aCoordType);
nsIntSize ImageSize();
uint32_t StartOffset(bool* aOk);
uint32_t EndOffset(bool* aOk);
bool IsLinkValid();
// XXX checking mRole alone may not result in same behavior as Accessibles
// due to ARIA roles. See bug 1210477.
inline bool IsTable() const
{
return mRole == roles::TABLE || mRole == roles::MATHML_TABLE;
}
inline bool IsTableRow() const
{
return (mRole == roles::ROW ||
mRole == roles::MATHML_TABLE_ROW ||
mRole == roles::MATHML_LABELED_ROW);
}
inline bool IsTableCell() const
{
return (mRole == roles::CELL ||
mRole == roles::COLUMNHEADER ||
mRole == roles::ROWHEADER ||
mRole == roles::GRID_CELL ||
mRole == roles::MATHML_CELL);
}
uint32_t AnchorCount(bool* aOk);
void AnchorURIAt(uint32_t aIndex, nsCString& aURI, bool* aOk);
ProxyAccessible* AnchorAt(uint32_t aIndex);
uint32_t LinkCount();
ProxyAccessible* LinkAt(const uint32_t& aIndex);
int32_t LinkIndexOf(ProxyAccessible* aLink);
int32_t LinkIndexAtOffset(uint32_t aOffset);
ProxyAccessible* TableOfACell();
uint32_t ColIdx();
uint32_t RowIdx();
uint32_t ColExtent();
uint32_t RowExtent();
void ColHeaderCells(nsTArray<ProxyAccessible*>* aCells);
void RowHeaderCells(nsTArray<ProxyAccessible*>* aCells);
bool IsCellSelected();
ProxyAccessible* TableCaption();
void TableSummary(nsString& aSummary);
uint32_t TableColumnCount();
uint32_t TableRowCount();
ProxyAccessible* TableCellAt(uint32_t aRow, uint32_t aCol);
int32_t TableCellIndexAt(uint32_t aRow, uint32_t aCol);
int32_t TableColumnIndexAt(uint32_t aCellIndex);
int32_t TableRowIndexAt(uint32_t aCellIndex);
void TableRowAndColumnIndicesAt(uint32_t aCellIndex,
int32_t* aRow, int32_t* aCol);
uint32_t TableColumnExtentAt(uint32_t aRow, uint32_t aCol);
uint32_t TableRowExtentAt(uint32_t aRow, uint32_t aCol);
void TableColumnDescription(uint32_t aCol, nsString& aDescription);
void TableRowDescription(uint32_t aRow, nsString& aDescription);
bool TableColumnSelected(uint32_t aCol);
bool TableRowSelected(uint32_t aRow);
bool TableCellSelected(uint32_t aRow, uint32_t aCol);
uint32_t TableSelectedCellCount();
uint32_t TableSelectedColumnCount();
uint32_t TableSelectedRowCount();
void TableSelectedCells(nsTArray<ProxyAccessible*>* aCellIDs);
void TableSelectedCellIndices(nsTArray<uint32_t>* aCellIndices);
void TableSelectedColumnIndices(nsTArray<uint32_t>* aColumnIndices);
void TableSelectedRowIndices(nsTArray<uint32_t>* aRowIndices);
void TableSelectColumn(uint32_t aCol);
void TableSelectRow(uint32_t aRow);
void TableUnselectColumn(uint32_t aCol);
void TableUnselectRow(uint32_t aRow);
bool TableIsProbablyForLayout();
ProxyAccessible* AtkTableColumnHeader(int32_t aCol);
ProxyAccessible* AtkTableRowHeader(int32_t aRow);
void SelectedItems(nsTArray<ProxyAccessible*>* aSelectedItems);
uint32_t SelectedItemCount();
ProxyAccessible* GetSelectedItem(uint32_t aIndex);
bool IsItemSelected(uint32_t aIndex);
bool AddItemToSelection(uint32_t aIndex);
bool RemoveItemFromSelection(uint32_t aIndex);
bool SelectAll();
bool UnselectAll();
void TakeSelection();
void SetSelected(bool aSelect);
bool DoAction(uint8_t aIndex);
uint8_t ActionCount();
void ActionDescriptionAt(uint8_t aIndex, nsString& aDescription);
void ActionNameAt(uint8_t aIndex, nsString& aName);
KeyBinding AccessKey();
KeyBinding KeyboardShortcut();
void AtkKeyBinding(nsString& aBinding);
double CurValue();
bool SetCurValue(double aValue);
double MinValue();
double MaxValue();
double Step();
void TakeFocus();
ProxyAccessible* FocusedChild();
ProxyAccessible* ChildAtPoint(int32_t aX, int32_t aY,
Accessible::EWhichChildAtPoint aWhichChild);
nsIntRect Bounds();
void Language(nsString& aLocale);
void DocType(nsString& aType);
void Title(nsString& aTitle);
void URL(nsString& aURL);
void MimeType(nsString aMime);
void URLDocTypeMimeType(nsString& aURL, nsString& aDocType,
nsString& aMimeType);
ProxyAccessible* AccessibleAtPoint(int32_t aX, int32_t aY,
bool aNeedsScreenCoords);
void Extents(bool aNeedsScreenCoords, int32_t* aX, int32_t* aY,
int32_t* aWidth, int32_t* aHeight);
/**
* Return the id of the dom node this accessible represents. Note this
* should probably only be used for testing.
*/
void DOMNodeID(nsString& aID);
protected: protected:
explicit ProxyAccessible(DocAccessibleParent* aThisAsDoc) explicit ProxyAccessible(DocAccessibleParent* aThisAsDoc)

Просмотреть файл

@ -4,6 +4,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
include protocol PFileDescriptorSet;
include protocol PBrowser; include protocol PBrowser;
using mozilla::a11y::IAccessibleHolder from "mozilla/a11y/COMPtrTypes.h"; using mozilla::a11y::IAccessibleHolder from "mozilla/a11y/COMPtrTypes.h";

Просмотреть файл

@ -39,34 +39,7 @@ public:
MOZ_COUNT_DTOR(ProxyAccessible); MOZ_COUNT_DTOR(ProxyAccessible);
} }
/* #include "mozilla/a11y/ProxyAccessibleShared.h"
* Return the states for the proxied accessible.
*/
uint64_t State() const;
/*
* Set aName to the name of the proxied accessible.
*/
void Name(nsString& aName) const;
/*
* Set aValue to the value of the proxied accessible.
*/
void Value(nsString& aValue) const;
/**
* Set aDesc to the description of the proxied accessible.
*/
void Description(nsString& aDesc) const;
/**
* Get the set of attributes on the proxied accessible.
*/
void Attributes(nsTArray<Attribute> *aAttrs) const;
nsIntRect Bounds();
void Language(nsString& aLocale);
bool GetCOMInterface(void** aOutAccessible) const; bool GetCOMInterface(void** aOutAccessible) const;

Просмотреть файл

@ -129,19 +129,38 @@
*/ */
function replaceIFrameHTMLElm(aID) function replaceIFrameHTMLElm(aID)
{ {
this.__proto__ = new rootContentReplaced(aID, "New Wave"); this.eventSeq = [
new invokerChecker(EVENT_SHOW, getDocChildNode, aID),
new invokerChecker(EVENT_REORDER, getDocNode, aID)
];
this.invoke = function replaceIFrameHTMLElm_invoke() this.invoke = function replaceIFrameHTMLElm_invoke()
{ {
var docNode = getDocNode(aID); var docNode = getDocNode(aID);
var newHTMLNode = docNode.createElement("html"); var newHTMLNode = docNode.createElement("html");
var newBodyNode = docNode.createElement("body"); newHTMLNode.innerHTML = `<body><p>New Wave</p></body`;
var newTextNode = docNode.createTextNode("New Wave");
newBodyNode.appendChild(newTextNode);
newHTMLNode.appendChild(newBodyNode);
docNode.replaceChild(newHTMLNode, docNode.documentElement); docNode.replaceChild(newHTMLNode, docNode.documentElement);
} }
this.finalCheck = function replaceIFrameHTMLElm_finalCheck()
{
var tree = {
role: ROLE_DOCUMENT,
children: [
{
role: ROLE_PARAGRAPH,
children: [
{
role: ROLE_TEXT_LEAF,
name: 'New Wave'
}
]
}
]
};
testAccessibleTree(getDocNode(aID), tree);
}
this.getID = function replaceIFrameHTMLElm_getID() this.getID = function replaceIFrameHTMLElm_getID()
{ {
return "replace HTML element"; return "replace HTML element";
@ -391,8 +410,8 @@
//////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////
// Test // Test
//gA11yEventDumpID = "eventdump"; // debug stuff
//gA11yEventDumpToConsole = true; //gA11yEventDumpToConsole = true;
//enableLogging('tree,verbose');
var gQueue = null; var gQueue = null;

Просмотреть файл

@ -9,7 +9,6 @@
#include "Compatibility.h" #include "Compatibility.h"
#include "DocAccessibleChild.h" #include "DocAccessibleChild.h"
#include "nsWinUtils.h" #include "nsWinUtils.h"
#include "mozilla/dom/TabChild.h"
#include "Role.h" #include "Role.h"
#include "RootAccessible.h" #include "RootAccessible.h"
#include "sdnDocAccessible.h" #include "sdnDocAccessible.h"
@ -105,8 +104,9 @@ DocAccessibleWrap::Shutdown()
if (nsWinUtils::IsWindowEmulationStarted()) { if (nsWinUtils::IsWindowEmulationStarted()) {
// Destroy window created for root document. // Destroy window created for root document.
if (mDocFlags & eTabDocument) { if (mDocFlags & eTabDocument) {
nsWinUtils::sHWNDCache->Remove(mHWND); HWND hWnd = static_cast<HWND>(mHWND);
::DestroyWindow(static_cast<HWND>(mHWND)); ::RemovePropW(hWnd, kPropNameDocAcc);
::DestroyWindow(hWnd);
} }
mHWND = nullptr; mHWND = nullptr;
@ -135,18 +135,7 @@ DocAccessibleWrap::DoInitialUpdate()
if (nsWinUtils::IsWindowEmulationStarted()) { if (nsWinUtils::IsWindowEmulationStarted()) {
// Create window for tab document. // Create window for tab document.
if (mDocFlags & eTabDocument) { if (mDocFlags & eTabDocument) {
mozilla::dom::TabChild* tabChild =
mozilla::dom::TabChild::GetFrom(mDocumentNode->GetShell());
a11y::RootAccessible* rootDocument = RootAccessible(); a11y::RootAccessible* rootDocument = RootAccessible();
mozilla::WindowsHandle nativeData = 0;
if (tabChild)
tabChild->SendGetWidgetNativeData(&nativeData);
else
nativeData = reinterpret_cast<mozilla::WindowsHandle>(
rootDocument->GetNativeWindow());
bool isActive = true; bool isActive = true;
nsIntRect rect(CW_USEDEFAULT, CW_USEDEFAULT, 0, 0); nsIntRect rect(CW_USEDEFAULT, CW_USEDEFAULT, 0, 0);
if (Compatibility::IsDolphin()) { if (Compatibility::IsDolphin()) {
@ -160,12 +149,12 @@ DocAccessibleWrap::DoInitialUpdate()
docShell->GetIsActive(&isActive); docShell->GetIsActive(&isActive);
} }
HWND parentWnd = reinterpret_cast<HWND>(nativeData); HWND parentWnd = reinterpret_cast<HWND>(rootDocument->GetNativeWindow());
mHWND = nsWinUtils::CreateNativeWindow(kClassNameTabContent, parentWnd, mHWND = nsWinUtils::CreateNativeWindow(kClassNameTabContent, parentWnd,
rect.x, rect.y, rect.x, rect.y,
rect.width, rect.height, isActive); rect.width, rect.height, isActive);
nsWinUtils::sHWNDCache->Put(mHWND, this); ::SetPropW(static_cast<HWND>(mHWND), kPropNameDocAcc, (HANDLE)this);
} else { } else {
DocAccessible* parentDocument = ParentDocument(); DocAccessible* parentDocument = ParentDocument();

Просмотреть файл

@ -35,7 +35,7 @@ const wchar_t* kPropNameTabContent = L"AccessibleTabWindow";
static LRESULT CALLBACK WindowProc(HWND hWnd, UINT msg, static LRESULT CALLBACK WindowProc(HWND hWnd, UINT msg,
WPARAM wParam, LPARAM lParam); WPARAM wParam, LPARAM lParam);
nsRefPtrHashtable<nsPtrHashKey<void>, DocAccessible>* nsWinUtils::sHWNDCache = nullptr; bool nsWinUtils::sWindowEmulationStarted = false;
already_AddRefed<nsIDOMCSSStyleDeclaration> already_AddRefed<nsIDOMCSSStyleDeclaration>
nsWinUtils::GetComputedStyleDeclaration(nsIContent* aContent) nsWinUtils::GetComputedStyleDeclaration(nsIContent* aContent)
@ -70,7 +70,7 @@ nsWinUtils::MaybeStartWindowEmulation()
Compatibility::IsDolphin() || Compatibility::IsDolphin() ||
XRE_IsContentProcess()) { XRE_IsContentProcess()) {
RegisterNativeWindow(kClassNameTabContent); RegisterNativeWindow(kClassNameTabContent);
sHWNDCache = new nsRefPtrHashtable<nsPtrHashKey<void>, DocAccessible>(2); sWindowEmulationStarted = true;
return true; return true;
} }
@ -82,14 +82,10 @@ nsWinUtils::ShutdownWindowEmulation()
{ {
// Unregister window call that's used for document accessibles associated // Unregister window call that's used for document accessibles associated
// with tabs. // with tabs.
if (IsWindowEmulationStarted()) if (IsWindowEmulationStarted()) {
::UnregisterClassW(kClassNameTabContent, GetModuleHandle(nullptr)); ::UnregisterClassW(kClassNameTabContent, GetModuleHandle(nullptr));
} sWindowEmulationStarted = false;
}
bool
nsWinUtils::IsWindowEmulationStarted()
{
return sHWNDCache != nullptr;
} }
void void
@ -158,7 +154,7 @@ WindowProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
int32_t objId = static_cast<DWORD>(lParam); int32_t objId = static_cast<DWORD>(lParam);
if (objId == OBJID_CLIENT) { if (objId == OBJID_CLIENT) {
DocAccessible* document = DocAccessible* document =
nsWinUtils::sHWNDCache->GetWeak(static_cast<void*>(hWnd)); reinterpret_cast<DocAccessible*>(::GetPropW(hWnd, kPropNameDocAcc));
if (document) { if (document) {
IAccessible* msaaAccessible = nullptr; IAccessible* msaaAccessible = nullptr;
document->GetNativeInterface((void**)&msaaAccessible); // does an addref document->GetNativeInterface((void**)&msaaAccessible); // does an addref

Просмотреть файл

@ -12,7 +12,6 @@
#include "nsIDOMCSSStyleDeclaration.h" #include "nsIDOMCSSStyleDeclaration.h"
#include "nsCOMPtr.h" #include "nsCOMPtr.h"
#include "nsRefPtrHashtable.h"
class nsIContent; class nsIContent;
@ -23,6 +22,7 @@ class DocAccessible;
const LPCWSTR kClassNameRoot = L"MozillaUIWindowClass"; const LPCWSTR kClassNameRoot = L"MozillaUIWindowClass";
const LPCWSTR kClassNameTabContent = L"MozillaContentWindowClass"; const LPCWSTR kClassNameTabContent = L"MozillaContentWindowClass";
const LPCWSTR kPropNameDocAcc = L"MozDocAccessible";
class nsWinUtils class nsWinUtils
{ {
@ -49,7 +49,7 @@ public:
/** /**
* Return true if window emulation is started. * Return true if window emulation is started.
*/ */
static bool IsWindowEmulationStarted(); static bool IsWindowEmulationStarted() { return sWindowEmulationStarted; }
/** /**
* Helper to register window class. * Helper to register window class.
@ -73,11 +73,11 @@ public:
*/ */
static void HideNativeWindow(HWND aWnd); static void HideNativeWindow(HWND aWnd);
private:
/** /**
* Cache for HWNDs of windows created for document accessibles in windows * Flag that indicates if window emulation is started.
* emulation mode.
*/ */
static nsRefPtrHashtable<nsPtrHashKey<void>, DocAccessible>* sHWNDCache; static bool sWindowEmulationStarted;
}; };
} // namespace a11y } // namespace a11y

1
aclocal.m4 поставляемый
Просмотреть файл

@ -24,7 +24,6 @@ builtin(include, build/autoconf/arch.m4)dnl
builtin(include, build/autoconf/android.m4)dnl builtin(include, build/autoconf/android.m4)dnl
builtin(include, build/autoconf/zlib.m4)dnl builtin(include, build/autoconf/zlib.m4)dnl
builtin(include, build/autoconf/icu.m4)dnl builtin(include, build/autoconf/icu.m4)dnl
builtin(include, build/autoconf/ffi.m4)dnl
builtin(include, build/autoconf/clang-plugin.m4)dnl builtin(include, build/autoconf/clang-plugin.m4)dnl
builtin(include, build/autoconf/alloc.m4)dnl builtin(include, build/autoconf/alloc.m4)dnl
builtin(include, build/autoconf/ios.m4)dnl builtin(include, build/autoconf/ios.m4)dnl

Просмотреть файл

@ -35,16 +35,6 @@ let whitelist = [
// Platform can be "linux", "macosx" or "win". If omitted, the exception applies to all platforms. // Platform can be "linux", "macosx" or "win". If omitted, the exception applies to all platforms.
let allowedImageReferences = [ let allowedImageReferences = [
// Bug 1302759
{file: "chrome://browser/skin/customizableui/customize-titleBar-toggle.png",
from: "chrome://browser/skin/browser.css",
platforms: ["linux"],
isFromDevTools: false},
{file: "chrome://browser/skin/customizableui/customize-titleBar-toggle@2x.png",
from: "chrome://browser/skin/browser.css",
platforms: ["linux"],
isFromDevTools: false},
// Bug 1302691 // Bug 1302691
{file: "chrome://devtools/skin/images/dock-bottom-minimize@2x.png", {file: "chrome://devtools/skin/images/dock-bottom-minimize@2x.png",
from: "chrome://devtools/skin/toolbox.css", from: "chrome://devtools/skin/toolbox.css",

Просмотреть файл

@ -84,3 +84,9 @@ addMessageListener("Test:WaitForObserverCall", ({data}) => {
} }
}, topic, false); }, topic, false);
}); });
addMessageListener("Test:WaitForMessage", () => {
content.addEventListener("message", ({data}) => {
sendAsyncMessage("Test:MessageReceived", data);
}, {once: true});
});

Просмотреть файл

@ -246,21 +246,23 @@ function promiseTodoObserverNotCalled(aTopic) {
} }
function promiseMessage(aMessage, aAction) { function promiseMessage(aMessage, aAction) {
let deferred = Promise.defer(); let promise = new Promise((resolve, reject) => {
let mm = _mm();
content.addEventListener("message", function messageListener(event) { mm.addMessageListener("Test:MessageReceived", function listener({data}) {
content.removeEventListener("message", messageListener); is(data, aMessage, "received " + aMessage);
is(event.data, aMessage, "received " + aMessage); if (data == aMessage)
if (event.data == aMessage) resolve();
deferred.resolve(); else
else reject();
deferred.reject(); mm.removeMessageListener("Test:MessageReceived", listener);
});
mm.sendAsyncMessage("Test:WaitForMessage");
}); });
if (aAction) if (aAction)
aAction(); aAction();
return deferred.promise; return promise;
} }
function promisePopupNotificationShown(aName, aAction) { function promisePopupNotificationShown(aName, aAction) {

Просмотреть файл

@ -292,7 +292,6 @@ function prompt(aBrowser, aRequest) {
requestTypes: requestTypes} = aRequest; requestTypes: requestTypes} = aRequest;
let uri = Services.io.newURI(aRequest.documentURI, null, null); let uri = Services.io.newURI(aRequest.documentURI, null, null);
let host = getHost(uri); let host = getHost(uri);
let principal = Services.scriptSecurityManager.createCodebasePrincipal(uri, {});
let chromeDoc = aBrowser.ownerDocument; let chromeDoc = aBrowser.ownerDocument;
let chromeWin = chromeDoc.defaultView; let chromeWin = chromeDoc.defaultView;
let stringBundle = chromeWin.gNavigatorBundle; let stringBundle = chromeWin.gNavigatorBundle;
@ -388,14 +387,12 @@ function prompt(aBrowser, aRequest) {
if (micPerm == perms.PROMPT_ACTION) if (micPerm == perms.PROMPT_ACTION)
micPerm = perms.UNKNOWN_ACTION; micPerm = perms.UNKNOWN_ACTION;
let camPermanentPerm = perms.testExactPermanentPermission(principal, "camera");
let camPerm = perms.testExactPermission(uri, "camera"); let camPerm = perms.testExactPermission(uri, "camera");
// Session approval given but never used to allocate a camera, remove let mediaManagerPerm =
// and ask again perms.testExactPermission(uri, "MediaManagerVideo");
if (camPerm && !camPermanentPerm) { if (mediaManagerPerm) {
perms.remove(uri, "camera"); perms.remove(uri, "MediaManagerVideo");
camPerm = perms.UNKNOWN_ACTION;
} }
if (camPerm == perms.PROMPT_ACTION) if (camPerm == perms.PROMPT_ACTION)
@ -534,10 +531,12 @@ function prompt(aBrowser, aRequest) {
allowedDevices.push(videoDeviceIndex); allowedDevices.push(videoDeviceIndex);
// Session permission will be removed after use // Session permission will be removed after use
// (it's really one-shot, not for the entire session) // (it's really one-shot, not for the entire session)
perms.add(uri, "camera", perms.ALLOW_ACTION, perms.add(uri, "MediaManagerVideo", perms.ALLOW_ACTION,
aRemember ? perms.EXPIRE_NEVER : perms.EXPIRE_SESSION); perms.EXPIRE_SESSION);
} else if (aRemember) { }
perms.add(uri, "camera", perms.DENY_ACTION); if (aRemember) {
perms.add(uri, "camera",
allowCamera ? perms.ALLOW_ACTION : perms.DENY_ACTION);
} }
} }
if (audioDevices.length) { if (audioDevices.length) {

Просмотреть файл

@ -182,13 +182,10 @@
height: 24px; height: 24px;
} }
#customization-titlebar-visibility-button { %ifdef CAN_DRAW_IN_TITLEBAR
list-style-image: url("chrome://browser/skin/customizableui/customize-titleBar-toggle.png"); #customization-titlebar-visibility-button > .button-box > .button-text,
-moz-image-region: rect(0, 24px, 24px, 0); %endif
} #customization-lwtheme-button > .box-inherit > .box-inherit > .button-text {
#customization-lwtheme-button > .box-inherit > .box-inherit > .button-text,
#customization-titlebar-visibility-button > .button-box > .button-text {
/* Sadly, button.css thinks its margins are perfect for everyone. */ /* Sadly, button.css thinks its margins are perfect for everyone. */
margin-inline-start: 6px !important; margin-inline-start: 6px !important;
} }
@ -200,6 +197,12 @@
background-size: contain; background-size: contain;
} }
%ifdef CAN_DRAW_IN_TITLEBAR
#customization-titlebar-visibility-button {
list-style-image: url("chrome://browser/skin/customizableui/customize-titleBar-toggle.png");
-moz-image-region: rect(0, 24px, 24px, 0);
}
#customization-titlebar-visibility-button > .button-box > .button-icon { #customization-titlebar-visibility-button > .button-box > .button-icon {
vertical-align: middle; vertical-align: middle;
} }
@ -218,6 +221,7 @@
-moz-image-region: rect(0, 96px, 48px, 48px); -moz-image-region: rect(0, 96px, 48px, 48px);
} }
} }
%endif /* CAN_DRAW_IN_TITLEBAR */
#main-window[customize-entered] #customization-panel-container { #main-window[customize-entered] #customization-panel-container {
background-image: url("chrome://browser/skin/customizableui/customizeMode-separatorHorizontal.png"), background-image: url("chrome://browser/skin/customizableui/customizeMode-separatorHorizontal.png"),

Просмотреть файл

@ -12,7 +12,7 @@
} }
.notification-anchor-icon, .notification-anchor-icon,
.blocked-permission-icon { #blocked-permissions-container > .blocked-permission-icon {
width: 16px; width: 16px;
height: 16px; height: 16px;
margin-inline-start: 2px; margin-inline-start: 2px;

Просмотреть файл

@ -16,8 +16,6 @@ for file in $MALLOC_HEADERS; do
fi fi
done done
MOZ_CHECK_HEADERS(alloca.h)
AC_CHECK_FUNCS(strndup posix_memalign memalign) AC_CHECK_FUNCS(strndup posix_memalign memalign)
AC_CHECK_FUNCS(malloc_usable_size) AC_CHECK_FUNCS(malloc_usable_size)

Просмотреть файл

@ -7,7 +7,7 @@ AC_DEFUN([MOZ_ANDROID_NDK],
MOZ_ARG_WITH_STRING(android-cxx-stl, MOZ_ARG_WITH_STRING(android-cxx-stl,
[ --with-android-cxx-stl=VALUE [ --with-android-cxx-stl=VALUE
use the specified C++ STL (stlport, libstdc++, libc++)], use the specified C++ STL (libstdc++, libc++)],
android_cxx_stl=$withval, android_cxx_stl=$withval,
android_cxx_stl=libc++) android_cxx_stl=libc++)
@ -110,11 +110,6 @@ if test "$OS_TARGET" = "Android"; then
# etc. # etc.
STLPORT_CPPFLAGS="-I$android_ndk/sources/android/support/include -I$cxx_include -I$cxxabi_include" STLPORT_CPPFLAGS="-I$android_ndk/sources/android/support/include -I$cxx_include -I$cxxabi_include"
;; ;;
mozstlport)
# We don't need to set STLPORT_LIBS, because the build system will
# take care of linking in our home-built stlport where it is needed.
STLPORT_CPPFLAGS="-isystem $_topsrcdir/build/stlport/stlport -isystem $_topsrcdir/build/stlport/overrides -isystem $android_ndk/sources/cxx-stl/system/include"
;;
*) *)
AC_MSG_ERROR([Bad value for --enable-android-cxx-stl]) AC_MSG_ERROR([Bad value for --enable-android-cxx-stl])
;; ;;

Просмотреть файл

@ -1,74 +0,0 @@
dnl This Source Code Form is subject to the terms of the Mozilla Public
dnl License, v. 2.0. If a copy of the MPL was not distributed with this
dnl file, You can obtain one at http://mozilla.org/MPL/2.0/.
AC_DEFUN([MOZ_SUBCONFIGURE_FFI], [
if test "$MOZ_BUILD_APP" != js -o -n "$JS_STANDALONE"; then
if test "$BUILD_CTYPES" -a -z "$MOZ_SYSTEM_FFI"; then
# Run the libffi 'configure' script.
ac_configure_args="--disable-shared --enable-static --disable-raw-api"
if test "$MOZ_DEBUG"; then
ac_configure_args="$ac_configure_args --enable-debug"
fi
if test "$DSO_PIC_CFLAGS"; then
ac_configure_args="$ac_configure_args --with-pic"
fi
for var in AS CC CXX CPP LD AR RANLIB STRIP; do
ac_configure_args="$ac_configure_args $var='`eval echo \\${${var}}`'"
done
old_cflags="$CFLAGS"
# The libffi sources (especially the ARM ones) are written expecting gas
# syntax, and clang's integrated assembler doesn't handle all of gas syntax.
if test -n "$CLANG_CC" -a "$CPU_ARCH" = arm; then
CFLAGS="-no-integrated-as $CFLAGS"
fi
ac_configure_args="$ac_configure_args --build=$build --host=$target"
if test "$CROSS_COMPILE"; then
ac_configure_args="$ac_configure_args \
CFLAGS=\"$CFLAGS\" \
CPPFLAGS=\"$CPPFLAGS\" \
LDFLAGS=\"$LDFLAGS\""
fi
CFLAGS="$old_cflags"
if test "$_MSC_VER"; then
# Use a wrapper script for cl and ml that looks more like gcc.
# autotools can't quite handle an MSVC build environment yet.
LDFLAGS=
CFLAGS=
ac_configure_args="$ac_configure_args LD=link CPP=\"$CC -nologo -EP\" \
CXXCPP=\"$CXX -nologo -EP\" SHELL=sh.exe"
flags=
if test -z "$MOZ_NO_DEBUG_RTL" -a -n "$MOZ_DEBUG"; then
flags=" -DUSE_DEBUG_RTL"
fi
if test -n "$CLANG_CL"; then
flags="$flags -clang-cl"
fi
case "${target_cpu}" in
x86_64)
# Need target since MSYS tools into mozilla-build may be 32bit
ac_configure_args="$ac_configure_args \
CC=\"$_topsrcdir/js/src/ctypes/libffi/msvcc.sh -m64$flags\" \
CXX=\"$_topsrcdir/js/src/ctypes/libffi/msvcc.sh -m64$flags\""
;;
*)
ac_configure_args="$ac_configure_args \
CC=\"$_topsrcdir/js/src/ctypes/libffi/msvcc.sh$flags\" \
CXX=\"$_topsrcdir/js/src/ctypes/libffi/msvcc.sh$flags\""
;;
esac
fi
# Use a separate cache file for libffi, since it does things differently
# from our configure.
old_config_files=$CONFIG_FILES
unset CONFIG_FILES
AC_OUTPUT_SUBDIRS(js/src/ctypes/libffi)
ac_configure_args="$_SUBDIR_CONFIG_ARGS"
CONFIG_FILES=$old_config_files
fi
fi
])

Просмотреть файл

@ -2,13 +2,15 @@ dnl This Source Code Form is subject to the terms of the Mozilla Public
dnl License, v. 2.0. If a copy of the MPL was not distributed with this dnl License, v. 2.0. If a copy of the MPL was not distributed with this
dnl file, You can obtain one at http://mozilla.org/MPL/2.0/. dnl file, You can obtain one at http://mozilla.org/MPL/2.0/.
dnl Several autoconf functions AC_REQUIRE AC_PROG_CPP/AC_PROG_CXXCPP, dnl Several autoconf functions AC_REQUIRE AC_PROG_CPP/AC_PROG_CXXCPP
dnl meaning they are called even when we don't call them explicitly. dnl or AC_HEADER_STDC, meaning they are called even when we don't call
dnl them explicitly.
dnl However, theses checks are not necessary and python configure sets dnl However, theses checks are not necessary and python configure sets
dnl the corresponding variables already, so just skip those tests dnl the corresponding variables already, so just skip those tests
dnl entirely. dnl entirely.
define([AC_PROG_CPP],[]) define([AC_PROG_CPP],[])
define([AC_PROG_CXXCPP],[]) define([AC_PROG_CXXCPP],[])
define([AC_HEADER_STDC], [])
AC_DEFUN([MOZ_TOOL_VARIABLES], AC_DEFUN([MOZ_TOOL_VARIABLES],
[ [

Просмотреть файл

@ -1,55 +0,0 @@
LOCAL_PATH:= $(call my-dir)
libgabi++_cflags := \
-I$(LOCAL_PATH)/include
libgabi++_common_src_files := \
src/array_type_info.cc \
src/class_type_info.cc \
src/delete.cc \
src/dynamic_cast.cc \
src/enum_type_info.cc \
src/function_type_info.cc \
src/new.cc \
src/pbase_type_info.cc \
src/pointer_type_info.cc \
src/pointer_to_member_type_info.cc \
src/si_class_type_info.cc \
src/type_info.cc \
src/vmi_class_type_info.cc
include $(CLEAR_VARS)
LOCAL_MODULE_TAGS := optional
LOCAL_CPP_EXTENSION := .cc
LOCAL_SRC_FILES:= $(libgabi++_common_src_files)
LOCAL_MODULE:= libgabi++
LOCAL_CFLAGS := $(libgabi++_cflags)
LOCAL_RTTI_FLAG := -frtti
LOCAL_SYSTEM_SHARED_LIBRARIES := libc
include $(BUILD_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE_TAGS := optional
LOCAL_CPP_EXTENSION := .cc
LOCAL_SRC_FILES:= $(libgabi++_common_src_files)
LOCAL_MODULE:= libgabi++
LOCAL_CFLAGS := $(libgabi++_cflags)
LOCAL_RTTI_FLAG := -frtti
LOCAL_SYSTEM_SHARED_LIBRARIES := libc
include $(BUILD_STATIC_LIBRARY)

Просмотреть файл

@ -1 +0,0 @@
This copy of libgabi++ is from Android 5.0 source code on https://android.googlesource.com/platform/abi/cpp/. Tag is android-5.0.0_r1.

Просмотреть файл

@ -1,183 +0,0 @@
// Copyright (C) 2011 The Android Open Source Project
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// 3. Neither the name of the project nor the names of its contributors
// may be used to endorse or promote products derived from this software
// without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
// OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
// OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
// SUCH DAMAGE.
//
#ifndef __GABIXX_CXXABI_H__
#define __GABIXX_CXXABI_H__
#include <typeinfo>
namespace __cxxabiv1
{
extern "C" void __cxa_pure_virtual();
// Derived types of type_info below are based on 2.9.5 of C++ ABI.
// Typeinfo for fundamental types.
class __fundamental_type_info : public std::type_info
{
public:
~__fundamental_type_info();
};
// Typeinfo for array types.
class __array_type_info : public std::type_info
{
public:
~__array_type_info();
};
// Typeinfo for function types.
class __function_type_info : public std::type_info
{
public:
~__function_type_info();
};
// Typeinfo for enum types.
class __enum_type_info : public std::type_info
{
public:
~__enum_type_info();
};
// Typeinfo for classes with no bases.
class __class_type_info : public std::type_info
{
public:
~__class_type_info();
enum class_type_info_code
{
CLASS_TYPE_INFO_CODE,
SI_CLASS_TYPE_INFO_CODE,
VMI_CLASS_TYPE_INFO_CODE
};
virtual class_type_info_code
code() const { return CLASS_TYPE_INFO_CODE; }
};
// Typeinfo for classes containing only a single, public, non-virtual base at
// offset zero.
class __si_class_type_info : public __class_type_info
{
public:
~__si_class_type_info();
const __class_type_info *__base_type;
virtual __class_type_info::class_type_info_code
code() const { return SI_CLASS_TYPE_INFO_CODE; }
};
struct __base_class_type_info
{
public:
const __class_type_info *__base_type;
// All but the lower __offset_shift bits of __offset_flags are a signed
// offset. For a non-virtual base, this is the offset in the object of the
// base subobject. For a virtual base, this is the offset in the virtual
// table of the virtual base offset for the virtual base referenced
// (negative).
long __offset_flags;
enum __offset_flags_masks
{
__virtual_mask = 0x1,
__public_mask = 0x2,
__offset_shift = 8
};
bool inline
is_virtual() const { return (__offset_flags & __virtual_mask) != 0; }
bool inline
is_public() const { return (__offset_flags & __public_mask) != 0; }
// FIXME: Right-shift of signed integer is implementation dependent.
long inline
offset() const { return __offset_flags >> __offset_shift; }
long inline
flags() const { return __offset_flags & ((1L << __offset_shift) - 1); }
};
// Typeinfo for classes with bases that do not satisfy the
// __si_class_type_info constraints.
class __vmi_class_type_info : public __class_type_info
{
public:
~__vmi_class_type_info();
unsigned int __flags;
unsigned int __base_count;
__base_class_type_info __base_info[1];
enum __flags_masks
{
__non_diamond_repeat_mask = 0x1,
__diamond_shaped_mask = 0x2
};
virtual __class_type_info::class_type_info_code
code() const { return VMI_CLASS_TYPE_INFO_CODE; }
};
class __pbase_type_info : public std::type_info
{
public:
~__pbase_type_info();
unsigned int __flags;
const std::type_info *__pointee;
enum __masks
{
__const_mask = 0x1,
__volatile_mask = 0x2,
__restrict_mask = 0x4,
__incomplete_mask = 0x8,
__incomplete_class_mask = 0x10
};
};
class __pointer_type_info : public __pbase_type_info
{
public:
~__pointer_type_info();
};
class __pointer_to_member_type_info : public __pbase_type_info
{
public:
~__pointer_to_member_type_info();
};
}
namespace abi = __cxxabiv1;
#endif /* defined(__GABIXX_CXXABI_H__) */

Просмотреть файл

@ -1,56 +0,0 @@
// Copyright (C) 2011 The Android Open Source Project
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// 3. Neither the name of the project nor the names of its contributors
// may be used to endorse or promote products derived from this software
// without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
// OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
// OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
// SUCH DAMAGE.
//
// new: Dynamic storage management.
#ifndef __GABIXX_NEW__
#define __GABIXX_NEW__
#include <cstddef>
namespace std
{
struct nothrow_t {};
extern const nothrow_t nothrow;
typedef void (*new_handler)();
}
// FIXME: Need to handle exceptions.
void* operator new(std::size_t size) throw(/*std::bad_alloc*/);
void* operator new(std::size_t size, const std::nothrow_t&) throw();
void operator delete(void* ptr) throw();
void operator delete(void*, const std::nothrow_t&) throw();
void* operator new[](std::size_t size) throw(/*std::bad_alloc*/);
void* operator new[](std::size_t size, const std::nothrow_t&) throw();
void operator delete[](void* ptr) throw();
void operator delete[](void* const, std::nothrow_t&) throw();
void* operator new(std::size_t size, void* ptr) throw();
void* operator new[](std::size_t size, void* ptr) throw();
void operator delete(void* ptr, void*) throw();
void operator delete[](void* ptr, void*) throw();
#endif // __GABIXX_NEW__

Просмотреть файл

@ -1,76 +0,0 @@
// Copyright (C) 2011 The Android Open Source Project
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// 3. Neither the name of the project nor the names of its contributors
// may be used to endorse or promote products derived from this software
// without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
// OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
// OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
// SUCH DAMAGE.
//
// typeinfo: RTTI support header.
//
// References:
// Itanium C++ ABI at http://www.codesourcery.com/public/cxx-abi/abi.html.
// IHI0041A C++ Application Binary Interface for the ARM architecture.
// Linux Standard Base C++ Specification for S390X 4.1.
//
#ifndef __GABIXX_TYPEINFO__
#define __GABIXX_TYPEINFO__
namespace std
{
// Defintion of type_info based on example in C++ ABI section 2.9.3
class type_info
{
public:
virtual
~type_info();
// Whether two type_infos corresponds to the same types.
bool
operator==(const type_info &ti) const;
// Whether two type_infos corresponds to the different types.
bool
operator!=(const type_info &ti) const;
bool
before(const type_info &ti) const;
// Return name of type.
const char*
name() const { return __type_name; }
private:
// Assignment of type_info is not allowed.
type_info (const type_info& rhs);
type_info&
operator=(const type_info& rhs);
// Mangled name of type.
const char *__type_name;
};
} // namespace std
#endif // _GABIXX_TYPEINFO_

Просмотреть файл

@ -1,36 +0,0 @@
# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
# vim: set filetype=python:
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
Library('gabi++')
SOURCES += [
'src/array_type_info.cc',
'src/class_type_info.cc',
'src/delete.cc',
'src/dynamic_cast.cc',
'src/enum_type_info.cc',
'src/function_type_info.cc',
'src/fundamental_type_info.cc',
'src/new.cc',
'src/pbase_type_info.cc',
'src/pointer_to_member_type_info.cc',
'src/pointer_type_info.cc',
'src/si_class_type_info.cc',
'src/type_info.cc',
'src/vmi_class_type_info.cc',
]
LOCAL_INCLUDES += [
'include'
]
DISABLE_STL_WRAPPING = True
NO_VISIBILITY_FLAGS = True
CXXFLAGS += [
'-fexceptions',
'-frtti'
]

Просмотреть файл

@ -1,37 +0,0 @@
// Copyright (C) 2011 The Android Open Source Project
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// 3. Neither the name of the project nor the names of its contributors
// may be used to endorse or promote products derived from this software
// without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
// OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
// OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
// SUCH DAMAGE.
//
// fundamental_type_info.cc: Methods for __fundamental_type_info.
#include <cxxabi.h>
namespace __cxxabiv1
{
__fundamental_type_info::~__fundamental_type_info()
{
}
} // namespace __cxxabiv1

Просмотреть файл

@ -1,37 +0,0 @@
// Copyright (C) 2011 The Android Open Source Project
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// 3. Neither the name of the project nor the names of its contributors
// may be used to endorse or promote products derived from this software
// without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
// OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
// OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
// SUCH DAMAGE.
//
// class_type_info.cc: Methods for __class_type_info.
#include <cxxabi.h>
namespace __cxxabiv1
{
__class_type_info::~__class_type_info()
{
}
} // namespace __cxxabiv1

Просмотреть файл

@ -1,38 +0,0 @@
// Copyright (C) 2011 The Android Open Source Project
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// 3. Neither the name of the project nor the names of its contributors
// may be used to endorse or promote products derived from this software
// without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
// OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
// OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
// SUCH DAMAGE.
//
// delete.cc: delete operator
#include <stdlib.h>
#include <new>
void
operator delete(void* ptr) throw()
{
if (ptr)
free(ptr);
}

Просмотреть файл

@ -1,356 +0,0 @@
// Copyright (C) 2011 The Android Open Source Project
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// 3. Neither the name of the project nor the names of its contributors
// may be used to endorse or promote products derived from this software
// without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
// OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
// OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
// SUCH DAMAGE.
//
// dynamic_cast.cc: RTTI support.
//
// References:
// Itanium C++ ABI at http://www.codesourcery.com/public/cxx-abi/abi.html
// IHI0041A C++ Application Binary Interface for the ARM architecture.
//
#include <cxxabi.h>
#include <cstddef>
#include <cassert>
namespace
{
// Adjust a pointer by an offset.
const void*
adjust_pointer(const void* p, std::ptrdiff_t off)
{
// FIXME: should we align pointer after adjustment?
const char *cp = reinterpret_cast<const char*>(p) + off;
return reinterpret_cast<const void*>(cp);
}
// Return the vtable pointer of a polymorphic object pointed by p.
inline const void*
get_vtable(const void* p)
{
return *reinterpret_cast<void*const*>(p);
}
// Return a pointer to a __class_type_info in a vtable.
inline const abi::__class_type_info*
get_class_type_info(const void* vtable)
{
const void* type_info_ptr = adjust_pointer(vtable, -sizeof(void*));
return *reinterpret_cast<abi::__class_type_info*const*>(type_info_ptr);
}
// Return offset to object in a vtable.
inline std::ptrdiff_t
get_offset_to_top(const void* vtable)
{
const void* type_info_ptr_address = adjust_pointer(vtable, -sizeof(void*));
const void* offset_to_top_address =
adjust_pointer(type_info_ptr_address, -sizeof(std::ptrdiff_t));
return *reinterpret_cast<const std::ptrdiff_t*>(offset_to_top_address);
}
// Return the virtual pointer to the most derived object of referred by a
// pointer p.
const void*
get_most_derived_object(const void* p)
{
const void* vtable = get_vtable(p);
std::ptrdiff_t offset_to_top = get_offset_to_top(vtable);
return adjust_pointer(p, offset_to_top);
}
// We assume that -1 cannot be a valid pointer to object.
const void * const ambiguous_object =
reinterpret_cast<const void*>(-1);
// Return a pointer to the subobject described by base_info.
const void*
get_subobject(const void* object,
const void* vtable,
const abi::__base_class_type_info* base_info)
{
long offset = base_info->offset();
if (base_info->is_virtual())
{
const std::ptrdiff_t* virtual_base_offset_address =
static_cast<const std::ptrdiff_t*> (adjust_pointer(vtable, offset));
offset = *virtual_base_offset_address;
}
return adjust_pointer(object, offset);
}
// Helper of __dyanmic_cast to walk the type tree of an object.
const void *
walk_object(const void *object,
const abi::__class_type_info *type,
const void *match_object,
const abi::__class_type_info *match_type)
{
if (*type == *match_type)
return (match_object == NULL || object == match_object) ? object : NULL;
switch(type->code())
{
case abi::__class_type_info::CLASS_TYPE_INFO_CODE:
// This isn't not the class you're looking for.
return NULL;
case abi::__class_type_info::SI_CLASS_TYPE_INFO_CODE:
// derived type has a single public base at offset 0.
{
const abi::__si_class_type_info* ti =
static_cast<const abi::__si_class_type_info*>(type);
return walk_object(object, ti->__base_type, match_object,
match_type);
}
case abi::__class_type_info::VMI_CLASS_TYPE_INFO_CODE:
{
const void* vtable = get_vtable(object);
const abi::__vmi_class_type_info* ti =
static_cast<const abi::__vmi_class_type_info*>(type);
// Look at all direct bases.
const void* result = NULL;
for (unsigned i = 0; i < ti->__base_count; ++i)
{
if (!ti->__base_info[i].is_public())
continue;
const void *subobject =
get_subobject(object, vtable, &ti->__base_info[i]);
const void* walk_subobject_result =
walk_object(subobject, ti->__base_info[i].__base_type,
match_object, match_type);
if (walk_subobject_result == ambiguous_object)
return ambiguous_object;
else if (walk_subobject_result != NULL)
{
if (result == NULL)
{
result = walk_subobject_result;
}
else if (result != walk_subobject_result)
return ambiguous_object;
}
}
return result;
}
default:
assert(0);
}
return NULL;
}
// Bookkeeping structure for derived-to-base cast in the general case.
struct cast_context
{
public:
const void* object;
const abi::__class_type_info *src_type;
const abi::__class_type_info *dst_type;
std::ptrdiff_t src2dst_offset;
const void* dst_object;
const void* result;
cast_context(const void* obj, const abi::__class_type_info *src,
const abi::__class_type_info *dst, std::ptrdiff_t offset)
: object(obj), src_type(src), dst_type(dst), src2dst_offset(offset),
dst_object(NULL), result(NULL)
{ }
};
// based-to-derive cast in the general case.
void
base_to_derived_cast(const void *object,
const abi::__class_type_info *type,
cast_context* context)
{
const void* saved_dst_object = context->dst_object;
bool is_dst_type = *type == *context->dst_type;
if (is_dst_type)
context->dst_object = object;
if (object == context->object
&& context->dst_object != NULL
&& *type == *context->src_type)
{
if (context->result == NULL)
context->result = context->dst_object;
else if (context->result != context->dst_object)
context->result = ambiguous_object;
context->dst_object = saved_dst_object;
return;
}
switch(type->code())
{
case abi::__class_type_info::CLASS_TYPE_INFO_CODE:
// This isn't not the class you're looking for.
break;
case abi::__class_type_info::SI_CLASS_TYPE_INFO_CODE:
// derived type has a single public base at offset 0.
{
const abi::__si_class_type_info* ti =
static_cast<const abi::__si_class_type_info*>(type);
base_to_derived_cast(object, ti->__base_type, context);
break;
}
case abi::__class_type_info::VMI_CLASS_TYPE_INFO_CODE:
{
const void* vtable = get_vtable(object);
const abi::__vmi_class_type_info* ti =
static_cast<const abi::__vmi_class_type_info*>(type);
// Look at all direct bases.
for (unsigned i = 0; i < ti->__base_count; ++i)
{
if (!ti->__base_info[i].is_public())
continue;
const void *subobject =
get_subobject(object, vtable, &ti->__base_info[i]);
base_to_derived_cast(subobject, ti->__base_info[i].__base_type,
context);
// FIXME: Use flags in base_info to optimize search.
if (context->result == ambiguous_object)
break;
}
break;
}
default:
assert(0);
}
context->dst_object = saved_dst_object;
}
} // namespace
namespace __cxxabiv1
{
#define DYNAMIC_CAST_NO_HINT -1
#define DYNAMIC_CAST_NOT_PUBLIC_BASE -2
#define DYNAMIC_CAST_MULTIPLE_PUBLIC_NONVIRTUAL_BASE -3
/* v: source address to be adjusted; nonnull, and since the
* source object is polymorphic, *(void**)v is a virtual pointer.
* src: static type of the source object.
* dst: destination type (the "T" in "dynamic_cast<T>(v)").
* src2dst_offset: a static hint about the location of the
* source subobject with respect to the complete object;
* special negative values are:
* -1: no hint
* -2: src is not a public base of dst
* -3: src is a multiple public base type but never a
* virtual base type
* otherwise, the src type is a unique public nonvirtual
* base type of dst at offset src2dst_offset from the
* origin of dst.
*/
extern "C" void*
__dynamic_cast (const void *v,
const abi::__class_type_info *src,
const abi::__class_type_info *dst,
std::ptrdiff_t src2dst_offset)
{
const void* most_derived_object = get_most_derived_object(v);
const void* vtable = get_vtable(most_derived_object);
const abi::__class_type_info* most_derived_class_type_info =
get_class_type_info(vtable);
// If T is not a public base type of the most derived class referred
// by v, the cast always fails.
void* t_object =
const_cast<void*>(walk_object(most_derived_object,
most_derived_class_type_info, NULL, dst));
if (t_object == NULL)
return NULL;
// C++ ABI 2.9.7 The dynamic_cast Algorithm:
//
// If, in the most derived object pointed (referred) to by v, v points
// (refers) to a public base class subobject of a T object [note: this can
// be checked at compile time], and if only one object of type T is derived
// from the subobject pointed (referred) to by v, the result is a pointer
// (an lvalue referring) to that T object.
// We knew that src is not a public base, so base-to-derived cast
// is not possible. This works even if there are multiple subobjects
// of type T in the most derived object.
if (src2dst_offset != DYNAMIC_CAST_NOT_PUBLIC_BASE)
{
// If it is known that v points to a public base class subobject
// of a T object, simply adjust the pointer by the offset.
if (t_object != ambiguous_object && src2dst_offset >= 0)
return const_cast<void*>(adjust_pointer(v, -src2dst_offset));
// If there is only one T type subobject, we only need to look at
// there. Otherwise, look for the subobject referred by v in the
// most derived object.
cast_context context(v, src, dst, src2dst_offset);
if (t_object != ambiguous_object)
base_to_derived_cast(t_object, dst, &context);
else
base_to_derived_cast(most_derived_object,
most_derived_class_type_info, &context);
if (context.result != NULL && context.result != ambiguous_object)
return const_cast<void*>(context.result);
}
// C++ ABI 2.9.7 The dynamic_cast Algorithm:
//
// Otherwise, if v points (refers) to a public base class subobject of the
// most derived object, and the type of the most derived object has an
// unambiguous public base class of type T, the result is a pointer (an
// lvalue referring) to the T subobject of the most derived object.
// Otherwise, the run-time check fails.
// Check to see if T is a unambiguous public base class.
if (t_object == ambiguous_object)
return NULL;
// See if v refers to a public base class subobject.
const void* v_object =
walk_object(most_derived_object, most_derived_class_type_info, v, src);
return v_object == v ? t_object : NULL;
}
} // namespace __cxxabiv1

Просмотреть файл

@ -1,37 +0,0 @@
// Copyright (C) 2011 The Android Open Source Project
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// 3. Neither the name of the project nor the names of its contributors
// may be used to endorse or promote products derived from this software
// without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
// OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
// OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
// SUCH DAMAGE.
//
// enum_type_info.cc: Methods for __enum_type_info.
#include <cxxabi.h>
namespace __cxxabiv1
{
__enum_type_info::~__enum_type_info()
{
}
} // namespace __cxxabiv1

Просмотреть файл

@ -1,37 +0,0 @@
// Copyright (C) 2011 The Android Open Source Project
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// 3. Neither the name of the project nor the names of its contributors
// may be used to endorse or promote products derived from this software
// without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
// OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
// OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
// SUCH DAMAGE.
//
// function_type_info.cc: Methods for __function_type_info.
#include <cxxabi.h>
namespace __cxxabiv1
{
__function_type_info::~__function_type_info()
{
}
} // namespace __cxxabiv1

Просмотреть файл

@ -1,37 +0,0 @@
// Copyright (C) 2011 The Android Open Source Project
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// 3. Neither the name of the project nor the names of its contributors
// may be used to endorse or promote products derived from this software
// without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
// OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
// OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
// SUCH DAMAGE.
//
// array_type_info.cc: Methods for __array_type_info.
#include <cxxabi.h>
namespace __cxxabiv1
{
__array_type_info::~__array_type_info()
{
}
} // namespace __cxxabiv1

Просмотреть файл

@ -1,42 +0,0 @@
// Copyright (C) 2011 The Android Open Source Project
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// 3. Neither the name of the project nor the names of its contributors
// may be used to endorse or promote products derived from this software
// without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
// OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
// OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
// SUCH DAMAGE.
//
#include <stdlib.h>
#include <new>
// FIXME: need to handle exceptions
void*
operator new(std::size_t size) throw (/*std::bad_alloc*/)
{
void* ptr = malloc(size);
#if 0
if (ptr == NULL)
throw std::bad_alloc();
#endif
return ptr;
}

Просмотреть файл

@ -1,37 +0,0 @@
// Copyright (C) 2011 The Android Open Source Project
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// 3. Neither the name of the project nor the names of its contributors
// may be used to endorse or promote products derived from this software
// without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
// OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
// OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
// SUCH DAMAGE.
//
// pbase_type_info.cc: Methods for __pbase_type_info.
#include <cxxabi.h>
namespace __cxxabiv1
{
__pbase_type_info::~__pbase_type_info()
{
}
} // namespace __cxxabiv1

Просмотреть файл

@ -1,37 +0,0 @@
// Copyright (C) 2011 The Android Open Source Project
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// 3. Neither the name of the project nor the names of its contributors
// may be used to endorse or promote products derived from this software
// without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
// OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
// OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
// SUCH DAMAGE.
//
// pointer_to_member_type_info.cc: Methods for __pointer_to_member_type_info.
#include <cxxabi.h>
namespace __cxxabiv1
{
__pointer_to_member_type_info::~__pointer_to_member_type_info()
{
}
} // namespace __cxxabiv1

Просмотреть файл

@ -1,37 +0,0 @@
// Copyright (C) 2011 The Android Open Source Project
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// 3. Neither the name of the project nor the names of its contributors
// may be used to endorse or promote products derived from this software
// without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
// OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
// OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
// SUCH DAMAGE.
//
// pointer_type_info.cc: Methods for __pointer_type_info.
#include <cxxabi.h>
namespace __cxxabiv1
{
__pointer_type_info::~__pointer_type_info()
{
}
} // namespace __cxxabiv1

Просмотреть файл

@ -1,37 +0,0 @@
// Copyright (C) 2011 The Android Open Source Project
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// 3. Neither the name of the project nor the names of its contributors
// may be used to endorse or promote products derived from this software
// without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
// OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
// OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
// SUCH DAMAGE.
//
// si_class_type_info.cc: Methods for __si_class_type_info.
#include <cxxabi.h>
namespace __cxxabiv1
{
__si_class_type_info::~__si_class_type_info()
{
}
} // namespace __cxxabiv1

Просмотреть файл

@ -1,75 +0,0 @@
// Copyright (C) 2011 The Android Open Source Project
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// 3. Neither the name of the project nor the names of its contributors
// may be used to endorse or promote products derived from this software
// without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
// OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
// OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
// SUCH DAMAGE.
//
// type_info.cc: Methods for std::type_info.
//
#include <cxxabi.h>
#ifdef __ARM_EABI__
// ARM EABI requires string comprison for mangled type names for type_info
// equality.
#include <string.h>
#endif
#include <typeinfo>
namespace std
{
type_info::~type_info()
{
}
bool
type_info::operator==(const type_info& rhs) const
{
#ifdef __ARM_EABI__
// IHI0041A CPPABI 3.2.5.6. Because of weak linkage and share libraries,
// we perform string comparison.
return strcmp(this->__type_name, rhs.__type_name) == 0;
#else
return this == &rhs;
#endif
}
bool
type_info::operator!=(const type_info& rhs) const
{
return !this->operator==(rhs);
}
bool
type_info::before(const type_info& rhs) const
{
#ifdef __ARM_EABI__
// IHI0041A CPPABI 3.2.5.6. Because of weak linkage and share libraries,
// we perform string comparison.
return strcmp(this->__type_name, rhs.__type_name) < 0;
#else
return this < &rhs;
#endif
}
} // end namespace std

Просмотреть файл

@ -1,37 +0,0 @@
// Copyright (C) 2011 The Android Open Source Project
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// 3. Neither the name of the project nor the names of its contributors
// may be used to endorse or promote products derived from this software
// without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
// OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
// OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
// SUCH DAMAGE.
//
// vmi_class_type_info.cc: Methods for __vmi_class_type_info.
#include <cxxabi.h>
namespace __cxxabiv1
{
__vmi_class_type_info::~__vmi_class_type_info()
{
}
} // namespace __cxxabiv1

Просмотреть файл

@ -1,8 +0,0 @@
# To use RTTI, "include abi/cpp/use_rtti.mk" in your target.
LOCAL_C_INCLUDES := \
abi/cpp/include \
$(LOCAL_C_INCLUDES)
LOCAL_RTTI_FLAG := -frtti
LOCAL_SHARED_LIBRARIES += libgabi++

Просмотреть файл

@ -15,11 +15,6 @@ if CONFIG['OS_ARCH'] == 'WINNT':
else: else:
DIRS += ['unix'] DIRS += ['unix']
if CONFIG['OS_TARGET'] == 'Android' and CONFIG['MOZ_ANDROID_CXX_STL'] == 'mozstlport':
DIRS += ['stlport']
if CONFIG['ENABLE_INTL_API']:
DIRS += ['gabi++']
if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'android': if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'android':
DIRS += ['annotationProcessors'] DIRS += ['annotationProcessors']

Просмотреть файл

@ -4,6 +4,14 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this # License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/. # file, You can obtain one at http://mozilla.org/MPL/2.0/.
@depends(target)
def force_system_ffi(target):
# Pre-emptively move to system ffi for non-tier one platforms.
if target.cpu not in ('x86', 'x86_64', 'arm'):
return True
imply_option('--with-system-ffi', force_system_ffi, "target")
js_option('--with-system-ffi', js_option('--with-system-ffi',
help='Use system libffi (located with pkgconfig)') help='Use system libffi (located with pkgconfig)')
@ -12,5 +20,38 @@ use_system_ffi = depends_if('--with-system-ffi')(lambda _: True)
system_ffi = pkg_check_modules('MOZ_FFI', 'libffi > 3.0.9', system_ffi = pkg_check_modules('MOZ_FFI', 'libffi > 3.0.9',
when=use_system_ffi) when=use_system_ffi)
building_ffi = depends(system_ffi)(lambda v: not bool(v))
set_config('MOZ_SYSTEM_FFI', system_ffi) set_config('MOZ_SYSTEM_FFI', system_ffi)
add_old_configure_assignment('MOZ_SYSTEM_FFI', system_ffi) add_old_configure_assignment('MOZ_SYSTEM_FFI', system_ffi)
# Target selection, based on ffi/configure.ac.
@depends_when(target, when=building_ffi)
def ffi_target(target):
if target.cpu not in ('x86', 'x86_64', 'arm'):
die('Building libffi from the tree is not supported on this platform. '
'Use --with-system-ffi instead.')
if target.os == 'WINNT':
target_dir = 'x86'
if target.cpu == 'x86_64':
target_name = 'X86_WIN64'
else:
target_name = 'X86_WIN32'
elif target.os == 'OSX':
target_dir = 'x86'
target_name = 'X86_DARWIN'
elif target.cpu == 'arm':
target_dir = 'arm'
target_name = 'ARM'
else:
target_dir = 'x86'
target_name = target.cpu.upper()
return namespace(
name=target_name,
dir=target_dir
)
set_config('FFI_TARGET', delayed_getattr(ffi_target, 'name'))
set_config('FFI_TARGET_DIR', delayed_getattr(ffi_target, 'dir'))

Просмотреть файл

@ -8,15 +8,17 @@
check_header('stdint.h') check_header('stdint.h')
have_inttypes = check_header('inttypes.h') have_inttypes = check_header('inttypes.h')
set_config('HAVE_INTTYPES_H', have_inttypes) # Assume we have ansi C header files available.
set_define('STDC_HEADERS', True)
# Checks for headers relevant to non-windows systems. set_config('HAVE_INTTYPES_H', have_inttypes)
non_msvc_compiler = depends(c_compiler)(lambda info: info.type != 'msvc')
building_linux = depends(target)(lambda target: target.kernel == 'Linux') building_linux = depends(target)(lambda target: target.kernel == 'Linux')
have_malloc = check_header('malloc.h') have_malloc = check_header('malloc.h')
check_header('alloca.h')
add_old_configure_assignment('HAVE_MALLOC_H', have_malloc) add_old_configure_assignment('HAVE_MALLOC_H', have_malloc)
check_headers( check_headers(

Просмотреть файл

@ -783,6 +783,10 @@ host_cxx_compiler = compiler('C++', host, c_compiler=host_c_compiler,
other_compiler=cxx_compiler, other_compiler=cxx_compiler,
other_c_compiler=c_compiler) other_c_compiler=c_compiler)
# Generic compiler-based conditions.
non_msvc_compiler = depends(c_compiler)(lambda info: info.type != 'msvc')
building_with_gcc = depends(c_compiler)(lambda info: info.type == 'gcc')
include('compile-checks.configure') include('compile-checks.configure')
@depends(have_64_bit, @depends(have_64_bit,

Просмотреть файл

@ -1,133 +0,0 @@
LOCAL_PATH := $(call my-dir)
# Normally, we distribute the NDK with prebuilt binaries of STLport
# in $LOCAL_PATH/libs/<abi>/. However,
#
STLPORT_FORCE_REBUILD := $(strip $(STLPORT_FORCE_REBUILD))
ifndef STLPORT_FORCE_REBUILD
ifeq (,$(strip $(wildcard $(LOCAL_PATH)/libs/$(TARGET_ARCH_ABI)/libstlport_static$(TARGET_LIB_EXTENSION))))
$(call __ndk_info,WARNING: Rebuilding STLport libraries from sources!)
$(call __ndk_info,You might want to use $$NDK/build/tools/build-cxx-stl.sh --stl=stlport)
$(call __ndk_info,in order to build prebuilt versions to speed up your builds!)
STLPORT_FORCE_REBUILD := true
endif
endif
libstlport_path := $(LOCAL_PATH)
libstlport_src_files := \
src/dll_main.cpp \
src/fstream.cpp \
src/strstream.cpp \
src/sstream.cpp \
src/ios.cpp \
src/stdio_streambuf.cpp \
src/istream.cpp \
src/ostream.cpp \
src/iostream.cpp \
src/codecvt.cpp \
src/collate.cpp \
src/ctype.cpp \
src/monetary.cpp \
src/num_get.cpp \
src/num_put.cpp \
src/num_get_float.cpp \
src/num_put_float.cpp \
src/numpunct.cpp \
src/time_facets.cpp \
src/messages.cpp \
src/locale.cpp \
src/locale_impl.cpp \
src/locale_catalog.cpp \
src/facets_byname.cpp \
src/complex.cpp \
src/complex_io.cpp \
src/complex_trig.cpp \
src/string.cpp \
src/bitset.cpp \
src/allocators.cpp \
src/c_locale.c \
src/cxa.c \
libstlport_cflags := -D_GNU_SOURCE
libstlport_cppflags := -fuse-cxa-atexit
libstlport_c_includes := $(libstlport_path)/stlport
#It is much more practical to include the sources of GAbi++ in our builds
# of STLport. This is similar to what the GNU libstdc++ does (it includes
# its own copy of libsupc++)
#
# This simplifies usage, since you only have to list a single library
# as a dependency, instead of two, especially when using the standalone
# toolchain.
#
include $(dir $(LOCAL_PATH))/gabi++/sources.mk
libstlport_c_includes += $(libgabi++_c_includes)
ifneq ($(strip $(filter-out $(NDK_KNOWN_ARCHS),$(TARGET_ARCH))),)
libgabi++_src_files := src/delete.cc \
src/new.cc
endif
ifneq ($(STLPORT_FORCE_REBUILD),true)
$(call ndk_log,Using prebuilt STLport libraries)
include $(CLEAR_VARS)
LOCAL_MODULE := stlport_static
LOCAL_SRC_FILES := libs/$(TARGET_ARCH_ABI)/lib$(LOCAL_MODULE)$(TARGET_LIB_EXTENSION)
# For armeabi*, choose thumb mode unless LOCAL_ARM_MODE := arm
ifneq (,$(filter armeabi%,$(TARGET_ARCH_ABI)))
ifneq (arm,$(LOCAL_ARM_MODE))
LOCAL_SRC_FILES := libs/$(TARGET_ARCH_ABI)/thumb/lib$(LOCAL_MODULE)$(TARGET_LIB_EXTENSION)
endif
endif
LOCAL_EXPORT_C_INCLUDES := $(libstlport_c_includes)
LOCAL_CPP_FEATURES := rtti
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := stlport_shared
LOCAL_SRC_FILES := libs/$(TARGET_ARCH_ABI)/lib$(LOCAL_MODULE)$(TARGET_SONAME_EXTENSION)
# For armeabi*, choose thumb mode unless LOCAL_ARM_MODE := arm
$(info TARGET_ARCH_ABI=$(TARGET_ARCH_ABI))
$(info LOCAL_ARM_MODE=$(LOCAL_ARM_MODE))
ifneq (,$(filter armeabi%,$(TARGET_ARCH_ABI)))
ifneq (arm,$(LOCAL_ARM_MODE))
LOCAL_SRC_FILES := libs/$(TARGET_ARCH_ABI)/thumb/lib$(LOCAL_MODULE)$(TARGET_SONAME_EXTENSION)
endif
endif
LOCAL_EXPORT_C_INCLUDES := $(libstlport_c_includes)
LOCAL_CPP_FEATURES := rtti
include $(PREBUILT_SHARED_LIBRARY)
else # STLPORT_FORCE_REBUILD == true
$(call ndk_log,Rebuilding STLport libraries from sources)
include $(CLEAR_VARS)
LOCAL_MODULE := stlport_static
LOCAL_CPP_EXTENSION := .cpp .cc
LOCAL_SRC_FILES := $(libstlport_src_files)
LOCAL_SRC_FILES += $(libgabi++_src_files:%=../gabi++/%)
LOCAL_CFLAGS := $(libstlport_cflags)
LOCAL_CPPFLAGS := $(libstlport_cppflags)
LOCAL_C_INCLUDES := $(libstlport_c_includes)
LOCAL_EXPORT_C_INCLUDES := $(libstlport_c_includes)
LOCAL_CPP_FEATURES := rtti exceptions
include $(BUILD_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := stlport_shared
LOCAL_CPP_EXTENSION := .cpp .cc
LOCAL_SRC_FILES := $(libstlport_src_files)
LOCAL_SRC_FILES += $(libgabi++_src_files:%=../gabi++/%)
LOCAL_CFLAGS := $(libstlport_cflags)
LOCAL_CPPFLAGS := $(libstlport_cppflags)
LOCAL_C_INCLUDES := $(libstlport_c_includes)
LOCAL_EXPORT_C_INCLUDES := $(libstlport_c_includes)
LOCAL_CPP_FEATURES := rtti exceptions
include $(BUILD_SHARED_LIBRARY)
endif # STLPORT_FORCE_REBUILD == true

Просмотреть файл

@ -1,27 +0,0 @@
Boris Fomitchev grants Licensee a non-exclusive, non-transferable, royalty-free license to use STLport and its documentation without fee.
By downloading, using, or copying STLport or any portion thereof, Licensee agrees to abide by the intellectual property laws and all other applicable laws of the United States of America, and to all of the terms and conditions of this Agreement.
Licensee shall maintain the following copyright and permission notices on STLport sources and its documentation unchanged :
Copyright 1999,2000 Boris Fomitchev
This material is provided "as is", with absolutely no warranty expressed or implied. Any use is at your own risk.
Permission to use or copy this software for any purpose is hereby granted without fee, provided the above notices are retained on all copies. Permission to modify the code and to distribute modified code is granted, provided the above notices are retained, and a notice that the code was modified is included with the above copyright notice.
The Licensee may distribute binaries compiled with STLport (whether original or modified) without any royalties or restrictions.
The Licensee may distribute original or modified STLport sources, provided that:
The conditions indicated in the above permission notice are met;
The following copyright notices are retained when present, and conditions provided in accompanying permission notices are met :
Copyright 1994 Hewlett-Packard Company
Copyright 1996,97 Silicon Graphics Computer Systems, Inc.
Copyright 1997 Moscow Center for SPARC Technology.
Permission to use, copy, modify, distribute and sell this software and its documentation for any purpose is hereby granted without fee, provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting documentation. Hewlett-Packard Company makes no representations about the suitability of this software for any purpose. It is provided "as is" without express or implied warranty.
Permission to use, copy, modify, distribute and sell this software and its documentation for any purpose is hereby granted without fee, provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting documentation. Silicon Graphics makes no representations about the suitability of this software for any purpose. It is provided "as is" without express or implied warranty.
Permission to use, copy, modify, distribute and sell this software and its documentation for any purpose is hereby granted without fee, provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting documentation. Moscow Center for SPARC Technology makes no representations about the suitability of this software for any purpose. It is provided "as is" without express or implied warranty.

Просмотреть файл

Просмотреть файл

@ -1,69 +0,0 @@
STLport for Android
WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
This feature is currently in beta. In case of issue
please contact the android-ndk support forum or
file bugs at http://b.android.com
WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
This directory contains a port of STLport for Android, which provides
a simple STL implementation. Note that it currently does not support
C++ exceptions and RTTI. Support for wchar_t and locales is probably buggy.
You can either use it as a static or shared library.
1/ The static library is recommended if you will only produce
one shared library for your project. All necessary STLport functions
will be added to it. This option should also generate smaller
overall binaries.
2/ The shared library, is recommended if you want to produce
several shared libraries in your project, because it avoids copying the
same STLport functions to each one of them, and having different instances
of the same global variables (which can easily conflict or result in
undefined behaviour).
To use the *static* library, define APP_STL in your Application.mk as follows:
APP_STL := stlport_static
To use the *shared* library, use "stlport_shared" instead:
APP_STL := stlport_shared
Note that, in this case, you will need, in your application, to explicitely
load the 'stlport_shared' library before any library that depends on it.
For example:
static {
System.loadLibrary("stlport_shared");
System.loadLibrary("foo");
System.loadLibrary("bar");
}
If both libfoo.so and libbar.so depend on STLport.
You can build the STLport unit test program by doing the following:
cd $NDK
tests/run-tests.sh --test=test-stlport
If you have an Android device connected to your machine, this will
automatically try to run the generated test command. Note that for now
a few tests are still failing (mostly related to wchar_t and locales).
They should be fixed hopefully by a later release of this library.
The NDK comes with prebuilt binaries for this library to speed up development.
You can however rebuild them from sources in your own application build by
defining STLPORT_FORCE_REBUILD to 'true' in your Application.mk as in:
STLPORT_FORCE_REBUILD := true
VERSION INFORMATION: This module is based on STLport version 5.2.0

Просмотреть файл

@ -1,9 +0,0 @@
Version: 5.2.1
Changes:
* Added _android.h included by _system.h
* Do not use linux float functions in num_get_float.cpp as Android does not
have them.
* _mbstate_t.h cannot define its own mbstate_t as bionic already defines
it.
* _pair.h needs to define bionic's (sgi's) internal pair header guard.

Просмотреть файл

@ -1,11 +0,0 @@
This copy of STLport was taken from the Android NDK git repository:
https://android.googlesource.com/platform/ndk.git
under sources/cxx-stl/stlport/.
The last changes to that directory come from commit ba4baa4
The overrides/ directory contains Mozilla-specific overrides to the standard
C++ headers found in the NDK.
The following patches are applied on top:
- android-mozilla-config.patch: Adjusts Android-specific configuration
to the mozilla codebase use of the STL.

Просмотреть файл

@ -1,64 +0,0 @@
**********************************************************************
* README file for STLport 5.0 *
* *
**********************************************************************
This directory contains the STLport-5.0 release.
What's inside :
README - this file
INSTALL - installation instructions
bin - installation directory for STLport unit tests;
it may contain more subdirs, if you use
crosscompilation
build/lib - build directory for STLport library (if you use
STLport iostreams and/or locale only)
build/test/unit - build directory for regression (unit) tests
build/test/eh - build directory for exception handling tests
stlport - main STLport include directory
src - source for iostreams implementation and other parts
that aren't pure template code
lib - installation directory for STLport library (if you
use STLport iostreams and/or locale only);
it may contain more subdirs, if you use
crosscompilation
test/unit - unit (regression) tests
test/eh - exception handling test using STLport iostreams
etc - miscellanous files (ChangeLog, TODO, scripts, etc.)
GETTING STLPORT
To download the latest version of STLport, please be sure to visit
https://sourceforge.net/project/showfiles.php?group_id=146814
LEGALESE
This software is being distributed under the following terms:
*
*
* Copyright (c) 1994
* Hewlett-Packard Company
*
* Copyright (c) 1996-1999
* Silicon Graphics Computer Systems, Inc.
*
* Copyright (c) 1997
* Moscow Center for SPARC Technology
*
* Copyright (c) 1999-2003
* Boris Fomitchev
*
* This material is provided "as is", with absolutely no warranty expressed
* or implied. Any use is at your own risk.
*
* Permission to use or copy this software for any purpose is hereby granted
* without fee, provided the above notices are retained on all copies.
* Permission to modify the code and to distribute modified code is granted,
* provided the above notices are retained, and a notice that the code was
* modified is included with the above copyright notice.
*
**********************************************************************

Просмотреть файл

@ -1,82 +0,0 @@
diff --git a/stlport/stl/config/_android.h b/stlport/stl/config/_android.h
--- a/stlport/stl/config/_android.h
+++ b/stlport/stl/config/_android.h
@@ -10,18 +10,18 @@
#define _PTHREADS
// Don't have native <cplusplus> headers
#define _STLP_HAS_NO_NEW_C_HEADERS 1
// Use unix for streams
#define _STLP_USE_UNIX_IO 1
-// We do have rtti support now through GAbi++
-#undef _STLP_NO_RTTI
+// We don't want rtti support
+#define _STLP_NO_RTTI 1
// C library is in the global namespace.
#define _STLP_VENDOR_GLOBAL_CSTD 1
// Don't have underlying local support.
#undef _STLP_REAL_LOCALE_IMPLEMENTED
// No pthread_spinlock_t in Android
@@ -32,48 +32,42 @@
// Little endian platform.
#define _STLP_LITTLE_ENDIAN 1
// No <exception> headers
#undef _STLP_NO_EXCEPTION_HEADER
// No throwing exceptions
-#undef _STLP_NO_EXCEPTIONS
-
+#define _STLP_NO_EXCEPTIONS 1
+#define _STLP_NO_EXCEPTION_HEADER 1
// No need to define our own namespace
#define _STLP_NO_OWN_NAMESPACE 1
// Use __new_alloc instead of __node_alloc, so we don't need static functions.
#define _STLP_USE_SIMPLE_NODE_ALLOC 1
// Don't use extern versions of range errors, so we don't need to
// compile as a library.
#define _STLP_USE_NO_EXTERN_RANGE_ERRORS 1
// The system math library doesn't have long double variants, e.g
// sinl, cosl, etc
#define _STLP_NO_VENDOR_MATH_L 1
-// Define how to include our native headers.
-#define _STLP_NATIVE_HEADER(header) <usr/include/header>
-#define _STLP_NATIVE_C_HEADER(header) <../include/header>
-#define _STLP_NATIVE_CPP_C_HEADER(header) <../../gabi++/include/header>
-#define _STLP_NATIVE_CPP_RUNTIME_HEADER(header) <../../gabi++/include/header>
-#define _STLP_NATIVE_OLD_STREAMS_HEADER(header) <usr/include/header>
-
// Include most of the gcc settings.
#include <stl/config/_gcc.h>
// Do not use glibc, Android is missing some things.
#undef _STLP_USE_GLIBC
// No exceptions.
-#undef _STLP_NO_UNCAUGHT_EXCEPT_SUPPORT
-#undef _STLP_NO_UNEXPECTED_EXCEPT_SUPPORT
+#define _STLP_NO_UNCAUGHT_EXCEPT_SUPPORT 1
+#define _STLP_NO_UNEXPECTED_EXCEPT_SUPPORT 1
-#ifndef _ANDROID_NDK_BLAZE_
-// Android does have include_next but it doesn't work well in our build system.
-#undef _STLP_HAS_INCLUDE_NEXT
-#endif
+#define _STLP_HAS_INCLUDE_NEXT 1
+
+// Use operator new instead of stlport own node allocator
+#undef _STLP_USE_NEWALLOC
+#define _STLP_USE_NEWALLOC 1
#endif /* __stl_config__android_h */

Просмотреть файл

@ -1,78 +0,0 @@
# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
# vim: set filetype=python:
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
Library('stlport')
# Keep the same name as the NDK-provided library, while using a shorter
# name for the Library for convenience in moz.build.
STATIC_LIBRARY_NAME = 'stlport_static'
FORCE_STATIC_LIB = True
SOURCES += [
'src/allocators.cpp',
'src/bitset.cpp',
'src/codecvt.cpp',
'src/collate.cpp',
'src/complex.cpp',
'src/complex_io.cpp',
'src/complex_trig.cpp',
'src/ctype.cpp',
'src/dll_main.cpp',
'src/facets_byname.cpp',
'src/fstream.cpp',
'src/ios.cpp',
'src/iostream.cpp',
'src/istream.cpp',
'src/locale.cpp',
'src/locale_catalog.cpp',
'src/locale_impl.cpp',
'src/messages.cpp',
'src/monetary.cpp',
'src/num_get.cpp',
'src/num_get_float.cpp',
'src/num_put.cpp',
'src/num_put_float.cpp',
'src/numpunct.cpp',
'src/ostream.cpp',
'src/sstream.cpp',
'src/stdio_streambuf.cpp',
'src/string.cpp',
'src/strstream.cpp',
'src/time_facets.cpp',
]
SOURCES += [
'src/c_locale.c',
'src/cxa.c',
]
DEFINES['_GNU_SOURCE'] = True
LOCAL_INCLUDES += [
'stlport',
]
DISABLE_STL_WRAPPING = True
NO_VISIBILITY_FLAGS = True
# Suppress warnings in third-party code.
if CONFIG['GNU_CXX']:
CXXFLAGS += [
'-Wno-empty-body',
'-Wno-type-limits',
'-Wno-unused-local-typedefs',
]
# Force to build a static library, instead of a fake library, without
# installing it in dist/lib.
NO_EXPAND_LIBS = True
# We allow warnings for third-party code that can be updated from upstream.
ALLOW_COMPILER_WARNINGS = True
CXXFLAGS += [
'-fuse-cxa-atexit',
]

Просмотреть файл

@ -1,65 +0,0 @@
/* -*- c++ -*- */
/*
* Copyright (C) 2009 The Android Open Source Project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
/*
* This header is taken from $ndk/sources/cxx-stl/system/include/new,
* and it fixes a bug in the NDK header where the nothrow versions of
* placement new and delete are not specified with 'throw()'. This bug
* causes GCC to not null-check the results from these functions.
*/
#ifndef __NEW__
#define __NEW__
#include <cstddef>
extern "C++" {
namespace std {
struct nothrow_t {};
extern const nothrow_t nothrow;
}
void* operator new(std::size_t);
void* operator new[](std::size_t);
void operator delete(void*);
void operator delete[](void*);
void* operator new(std::size_t, const std::nothrow_t&) throw();
void* operator new[](std::size_t, const std::nothrow_t&) throw();
void operator delete(void*, const std::nothrow_t&) throw();
void operator delete[](void*, const std::nothrow_t&) throw();
inline void* operator new(std::size_t, void* p) { return p; }
inline void* operator new[](std::size_t, void* p) { return p; }
// these next two are not really required, since exceptions are off
inline void operator delete(void*, void*) { }
inline void operator delete[](void*, void*) { }
} // extern C++
#endif // __NEW__

Просмотреть файл

@ -1,117 +0,0 @@
/*
* Copyright (c) 1999
* Silicon Graphics Computer Systems, Inc.
*
* Copyright (c) 1999
* Boris Fomitchev
*
* This material is provided "as is", with absolutely no warranty expressed
* or implied. Any use is at your own risk.
*
* Permission to use or copy this software for any purpose is hereby granted
* without fee, provided the above notices are retained on all copies.
* Permission to modify the code and to distribute modified code is granted,
* provided the above notices are retained, and a notice that the code was
* modified is included with the above copyright notice.
*
*/
#ifndef _STLP_STDIO_FILE_H
#define _STLP_STDIO_FILE_H
/* This file provides a low-level interface between the internal
* representation of struct FILE, from the C stdio library, and
* the C++ I/O library. */
#ifndef _STLP_CSTDIO
# include <cstdio>
#endif
#ifndef _STLP_CSTDDEF
# include <cstddef>
#endif
#if defined (__MSL__)
# include <unix.h> /* get the definition of fileno */
#endif
_STLP_BEGIN_NAMESPACE
#if defined (_STLP_WCE)
inline int _FILE_fd(const FILE *__f) {
/* Check if FILE is one of the three standard streams
We do this check first, because invoking _fileno() on one of them
causes a terminal window to be created. This also happens if you do
any IO on them, but merely retrieving the filedescriptor shouldn't
already do that.
Obviously this is pretty implementation-specific because it requires
that indeed the first three FDs are always the same, but that is not
only common but almost guaranteed. */
for (int __fd = 0; __fd != 3; ++__fd) {
if (__f == _getstdfilex(__fd))
return __fd;
}
/* Normal files. */
return (int)::_fileno((FILE*)__f);
}
# elif defined (_STLP_SCO_OPENSERVER) || defined (__NCR_SVR)
inline int _FILE_fd(const FILE *__f) { return __f->__file; }
# elif defined (__sun) && defined (_LP64)
inline int _FILE_fd(const FILE *__f) { return (int) __f->__pad[2]; }
#elif defined (__hpux) /* && defined(__hppa) && defined(__HP_aCC)) */ || \
defined (__MVS__) || \
defined (_STLP_USE_UCLIBC) /* should be before _STLP_USE_GLIBC */
inline int _FILE_fd(const FILE *__f) { return fileno(__CONST_CAST(FILE*, __f)); }
#elif defined (_STLP_USE_GLIBC)
inline int _FILE_fd(const FILE *__f) { return __f->_fileno; }
#elif defined (__BORLANDC__)
inline int _FILE_fd(const FILE *__f) { return __f->fd; }
#elif defined (__MWERKS__)
/* using MWERKS-specific defines here to detect other OS targets
* dwa: I'm not sure they provide fileno for all OS's, but this should
* work for Win32 and WinCE
* Hmm, at least for Novell NetWare __dest_os == __mac_os true too..
* May be both __dest_os and __mac_os defined and empty? - ptr */
# if __dest_os == __mac_os
inline int _FILE_fd(const FILE *__f) { return ::fileno(__CONST_CAST(FILE*, __f)); }
# else
inline int _FILE_fd(const FILE *__f) { return ::_fileno(__CONST_CAST(FILE*, __f)); }
# endif
#elif defined (__QNXNTO__) || defined (__WATCOMC__) || defined (__EMX__)
inline int _FILE_fd(const FILE *__f) { return __f->_handle; }
#elif defined (__Lynx__)
/* the prototypes are taken from LynxOS patch for STLport 4.0 */
inline int _FILE_fd(const FILE *__f) { return __f->_fd; }
#else /* The most common access to file descriptor. */
inline int _FILE_fd(const FILE *__f) { return __f->_file; }
#endif
_STLP_END_NAMESPACE
#endif /* _STLP_STDIO_FILE_H */
/* Local Variables:
* mode:C++
* End: */

Просмотреть файл

@ -1,46 +0,0 @@
/*
* Copyright (c) 1999
* Silicon Graphics Computer Systems, Inc.
*
* Copyright (c) 1999
* Boris Fomitchev
*
* This material is provided "as is", with absolutely no warranty expressed
* or implied. Any use is at your own risk.
*
* Permission to use or copy this software for any purpose is hereby granted
* without fee, provided the above notices are retained on all copies.
* Permission to modify the code and to distribute modified code is granted,
* provided the above notices are retained, and a notice that the code was
* modified is included with the above copyright notice.
*
*/
#ifndef ACQUIRE_RELEASE_H
#define ACQUIRE_RELEASE_H
#include "c_locale.h"
_STLP_BEGIN_NAMESPACE
_STLP_MOVE_TO_PRIV_NAMESPACE
_Locale_ctype* _STLP_CALL __acquire_ctype(const char* &name, char *buf, _Locale_name_hint* hint, int *__err_code);
_Locale_codecvt* _STLP_CALL __acquire_codecvt(const char* &name, char *buf, _Locale_name_hint* hint, int *__err_code);
_Locale_numeric* _STLP_CALL __acquire_numeric(const char* &name, char *buf, _Locale_name_hint* hint, int *__err_code);
_Locale_collate* _STLP_CALL __acquire_collate(const char* &name, char *buf, _Locale_name_hint* hint, int *__err_code);
_Locale_monetary* _STLP_CALL __acquire_monetary(const char* &name, char *buf, _Locale_name_hint* hint, int *__err_code);
_Locale_time* _STLP_CALL __acquire_time(const char* &name, char *buf, _Locale_name_hint*, int *__err_code);
_Locale_messages* _STLP_CALL __acquire_messages(const char* &name, char *buf, _Locale_name_hint* hint, int *__err_code);
void _STLP_CALL __release_ctype(_Locale_ctype* cat);
void _STLP_CALL __release_codecvt(_Locale_codecvt* cat);
void _STLP_CALL __release_numeric(_Locale_numeric* cat);
void _STLP_CALL __release_collate(_Locale_collate* cat);
void _STLP_CALL __release_monetary(_Locale_monetary* cat);
void _STLP_CALL __release_time(_Locale_time* __time);
void _STLP_CALL __release_messages(_Locale_messages* cat);
_STLP_MOVE_TO_STD_NAMESPACE
_STLP_END_NAMESPACE
#endif /* ACQUIRE_RELEASE_H */

Просмотреть файл

@ -1,21 +0,0 @@
#ifndef ALIGNED_BUFFER_H
#define ALIGNED_BUFFER_H
_STLP_BEGIN_NAMESPACE
// this is for fake initialization
template<class T>
union _Stl_aligned_buffer {
char buf[sizeof(T)];
struct { double a; double b; } padding;
T* operator&() {
return __REINTERPRET_CAST(T*, this);
}
T const* operator&() const {
return __REINTERPRET_CAST(T const*, this);
}
};
_STLP_END_NAMESPACE
#endif

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -1,156 +0,0 @@
/*
* Copyright (c) 1998
* Silicon Graphics Computer Systems, Inc.
*
* Copyright (c) 1999
* Boris Fomitchev
*
* This material is provided "as is", with absolutely no warranty expressed
* or implied. Any use is at your own risk.
*
* Permission to use or copy this software for any purpose is hereby granted
* without fee, provided the above notices are retained on all copies.
* Permission to modify the code and to distribute modified code is granted,
* provided the above notices are retained, and a notice that the code was
* modified is included with the above copyright notice.
*
*/
#include "stlport_prefix.h"
#include <bitset>
_STLP_BEGIN_NAMESPACE
_STLP_MOVE_TO_PRIV_NAMESPACE
// ------------------------------------------------------------
// Lookup tables for find and count operations.
size_t _Bs_G::_S_count(const unsigned char *__first,
const unsigned char *__last)
{
static const unsigned char _bit_count[256] = {
0, /* 0 */ 1, /* 1 */ 1, /* 2 */ 2, /* 3 */ 1, /* 4 */
2, /* 5 */ 2, /* 6 */ 3, /* 7 */ 1, /* 8 */ 2, /* 9 */
2, /* 10 */ 3, /* 11 */ 2, /* 12 */ 3, /* 13 */ 3, /* 14 */
4, /* 15 */ 1, /* 16 */ 2, /* 17 */ 2, /* 18 */ 3, /* 19 */
2, /* 20 */ 3, /* 21 */ 3, /* 22 */ 4, /* 23 */ 2, /* 24 */
3, /* 25 */ 3, /* 26 */ 4, /* 27 */ 3, /* 28 */ 4, /* 29 */
4, /* 30 */ 5, /* 31 */ 1, /* 32 */ 2, /* 33 */ 2, /* 34 */
3, /* 35 */ 2, /* 36 */ 3, /* 37 */ 3, /* 38 */ 4, /* 39 */
2, /* 40 */ 3, /* 41 */ 3, /* 42 */ 4, /* 43 */ 3, /* 44 */
4, /* 45 */ 4, /* 46 */ 5, /* 47 */ 2, /* 48 */ 3, /* 49 */
3, /* 50 */ 4, /* 51 */ 3, /* 52 */ 4, /* 53 */ 4, /* 54 */
5, /* 55 */ 3, /* 56 */ 4, /* 57 */ 4, /* 58 */ 5, /* 59 */
4, /* 60 */ 5, /* 61 */ 5, /* 62 */ 6, /* 63 */ 1, /* 64 */
2, /* 65 */ 2, /* 66 */ 3, /* 67 */ 2, /* 68 */ 3, /* 69 */
3, /* 70 */ 4, /* 71 */ 2, /* 72 */ 3, /* 73 */ 3, /* 74 */
4, /* 75 */ 3, /* 76 */ 4, /* 77 */ 4, /* 78 */ 5, /* 79 */
2, /* 80 */ 3, /* 81 */ 3, /* 82 */ 4, /* 83 */ 3, /* 84 */
4, /* 85 */ 4, /* 86 */ 5, /* 87 */ 3, /* 88 */ 4, /* 89 */
4, /* 90 */ 5, /* 91 */ 4, /* 92 */ 5, /* 93 */ 5, /* 94 */
6, /* 95 */ 2, /* 96 */ 3, /* 97 */ 3, /* 98 */ 4, /* 99 */
3, /* 100 */ 4, /* 101 */ 4, /* 102 */ 5, /* 103 */ 3, /* 104 */
4, /* 105 */ 4, /* 106 */ 5, /* 107 */ 4, /* 108 */ 5, /* 109 */
5, /* 110 */ 6, /* 111 */ 3, /* 112 */ 4, /* 113 */ 4, /* 114 */
5, /* 115 */ 4, /* 116 */ 5, /* 117 */ 5, /* 118 */ 6, /* 119 */
4, /* 120 */ 5, /* 121 */ 5, /* 122 */ 6, /* 123 */ 5, /* 124 */
6, /* 125 */ 6, /* 126 */ 7, /* 127 */ 1, /* 128 */ 2, /* 129 */
2, /* 130 */ 3, /* 131 */ 2, /* 132 */ 3, /* 133 */ 3, /* 134 */
4, /* 135 */ 2, /* 136 */ 3, /* 137 */ 3, /* 138 */ 4, /* 139 */
3, /* 140 */ 4, /* 141 */ 4, /* 142 */ 5, /* 143 */ 2, /* 144 */
3, /* 145 */ 3, /* 146 */ 4, /* 147 */ 3, /* 148 */ 4, /* 149 */
4, /* 150 */ 5, /* 151 */ 3, /* 152 */ 4, /* 153 */ 4, /* 154 */
5, /* 155 */ 4, /* 156 */ 5, /* 157 */ 5, /* 158 */ 6, /* 159 */
2, /* 160 */ 3, /* 161 */ 3, /* 162 */ 4, /* 163 */ 3, /* 164 */
4, /* 165 */ 4, /* 166 */ 5, /* 167 */ 3, /* 168 */ 4, /* 169 */
4, /* 170 */ 5, /* 171 */ 4, /* 172 */ 5, /* 173 */ 5, /* 174 */
6, /* 175 */ 3, /* 176 */ 4, /* 177 */ 4, /* 178 */ 5, /* 179 */
4, /* 180 */ 5, /* 181 */ 5, /* 182 */ 6, /* 183 */ 4, /* 184 */
5, /* 185 */ 5, /* 186 */ 6, /* 187 */ 5, /* 188 */ 6, /* 189 */
6, /* 190 */ 7, /* 191 */ 2, /* 192 */ 3, /* 193 */ 3, /* 194 */
4, /* 195 */ 3, /* 196 */ 4, /* 197 */ 4, /* 198 */ 5, /* 199 */
3, /* 200 */ 4, /* 201 */ 4, /* 202 */ 5, /* 203 */ 4, /* 204 */
5, /* 205 */ 5, /* 206 */ 6, /* 207 */ 3, /* 208 */ 4, /* 209 */
4, /* 210 */ 5, /* 211 */ 4, /* 212 */ 5, /* 213 */ 5, /* 214 */
6, /* 215 */ 4, /* 216 */ 5, /* 217 */ 5, /* 218 */ 6, /* 219 */
5, /* 220 */ 6, /* 221 */ 6, /* 222 */ 7, /* 223 */ 3, /* 224 */
4, /* 225 */ 4, /* 226 */ 5, /* 227 */ 4, /* 228 */ 5, /* 229 */
5, /* 230 */ 6, /* 231 */ 4, /* 232 */ 5, /* 233 */ 5, /* 234 */
6, /* 235 */ 5, /* 236 */ 6, /* 237 */ 6, /* 238 */ 7, /* 239 */
4, /* 240 */ 5, /* 241 */ 5, /* 242 */ 6, /* 243 */ 5, /* 244 */
6, /* 245 */ 6, /* 246 */ 7, /* 247 */ 5, /* 248 */ 6, /* 249 */
6, /* 250 */ 7, /* 251 */ 6, /* 252 */ 7, /* 253 */ 7, /* 254 */
8 /* 255 */
};
size_t __result(0);
while ( __first < __last ) {
__result += _bit_count[*(__first++)];
}
return __result;
}
unsigned char _Bs_G::_S_first_one(unsigned char __byte)
{
static const unsigned char _first_one[256] = {
0, /* 0 */ 0, /* 1 */ 1, /* 2 */ 0, /* 3 */ 2, /* 4 */
0, /* 5 */ 1, /* 6 */ 0, /* 7 */ 3, /* 8 */ 0, /* 9 */
1, /* 10 */ 0, /* 11 */ 2, /* 12 */ 0, /* 13 */ 1, /* 14 */
0, /* 15 */ 4, /* 16 */ 0, /* 17 */ 1, /* 18 */ 0, /* 19 */
2, /* 20 */ 0, /* 21 */ 1, /* 22 */ 0, /* 23 */ 3, /* 24 */
0, /* 25 */ 1, /* 26 */ 0, /* 27 */ 2, /* 28 */ 0, /* 29 */
1, /* 30 */ 0, /* 31 */ 5, /* 32 */ 0, /* 33 */ 1, /* 34 */
0, /* 35 */ 2, /* 36 */ 0, /* 37 */ 1, /* 38 */ 0, /* 39 */
3, /* 40 */ 0, /* 41 */ 1, /* 42 */ 0, /* 43 */ 2, /* 44 */
0, /* 45 */ 1, /* 46 */ 0, /* 47 */ 4, /* 48 */ 0, /* 49 */
1, /* 50 */ 0, /* 51 */ 2, /* 52 */ 0, /* 53 */ 1, /* 54 */
0, /* 55 */ 3, /* 56 */ 0, /* 57 */ 1, /* 58 */ 0, /* 59 */
2, /* 60 */ 0, /* 61 */ 1, /* 62 */ 0, /* 63 */ 6, /* 64 */
0, /* 65 */ 1, /* 66 */ 0, /* 67 */ 2, /* 68 */ 0, /* 69 */
1, /* 70 */ 0, /* 71 */ 3, /* 72 */ 0, /* 73 */ 1, /* 74 */
0, /* 75 */ 2, /* 76 */ 0, /* 77 */ 1, /* 78 */ 0, /* 79 */
4, /* 80 */ 0, /* 81 */ 1, /* 82 */ 0, /* 83 */ 2, /* 84 */
0, /* 85 */ 1, /* 86 */ 0, /* 87 */ 3, /* 88 */ 0, /* 89 */
1, /* 90 */ 0, /* 91 */ 2, /* 92 */ 0, /* 93 */ 1, /* 94 */
0, /* 95 */ 5, /* 96 */ 0, /* 97 */ 1, /* 98 */ 0, /* 99 */
2, /* 100 */ 0, /* 101 */ 1, /* 102 */ 0, /* 103 */ 3, /* 104 */
0, /* 105 */ 1, /* 106 */ 0, /* 107 */ 2, /* 108 */ 0, /* 109 */
1, /* 110 */ 0, /* 111 */ 4, /* 112 */ 0, /* 113 */ 1, /* 114 */
0, /* 115 */ 2, /* 116 */ 0, /* 117 */ 1, /* 118 */ 0, /* 119 */
3, /* 120 */ 0, /* 121 */ 1, /* 122 */ 0, /* 123 */ 2, /* 124 */
0, /* 125 */ 1, /* 126 */ 0, /* 127 */ 7, /* 128 */ 0, /* 129 */
1, /* 130 */ 0, /* 131 */ 2, /* 132 */ 0, /* 133 */ 1, /* 134 */
0, /* 135 */ 3, /* 136 */ 0, /* 137 */ 1, /* 138 */ 0, /* 139 */
2, /* 140 */ 0, /* 141 */ 1, /* 142 */ 0, /* 143 */ 4, /* 144 */
0, /* 145 */ 1, /* 146 */ 0, /* 147 */ 2, /* 148 */ 0, /* 149 */
1, /* 150 */ 0, /* 151 */ 3, /* 152 */ 0, /* 153 */ 1, /* 154 */
0, /* 155 */ 2, /* 156 */ 0, /* 157 */ 1, /* 158 */ 0, /* 159 */
5, /* 160 */ 0, /* 161 */ 1, /* 162 */ 0, /* 163 */ 2, /* 164 */
0, /* 165 */ 1, /* 166 */ 0, /* 167 */ 3, /* 168 */ 0, /* 169 */
1, /* 170 */ 0, /* 171 */ 2, /* 172 */ 0, /* 173 */ 1, /* 174 */
0, /* 175 */ 4, /* 176 */ 0, /* 177 */ 1, /* 178 */ 0, /* 179 */
2, /* 180 */ 0, /* 181 */ 1, /* 182 */ 0, /* 183 */ 3, /* 184 */
0, /* 185 */ 1, /* 186 */ 0, /* 187 */ 2, /* 188 */ 0, /* 189 */
1, /* 190 */ 0, /* 191 */ 6, /* 192 */ 0, /* 193 */ 1, /* 194 */
0, /* 195 */ 2, /* 196 */ 0, /* 197 */ 1, /* 198 */ 0, /* 199 */
3, /* 200 */ 0, /* 201 */ 1, /* 202 */ 0, /* 203 */ 2, /* 204 */
0, /* 205 */ 1, /* 206 */ 0, /* 207 */ 4, /* 208 */ 0, /* 209 */
1, /* 210 */ 0, /* 211 */ 2, /* 212 */ 0, /* 213 */ 1, /* 214 */
0, /* 215 */ 3, /* 216 */ 0, /* 217 */ 1, /* 218 */ 0, /* 219 */
2, /* 220 */ 0, /* 221 */ 1, /* 222 */ 0, /* 223 */ 5, /* 224 */
0, /* 225 */ 1, /* 226 */ 0, /* 227 */ 2, /* 228 */ 0, /* 229 */
1, /* 230 */ 0, /* 231 */ 3, /* 232 */ 0, /* 233 */ 1, /* 234 */
0, /* 235 */ 2, /* 236 */ 0, /* 237 */ 1, /* 238 */ 0, /* 239 */
4, /* 240 */ 0, /* 241 */ 1, /* 242 */ 0, /* 243 */ 2, /* 244 */
0, /* 245 */ 1, /* 246 */ 0, /* 247 */ 3, /* 248 */ 0, /* 249 */
1, /* 250 */ 0, /* 251 */ 2, /* 252 */ 0, /* 253 */ 1, /* 254 */
0, /* 255 */
};
return _first_one[__byte];
}
_STLP_MOVE_TO_STD_NAMESPACE
_STLP_END_NAMESPACE

Просмотреть файл

@ -1,29 +0,0 @@
/*
* Copyright (c) 1999
* Silicon Graphics Computer Systems, Inc.
*
* Copyright (c) 1999
* Boris Fomitchev
*
* This material is provided "as is", with absolutely no warranty expressed
* or implied. Any use is at your own risk.
*
* Permission to use or copy this software for any purpose is hereby granted
* without fee, provided the above notices are retained on all copies.
* Permission to modify the code and to distribute modified code is granted,
* provided the above notices are retained, and a notice that the code was
* modified is included with the above copyright notice.
*
*/
#include "stlport_prefix.h"
#include "c_locale.h"
#if defined (_STLP_WIN32) && !defined (_STLP_WCE)
# include "c_locale_win32/c_locale_win32.c"
#elif defined (_STLP_USE_GLIBC2_LOCALIZATION)
# include "c_locale_glibc/c_locale_glibc2.c" /* glibc 2.2 and newer */
#else
# include "c_locale_dummy/c_locale_dummy.c"
#endif

Просмотреть файл

@ -1,450 +0,0 @@
/*
* Copyright (c) 1999
* Silicon Graphics Computer Systems, Inc.
*
* Copyright (c) 1999
* Boris Fomitchev
*
* This material is provided "as is", with absolutely no warranty expressed
* or implied. Any use is at your own risk.
*
* Permission to use or copy this software for any purpose is hereby granted
* without fee, provided the above notices are retained on all copies.
* Permission to modify the code and to distribute modified code is granted,
* provided the above notices are retained, and a notice that the code was
* modified is included with the above copyright notice.
*
*/
/*
* It is impossible to write the C++ locale library in terms of locales
* as defined in the C standard. Instead, we write the C++ locale and I/O
* library in terms of a low level C-like interface. This file defines
* that interface.
*
* The low-level locale interface can't be written portably; there
* must be a version of it for each platform that the C++ library
* is ported to. On many systems this interface may be a thin wrapper
* for existing functionality.
*/
#ifndef _STLP_C_LOCALE_IMPL_H
#define _STLP_C_LOCALE_IMPL_H
#include "stlport_prefix.h"
#include <wchar.h> /* for mbstate_t */
#include <stl/c_locale.h>
struct _Locale_name_hint;
#if defined (_GNU_SOURCE) && defined (__GLIBC__) && \
((__GLIBC__ > 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 2))
# define _STLP_USE_GLIBC2_LOCALIZATION
# include <nl_types.h>
typedef nl_catd nl_catd_type;
#else
typedef int nl_catd_type;
#endif
/*
* A number: the maximum length of a simple locale name.
* (i.e. a name like like en_US, as opposed to a name like
* en_US/de_AT/de_AT/es_MX/en_US/en_US) */
#define _Locale_MAX_SIMPLE_NAME 256
#ifdef __cplusplus
extern "C" {
#endif
/*
* Typedefs:
*/
typedef unsigned short int _Locale_mask_t;
/* Function called during STLport library load phase. Might contain any
* code necessary to the platform localization layer.
*/
void _Locale_init(void);
/* Function called during STLport library unload. Might contain any
* code necessary to the platform localization layer.
*/
void _Locale_final(void);
/* Create a category of the locale with the given name.
*
* The char* argument is a simple (not a composite) locale name, which may
* neither be an empty string nor a null pointer.
*
* These functions return NULL to indicate failure. Failure reason should be reported
* using the __err_code pointer.
*/
struct _Locale_ctype* _Locale_ctype_create(const char *, struct _Locale_name_hint*, int * /* __err_code */);
struct _Locale_codecvt* _Locale_codecvt_create(const char *, struct _Locale_name_hint*, int * /* __err_code */);
struct _Locale_numeric* _Locale_numeric_create(const char *, struct _Locale_name_hint*, int * /* __err_code */);
struct _Locale_time* _Locale_time_create(const char *, struct _Locale_name_hint*, int * /* __err_code */);
struct _Locale_collate* _Locale_collate_create(const char *, struct _Locale_name_hint*, int * /* __err_code */);
struct _Locale_monetary* _Locale_monetary_create(const char *, struct _Locale_name_hint*, int * /* __err_code */);
struct _Locale_messages* _Locale_messages_create(const char *, struct _Locale_name_hint*, int * /* __err_code */);
/* Give error reason on failure of one of the _Locale_*_create functions. Available
* reasons are:
* 0: No specific error reason has been reported.
* 1: No platform support for the given facet.
* 2: Unknown locale name
* 3: No platform API for localization support.
* 4: No more memory
*/
#define _STLP_LOC_UNDEFINED 0
#define _STLP_LOC_UNSUPPORTED_FACET_CATEGORY 1
#define _STLP_LOC_UNKNOWN_NAME 2
#define _STLP_LOC_NO_PLATFORM_SUPPORT 3
#define _STLP_LOC_NO_MEMORY 4
/* Release a category of a locale
*
* These functions are used to release a category acquired with the
* according _Locale_*_create() functions.
*/
void _Locale_ctype_destroy(struct _Locale_ctype *);
void _Locale_codecvt_destroy(struct _Locale_codecvt *);
void _Locale_numeric_destroy(struct _Locale_numeric *);
void _Locale_time_destroy(struct _Locale_time *);
void _Locale_collate_destroy(struct _Locale_collate *);
void _Locale_monetary_destroy(struct _Locale_monetary *);
void _Locale_messages_destroy(struct _Locale_messages *);
/*
* Returns the name of the user's default locale in each
* category, as a null-terminated string. A NULL value
* means the default "C" locale.
*/
const char * _Locale_ctype_default(char * __buf);
const char * _Locale_numeric_default(char * __buf);
const char * _Locale_time_default(char * __buf);
const char * _Locale_collate_default(char * __buf);
const char * _Locale_monetary_default(char * __buf);
const char * _Locale_messages_default(char * __buf);
/* Retrieve the name of the given category
*
* __buf points to a buffer that can hold at least _Locale_MAX_SIMPLE_NAME
* characters. These functions store the name, as a null-terminated
* string, in __buf. This function can't fail, at worst name is truncated.
*/
char const* _Locale_ctype_name(const struct _Locale_ctype *, char* __buf);
char const* _Locale_codecvt_name(const struct _Locale_codecvt *, char* __buf);
char const* _Locale_numeric_name(const struct _Locale_numeric *, char* __buf);
char const* _Locale_time_name(const struct _Locale_time *, char* __buf);
char const* _Locale_collate_name(const struct _Locale_collate *, char* __buf);
char const* _Locale_monetary_name(const struct _Locale_monetary *, char* __buf);
char const* _Locale_messages_name(const struct _Locale_messages *, char* __buf);
/*
* cname is a (possibly composite) locale name---i.e. a name that can
* be passed to setlocale. __buf points to an array large enough to
* store at least _Locale_MAX_SIMPLE_NAME characters, and each of these
* functions extracts the name of a single category, stores it in buf
* as a null-terminated string, and returns buf.
*/
char const* _Locale_extract_ctype_name(const char *cname, char *__buf,
struct _Locale_name_hint* __hint, int *__err_code);
char const* _Locale_extract_numeric_name(const char *cname, char *__buf,
struct _Locale_name_hint* __hint, int *__err_code);
char const* _Locale_extract_time_name(const char *cname, char *__buf,
struct _Locale_name_hint* __hint, int *__err_code);
char const* _Locale_extract_collate_name(const char *cname, char *__buf,
struct _Locale_name_hint* __hint, int *__err_code);
char const* _Locale_extract_monetary_name(const char *cname, char *__buf,
struct _Locale_name_hint* __hint, int *__err_code);
char const* _Locale_extract_messages_name(const char *cname, char *__buf,
struct _Locale_name_hint* __hint, int *__err_code);
/* Functions to improve locale creation process. For some locale API (Win32)
* you need to find a locale identification from the name which can be a
* rather expensive operation especially if you do so for all facets of a
* locale. Those functions can be used to extract from a API dependent facet
* struct the information necessary to skip this lookup process for other
* facets creation. If not supported those function should return NULL.
*/
struct _Locale_name_hint* _Locale_get_ctype_hint(struct _Locale_ctype*);
struct _Locale_name_hint* _Locale_get_numeric_hint(struct _Locale_numeric*);
struct _Locale_name_hint* _Locale_get_time_hint(struct _Locale_time*);
struct _Locale_name_hint* _Locale_get_collate_hint(struct _Locale_collate*);
struct _Locale_name_hint* _Locale_get_monetary_hint(struct _Locale_monetary*);
struct _Locale_name_hint* _Locale_get_messages_hint(struct _Locale_messages*);
/*
* FUNCTIONS THAT USE CTYPE
*/
/*
* Narrow character functions:
*/
/*
* Returns a pointer to the beginning of the ctype table. The table is
* at least 257 bytes long; if p is the pointer returned by this
* function, then p[c] is valid if c is EOF or if p is any value of
* type unsigned char.
*/
const _Locale_mask_t * _Locale_ctype_table(struct _Locale_ctype *);
/*
* c is either EOF, or an unsigned char value.
*/
int _Locale_toupper(struct _Locale_ctype *, int /* c */);
int _Locale_tolower(struct _Locale_ctype *, int /* c */);
#ifndef _STLP_NO_WCHAR_T
/*
* Wide character functions:
*/
_Locale_mask_t _WLocale_ctype(struct _Locale_ctype *, wint_t, _Locale_mask_t);
wint_t _WLocale_tolower(struct _Locale_ctype *, wint_t);
wint_t _WLocale_toupper(struct _Locale_ctype *, wint_t);
/*
* Multibyte functions:
*/
/*
* Returns the number of bytes of the longest allowed multibyte
* character in the current encoding.
*/
int _WLocale_mb_cur_max(struct _Locale_codecvt *);
/*
* Returns the number of bytes of the shortest allowed multibyte
* character in the current encoding.
*/
int _WLocale_mb_cur_min(struct _Locale_codecvt *);
/*
* Returns 1 if the current multibyte encoding is stateless
* and does not require the use of an mbstate_t value.
*/
int _WLocale_is_stateless(struct _Locale_codecvt *);
/*
* Almost identical to mbrtowc, from 4.6.5.3.2 of NA1. The only
* important difference is that mbrtowc treats null wide characters
* as special, and we don't. Specifically: examines the characters
* in [from, from + n), extracts a single wide character, and stores
* it in *to. Modifies shift_state if appropriate. The return value,
* which is always positive, is the number of characters extracted from
* the input sequence. Return value is (size_t) -1 if there was an
* encoding error in the input sequence, and (size_t) -2 if
* [from, from + n) is correct but not complete. None of the pointer
* arguments may be null pointers.
*/
size_t _WLocale_mbtowc(struct _Locale_codecvt *,
wchar_t * /* to */,
const char * /* from */, size_t /* n */,
mbstate_t *);
/*
* Again, very similar to wcrtomb. The differences are that (1) it
* doesn't treat null characters as special; and (2) it stores at most
* n characters. Converts c to a multibyte sequence, stores that
* sequence in the array 'to', and returns the length of the sequence.
* Modifies shift_state if appropriate. The return value is (size_t) -1
* if c is not a valid wide character, and (size_t) -2 if the length of
* the multibyte character sequence is greater than n.
*/
size_t _WLocale_wctomb(struct _Locale_codecvt *,
char *, size_t,
const wchar_t,
mbstate_t *);
/*
* Inserts whatever characters are necessary to restore st to an
* initial shift state. Sets *next to buf + m, where m is the number
* of characters inserted. (0 <= m <= n.) Returns m to indicate
* success, (size_t) -1 to indicate error, (size_t) -2 to indicate
* partial success (more than n characters needed). For success or partial
* success, sets *next to buf + m.
*/
size_t _WLocale_unshift(struct _Locale_codecvt *,
mbstate_t *,
char *, size_t, char **);
#endif
/*
* FUNCTIONS THAT USE COLLATE
*/
/*
* Compares the two sequences [s1, s1 + n1) and [s2, s2 + n2). Neither
* sequence is assumed to be null-terminated, and null characters
* aren't special. If the two sequences are the same up through
* min(n1, n2), then the sequence that compares less is whichever one
* is shorter.
*/
int _Locale_strcmp(struct _Locale_collate *,
const char * /* s1 */, size_t /* n1 */,
const char * /* s2 */, size_t /* n2 */);
#ifndef _STLP_NO_WCHAR_T
int _WLocale_strcmp(struct _Locale_collate *,
const wchar_t * /* s1 */, size_t /* n1 */,
const wchar_t * /* s2 */, size_t /* n2 */);
#endif
/*
* Creates a transformed version of the string [s2, s2 + n2). The
* string may contain embedded null characters; nulls aren't special.
* The transformed string begins at s1, and contains at most n1
* characters. The return value is the length of the transformed
* string. If the return value is greater than n1 then this is an
* error condition: it indicates that there wasn't enough space. In
* that case, the contents of [s1, s1 + n1) is unspecified.
*/
size_t _Locale_strxfrm(struct _Locale_collate *,
char * /* s1 */, size_t /* n1 */,
const char * /* s2 */, size_t /* n2 */);
#ifndef _STLP_NO_WCHAR_T
size_t _WLocale_strxfrm(struct _Locale_collate *,
wchar_t * /* s1 */, size_t /* n1 */,
const wchar_t * /* s2 */, size_t /* n2 */);
#endif
/*
* FUNCTIONS THAT USE NUMERIC
*/
/*
* Equivalent to the first three fields in struct lconv. (C standard,
* section 7.4.)
*/
char _Locale_decimal_point(struct _Locale_numeric *);
char _Locale_thousands_sep(struct _Locale_numeric *);
const char * _Locale_grouping(struct _Locale_numeric *);
#ifndef _STLP_NO_WCHAR_T
wchar_t _WLocale_decimal_point(struct _Locale_numeric *);
wchar_t _WLocale_thousands_sep(struct _Locale_numeric *);
#endif
/*
* Return "true" and "false" in English locales, and something
* appropriate in non-English locales.
*/
const char * _Locale_true(struct _Locale_numeric *);
const char * _Locale_false(struct _Locale_numeric *);
#ifndef _STLP_NO_WCHAR_T
const wchar_t * _WLocale_true(struct _Locale_numeric *, wchar_t* /* buf */, size_t /* bufSize */);
const wchar_t * _WLocale_false(struct _Locale_numeric *, wchar_t* /* buf */, size_t /* bufSize */);
#endif
/*
* FUNCTIONS THAT USE MONETARY
*/
/*
* Return the obvious fields of struct lconv.
*/
const char * _Locale_int_curr_symbol(struct _Locale_monetary *);
const char * _Locale_currency_symbol(struct _Locale_monetary *);
char _Locale_mon_decimal_point(struct _Locale_monetary *);
char _Locale_mon_thousands_sep(struct _Locale_monetary *);
const char * _Locale_mon_grouping(struct _Locale_monetary *);
const char * _Locale_positive_sign(struct _Locale_monetary *);
const char * _Locale_negative_sign(struct _Locale_monetary *);
char _Locale_int_frac_digits(struct _Locale_monetary *);
char _Locale_frac_digits(struct _Locale_monetary *);
int _Locale_p_cs_precedes(struct _Locale_monetary *);
int _Locale_p_sep_by_space(struct _Locale_monetary *);
int _Locale_p_sign_posn(struct _Locale_monetary *);
int _Locale_n_cs_precedes(struct _Locale_monetary *);
int _Locale_n_sep_by_space(struct _Locale_monetary *);
int _Locale_n_sign_posn(struct _Locale_monetary *);
#ifndef _STLP_NO_WCHAR_T
const wchar_t * _WLocale_int_curr_symbol(struct _Locale_monetary *, wchar_t* /* buf */, size_t /* bufSize */);
const wchar_t * _WLocale_currency_symbol(struct _Locale_monetary *, wchar_t* /* buf */, size_t /* bufSize */);
wchar_t _WLocale_mon_decimal_point(struct _Locale_monetary *);
wchar_t _WLocale_mon_thousands_sep(struct _Locale_monetary *);
const wchar_t * _WLocale_positive_sign(struct _Locale_monetary *, wchar_t* /* buf */, size_t /* bufSize */);
const wchar_t * _WLocale_negative_sign(struct _Locale_monetary *, wchar_t* /* buf */, size_t /* bufSize */);
#endif
/*
* FUNCTIONS THAT USE TIME
*/
/*
* month is in the range [0, 12).
*/
const char * _Locale_full_monthname(struct _Locale_time *, int /* month */);
const char * _Locale_abbrev_monthname(struct _Locale_time *, int /* month */);
#ifndef _STLP_NO_WCHAR_T
const wchar_t * _WLocale_full_monthname(struct _Locale_time *, int /* month */,
wchar_t* /* buf */, size_t /* bufSize */);
const wchar_t * _WLocale_abbrev_monthname(struct _Locale_time *, int /* month */,
wchar_t* /* buf */, size_t /* bufSize */);
#endif
/*
* day is in the range [0, 7). Sunday is 0.
*/
const char * _Locale_full_dayofweek(struct _Locale_time *, int /* day */);
const char * _Locale_abbrev_dayofweek(struct _Locale_time *, int /* day */);
#ifndef _STLP_NO_WCHAR_T
const wchar_t * _WLocale_full_dayofweek(struct _Locale_time *, int /* day */,
wchar_t* /* buf */, size_t /* bufSize */);
const wchar_t * _WLocale_abbrev_dayofweek(struct _Locale_time *, int /* day */,
wchar_t* /* buf */, size_t /* bufSize */);
#endif
const char * _Locale_d_t_fmt(struct _Locale_time *);
const char * _Locale_d_fmt(struct _Locale_time *);
const char * _Locale_t_fmt(struct _Locale_time *);
const char * _Locale_long_d_t_fmt(struct _Locale_time*);
const char * _Locale_long_d_fmt(struct _Locale_time*);
const char * _Locale_am_str(struct _Locale_time *);
const char * _Locale_pm_str(struct _Locale_time *);
#ifndef _STLP_NO_WCHAR_T
const wchar_t * _WLocale_am_str(struct _Locale_time *,
wchar_t* /* buf */, size_t /* bufSize */);
const wchar_t * _WLocale_pm_str(struct _Locale_time *,
wchar_t* /* buf */, size_t /* bufSize */);
#endif
/*
* FUNCTIONS THAT USE MESSAGES
*/
/*
* Very similar to catopen, except that it uses the given message
* category to determine which catalog to open.
*/
nl_catd_type _Locale_catopen(struct _Locale_messages*, const char*);
/* Complementary to _Locale_catopen.
* The catalog must be a value that was returned by a previous call
* to _Locale_catopen.
*/
void _Locale_catclose(struct _Locale_messages*, nl_catd_type);
/*
* Returns a string, identified by a set index and a message index,
* from an opened message catalog. Returns the supplied default if
* no such string exists.
*/
const char * _Locale_catgets(struct _Locale_messages *, nl_catd_type,
int, int,const char *);
#ifdef __cplusplus
}
#endif
#endif /* _STLP_C_LOCALE_IMPL_H */

Просмотреть файл

@ -1,531 +0,0 @@
/*
* Copyright (c) 1999
* Silicon Graphics Computer Systems, Inc.
*
* Copyright (c) 1999
* Boris Fomitchev
*
* This material is provided "as is", with absolutely no warranty expressed
* or implied. Any use is at your own risk.
*
* Permission to use or copy this software for any purpose is hereby granted
* without fee, provided the above notices are retained on all copies.
* Permission to modify the code and to distribute modified code is granted,
* provided the above notices are retained, and a notice that the code was
* modified is included with the above copyright notice.
*
*/
/* This is a "stub" implementation of the "c_locale.h" interface,
intended for operating systems where we have not yet written
a real implementation. A C++ library using this stub implementation
is still standard-conforming, since the C++ standard does not require
that any locales other than "C" be supported.
*/
#include <string.h>
#include <wchar.h>
#include <ctype.h>
#include <wctype.h>
#include <limits.h>
#if defined (_STLP_USE_SAFE_STRING_FUNCTIONS)
# define _STLP_STRNCPY(D, DS, S, C) strncpy_s(D, DS, S, C)
# if !defined (_STLP_NO_WCHAR_T)
# define _STLP_WCSNCPY(D, DS, S, C) wcsncpy_s(D, DS, S, C)
# endif
#else
# define _STLP_STRNCPY(D, DS, S, C) strncpy(D, S, C)
# if !defined (_STLP_NO_WCHAR_T)
# define _STLP_WCSNCPY(D, DS, S, C) wcsncpy(D, S, C)
# endif
#endif
static const char *_C_name = "C";
static const char *_empty_str = "";
#ifndef _STLP_NO_WCHAR_T
#if defined(WCHAR_MAX) && WCHAR_MAX == 255
static const wchar_t *_empty_wstr = "";
#else
static const wchar_t *_empty_wstr = L"";
#endif
#endif
static _Locale_mask_t ctable[256];
/* Framework functions */
void _Locale_init(void) {
/* Ctype table for the ASCII character set. */
char c;
/* We might never reach 128 when char is signed. */
for (c = 0; /* c != 128 */; ++c) {
if (isalpha(c)) ctable[(unsigned char)c] |= _Locale_ALPHA;
if (iscntrl(c)) ctable[(unsigned char)c] |= _Locale_CNTRL;
if (isdigit(c)) ctable[(unsigned char)c] |= _Locale_DIGIT;
if (isprint(c)) ctable[(unsigned char)c] |= _Locale_PRINT;
if (ispunct(c)) ctable[(unsigned char)c] |= _Locale_PUNCT;
if (isspace(c)) ctable[(unsigned char)c] |= _Locale_SPACE;
if (isxdigit(c)) ctable[(unsigned char)c] |= _Locale_XDIGIT;
if (isupper(c)) ctable[(unsigned char)c] |= _Locale_UPPER;
if (islower(c)) ctable[(unsigned char)c] |= _Locale_LOWER;
if (c == 127) break;
}
/* ASCII is a 7-bit code, so everything else is non-ASCII. */
memset(&(ctable[128]), 0, 128 * sizeof(_Locale_mask_t));
}
void _Locale_final(void)
{}
void* _Locale_create(const char* name, int *__err_code) {
if (name[0] == 'C' && name[1] == 0)
{ return (void*)0x1; }
*__err_code = _STLP_LOC_NO_PLATFORM_SUPPORT; return 0;
}
struct _Locale_ctype* _Locale_ctype_create(const char *name,
struct _Locale_name_hint* hint, int *__err_code)
{ return (struct _Locale_ctype*)_Locale_create(name, __err_code); }
struct _Locale_codecvt* _Locale_codecvt_create(const char *name,
struct _Locale_name_hint* hint, int *__err_code)
{ return (struct _Locale_codecvt*)_Locale_create(name, __err_code); }
struct _Locale_numeric* _Locale_numeric_create(const char *name,
struct _Locale_name_hint* hint, int *__err_code)
{ return (struct _Locale_numeric*)_Locale_create(name, __err_code); }
struct _Locale_time* _Locale_time_create(const char *name,
struct _Locale_name_hint* hint, int *__err_code)
{ return (struct _Locale_time*)_Locale_create(name, __err_code); }
struct _Locale_collate* _Locale_collate_create(const char *name,
struct _Locale_name_hint* hint, int *__err_code)
{ return (struct _Locale_collate*)_Locale_create(name, __err_code); }
struct _Locale_monetary* _Locale_monetary_create(const char *name,
struct _Locale_name_hint* hint, int *__err_code)
{ return (struct _Locale_monetary*)_Locale_create(name, __err_code); }
struct _Locale_messages* _Locale_messages_create(const char *name,
struct _Locale_name_hint* hint, int *__err_code)
{ return (struct _Locale_messages*)_Locale_create(name, __err_code); }
const char *_Locale_ctype_default(char* buf) { return _C_name; }
const char *_Locale_numeric_default(char * buf) { return _C_name; }
const char *_Locale_time_default(char* buf) { return _C_name; }
const char *_Locale_collate_default(char* buf) { return _C_name; }
const char *_Locale_monetary_default(char* buf) { return _C_name; }
const char *_Locale_messages_default(char* buf) { return _C_name; }
char const* _Locale_ctype_name(const struct _Locale_ctype *lctype, char* buf)
{ return _C_name; }
char const* _Locale_codecvt_name(const struct _Locale_codecvt *lcodecvt, char* buf)
{ return _C_name; }
char const* _Locale_numeric_name(const struct _Locale_numeric *lnum, char* buf)
{ return _C_name; }
char const* _Locale_time_name(const struct _Locale_time *ltime, char* buf)
{ return _C_name; }
char const* _Locale_collate_name(const struct _Locale_collate *lcol, char* buf)
{ return _C_name; }
char const* _Locale_monetary_name(const struct _Locale_monetary *lmon, char* buf)
{ return _C_name; }
char const* _Locale_messages_name(const struct _Locale_messages *lmes, char* buf)
{ return _C_name; }
void _Locale_ctype_destroy(struct _Locale_ctype *lctype) {}
void _Locale_codecvt_destroy(struct _Locale_codecvt *lcodecvt) {}
void _Locale_numeric_destroy(struct _Locale_numeric *lnum) {}
void _Locale_time_destroy(struct _Locale_time *ltime) {}
void _Locale_collate_destroy(struct _Locale_collate *lcol) {}
void _Locale_monetary_destroy(struct _Locale_monetary *lmon) {}
void _Locale_messages_destroy(struct _Locale_messages *lmes) {}
static char const* _Locale_extract_name(const char* name, int *__err_code) {
// When the request is the default locale or the "C" locale we answer "C".
if (name[0] == 0 ||
(name[0] == 'C' && name[1] == 0))
{ return _C_name; }
*__err_code = _STLP_LOC_NO_PLATFORM_SUPPORT; return 0;
}
char const* _Locale_extract_ctype_name(const char *name, char *buf,
struct _Locale_name_hint* hint, int *__err_code)
{ return _Locale_extract_name(name, __err_code); }
char const* _Locale_extract_numeric_name(const char *name, char *buf,
struct _Locale_name_hint* hint, int *__err_code)
{ return _Locale_extract_name(name, __err_code); }
char const* _Locale_extract_time_name(const char*name, char *buf,
struct _Locale_name_hint* hint, int *__err_code)
{ return _Locale_extract_name(name, __err_code); }
char const* _Locale_extract_collate_name(const char *name, char *buf,
struct _Locale_name_hint* hint, int *__err_code)
{ return _Locale_extract_name(name, __err_code); }
char const* _Locale_extract_monetary_name(const char *name, char *buf,
struct _Locale_name_hint* hint, int *__err_code)
{ return _Locale_extract_name(name, __err_code); }
char const* _Locale_extract_messages_name(const char *name, char *buf,
struct _Locale_name_hint* hint, int *__err_code)
{ return _Locale_extract_name(name, __err_code); }
struct _Locale_name_hint* _Locale_get_ctype_hint(struct _Locale_ctype* ctype)
{ return 0; }
struct _Locale_name_hint* _Locale_get_numeric_hint(struct _Locale_numeric* numeric)
{ return 0; }
struct _Locale_name_hint* _Locale_get_time_hint(struct _Locale_time* time)
{ return 0; }
struct _Locale_name_hint* _Locale_get_collate_hint(struct _Locale_collate* collate)
{ return 0; }
struct _Locale_name_hint* _Locale_get_monetary_hint(struct _Locale_monetary* monetary)
{ return 0; }
struct _Locale_name_hint* _Locale_get_messages_hint(struct _Locale_messages* messages)
{ return 0; }
/* ctype */
const _Locale_mask_t* _Locale_ctype_table(struct _Locale_ctype* lctype) {
_STLP_MARK_PARAMETER_AS_UNUSED(lctype)
return ctable;
}
int _Locale_toupper(struct _Locale_ctype*lctype, int c)
{ return toupper(c); }
int _Locale_tolower(struct _Locale_ctype*lctype, int c)
{ return tolower(c); }
#ifndef _STLP_NO_WCHAR_T
_Locale_mask_t _WLocale_ctype(struct _Locale_ctype *lctype, wint_t wc, _Locale_mask_t mask) {
_Locale_mask_t ret = 0;
if ((mask & _Locale_ALPHA) != 0 && iswalpha(wc))
ret |= _Locale_ALPHA;
if ((mask & _Locale_CNTRL) != 0 && iswcntrl(wc))
ret |= _Locale_CNTRL;
if ((mask & _Locale_DIGIT) != 0 && iswdigit(wc))
ret |= _Locale_DIGIT;
if ((mask & _Locale_PRINT) != 0 && iswprint(wc))
ret |= _Locale_PRINT;
if ((mask & _Locale_PUNCT) != 0 && iswpunct(wc))
ret |= _Locale_PUNCT;
if ((mask & _Locale_SPACE) != 0 && iswspace(wc))
ret |= _Locale_SPACE;
if ((mask & _Locale_XDIGIT) != 0 && iswxdigit(wc))
ret |= _Locale_XDIGIT;
if ((mask & _Locale_UPPER) != 0 && iswupper(wc))
ret |= _Locale_UPPER;
if ((mask & _Locale_LOWER) != 0 && iswlower(wc))
ret |= _Locale_LOWER;
return ret;
}
wint_t _WLocale_tolower(struct _Locale_ctype *lctype, wint_t wc)
{ return towlower(wc); }
wint_t _WLocale_toupper(struct _Locale_ctype *lctype, wint_t wc)
{ return towupper(wc); }
int _WLocale_mb_cur_max (struct _Locale_codecvt *lcodecvt) { return 1; }
int _WLocale_mb_cur_min (struct _Locale_codecvt *lcodecvt) { return 1; }
int _WLocale_is_stateless (struct _Locale_codecvt *lcodecvt) { return 1; }
size_t _WLocale_mbtowc(struct _Locale_codecvt *lcodecvt,
wchar_t *to,
const char *from, size_t n,
mbstate_t *st)
{ *to = *from; return 1; }
size_t _WLocale_wctomb(struct _Locale_codecvt *lcodecvt,
char *to, size_t n,
const wchar_t c,
mbstate_t *st)
{ *to = (char)c; return 1; }
size_t _WLocale_unshift(struct _Locale_codecvt *lcodecvt,
mbstate_t *st,
char *buf, size_t n, char ** next)
{ *next = buf; return 0; }
#endif
/* Collate */
int _Locale_strcmp(struct _Locale_collate* lcol,
const char* s1, size_t n1, const char* s2, size_t n2) {
int ret = 0;
char buf1[64], buf2[64];
while (n1 > 0 || n2 > 0) {
size_t bufsize1 = n1 < 63 ? n1 : 63;
size_t bufsize2 = n2 < 63 ? n2 : 63;
_STLP_STRNCPY(buf1, 64, s1, bufsize1); buf1[bufsize1] = 0;
_STLP_STRNCPY(buf2, 64, s2, bufsize2); buf2[bufsize2] = 0;
ret = strcmp(buf1, buf2);
if (ret != 0) return ret < 0 ? -1 : 1;
s1 += bufsize1; n1 -= bufsize1;
s2 += bufsize2; n2 -= bufsize2;
}
return ret == 0 ? 0 : (ret < 0 ? -1 : 1);
}
#ifndef _STLP_NO_WCHAR_T
int _WLocale_strcmp(struct _Locale_collate* lcol,
const wchar_t* s1, size_t n1, const wchar_t* s2, size_t n2) {
int ret = 0;
wchar_t buf1[64], buf2[64];
while (n1 > 0 || n2 > 0) {
size_t bufsize1 = n1 < 63 ? n1 : 63;
size_t bufsize2 = n2 < 63 ? n2 : 63;
_STLP_WCSNCPY(buf1, 64, s1, bufsize1); buf1[bufsize1] = 0;
_STLP_WCSNCPY(buf2, 64, s2, bufsize2); buf2[bufsize2] = 0;
ret = wcscmp(buf1, buf2);
if (ret != 0) return ret < 0 ? -1 : 1;
s1 += bufsize1; n1 -= bufsize1;
s2 += bufsize2; n2 -= bufsize2;
}
return ret == 0 ? 0 : (ret < 0 ? -1 : 1);
}
#endif
size_t _Locale_strxfrm(struct _Locale_collate* lcol,
char* dest, size_t dest_n,
const char* src, size_t src_n) {
if (dest != 0) {
_STLP_STRNCPY(dest, dest_n, src, dest_n - 1); dest[dest_n - 1] = 0;
}
return src_n;
}
#ifndef _STLP_NO_WCHAR_T
size_t _WLocale_strxfrm(struct _Locale_collate* lcol,
wchar_t* dest, size_t dest_n,
const wchar_t* src, size_t src_n) {
if (dest != 0) {
_STLP_WCSNCPY(dest, dest_n, src, dest_n - 1); dest[dest_n - 1] = 0;
}
return src_n;
}
#endif
/* Numeric */
char _Locale_decimal_point(struct _Locale_numeric* lnum)
{ return '.'; }
char _Locale_thousands_sep(struct _Locale_numeric* lnum)
{ return ','; }
const char* _Locale_grouping(struct _Locale_numeric * lnum)
{ return _empty_str; }
const char * _Locale_true(struct _Locale_numeric * lnum)
{ return "true"; }
const char * _Locale_false(struct _Locale_numeric * lnum)
{ return "false"; }
#ifndef _STLP_NO_WCHAR_T
wchar_t _WLocale_decimal_point(struct _Locale_numeric* lnum)
{ return L'.'; }
wchar_t _WLocale_thousands_sep(struct _Locale_numeric* lnum)
{ return L','; }
#if defined(WCHAR_MAX) && WCHAR_MAX == 255
const wchar_t * _WLocale_true(struct _Locale_numeric* lnum, wchar_t* buf, size_t bufSize)
{ return "true"; }
const wchar_t * _WLocale_false(struct _Locale_numeric* lnum, wchar_t* buf, size_t bufSize)
{ return "false"; }
#else
const wchar_t * _WLocale_true(struct _Locale_numeric* lnum, wchar_t* buf, size_t bufSize)
{ return L"true"; }
const wchar_t * _WLocale_false(struct _Locale_numeric* lnum, wchar_t* buf, size_t bufSize)
{ return L"false"; }
#endif
#endif
/* Monetary */
const char* _Locale_int_curr_symbol(struct _Locale_monetary * lmon)
{ return _empty_str; }
const char* _Locale_currency_symbol(struct _Locale_monetary * lmon)
{ return _empty_str; }
char _Locale_mon_decimal_point(struct _Locale_monetary * lmon)
{ return '.'; }
char _Locale_mon_thousands_sep(struct _Locale_monetary * lmon)
{ return ','; }
const char* _Locale_mon_grouping(struct _Locale_monetary * lmon)
{ return _empty_str; }
const char* _Locale_positive_sign(struct _Locale_monetary * lmon)
{ return _empty_str; }
const char* _Locale_negative_sign(struct _Locale_monetary * lmon)
{ return _empty_str; }
char _Locale_int_frac_digits(struct _Locale_monetary * lmon)
{ return 0; }
char _Locale_frac_digits(struct _Locale_monetary * lmon)
{ return 0; }
int _Locale_p_cs_precedes(struct _Locale_monetary * lmon)
{ return CHAR_MAX; }
int _Locale_p_sep_by_space(struct _Locale_monetary * lmon)
{ return CHAR_MAX; }
int _Locale_p_sign_posn(struct _Locale_monetary * lmon)
{ return CHAR_MAX; }
int _Locale_n_cs_precedes(struct _Locale_monetary * lmon)
{ return CHAR_MAX; }
int _Locale_n_sep_by_space(struct _Locale_monetary * lmon)
{ return CHAR_MAX; }
int _Locale_n_sign_posn(struct _Locale_monetary * lmon)
{ return CHAR_MAX; }
#ifndef _STLP_NO_WCHAR_T
const wchar_t* _WLocale_int_curr_symbol(struct _Locale_monetary * lmon,
wchar_t* buf, size_t bufSize)
{ return _empty_wstr; }
const wchar_t* _WLocale_currency_symbol(struct _Locale_monetary * lmon,
wchar_t* buf, size_t bufSize)
{ return _empty_wstr; }
wchar_t _WLocale_mon_decimal_point(struct _Locale_monetary * lmon)
{ return L'.'; }
wchar_t _WLocale_mon_thousands_sep(struct _Locale_monetary * lmon)
{ return L','; }
const wchar_t* _WLocale_positive_sign(struct _Locale_monetary * lmon,
wchar_t* buf, size_t bufSize)
{ return _empty_wstr; }
const wchar_t* _WLocale_negative_sign(struct _Locale_monetary * lmon,
wchar_t* buf, size_t bufSize)
{ return _empty_wstr; }
#endif
/* Time */
static const char* full_monthname[] =
{ "January", "February", "March", "April", "May", "June",
"July", "August", "September", "October", "November", "December" };
const char * _Locale_full_monthname(struct _Locale_time * ltime, int n)
{ return full_monthname[n]; }
static const char* abbrev_monthname[] =
{ "Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };
const char * _Locale_abbrev_monthname(struct _Locale_time * ltime, int n)
{ return abbrev_monthname[n]; }
static const char* full_dayname[] =
{ "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" };
const char * _Locale_full_dayofweek(struct _Locale_time * ltime, int n)
{ return full_dayname[n]; }
static const char* abbrev_dayname[] =
{ "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" };
const char * _Locale_abbrev_dayofweek(struct _Locale_time * ltime, int n)
{ return abbrev_dayname[n]; }
const char* _Locale_d_t_fmt(struct _Locale_time* ltime)
{ return "%m/%d/%y"; }
const char* _Locale_d_fmt(struct _Locale_time* ltime)
{ return "%m/%d/%y"; }
const char* _Locale_t_fmt(struct _Locale_time* ltime)
{ return "%H:%M:%S"; }
const char* _Locale_long_d_t_fmt(struct _Locale_time* ltime)
{ return _empty_str; }
const char* _Locale_long_d_fmt(struct _Locale_time* ltime)
{ return _empty_str; }
const char* _Locale_am_str(struct _Locale_time* ltime)
{ return "AM"; }
const char* _Locale_pm_str(struct _Locale_time* ltime)
{ return "PM"; }
#ifndef _STLP_NO_WCHAR_T
#if defined(WCHAR_MAX) && WCHAR_MAX == 255
static const wchar_t* full_wmonthname[] =
{ "January", "February", "March", "April", "May", "June",
"July", "August", "September", "October", "November", "December" };
const wchar_t * _WLocale_full_monthname(struct _Locale_time * ltime, int n,
wchar_t* buf, size_t bufSize)
{ return full_wmonthname[n]; }
static const wchar_t* abbrev_wmonthname[] =
{ "Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };
const wchar_t * _WLocale_abbrev_monthname(struct _Locale_time * ltime, int n,
wchar_t* buf, size_t bufSize)
{ return abbrev_wmonthname[n]; }
static const wchar_t* full_wdayname[] =
{ "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" };
const wchar_t * _WLocale_full_dayofweek(struct _Locale_time * ltime, int n,
wchar_t* buf, size_t bufSize)
{ return full_wdayname[n]; }
static const wchar_t* abbrev_wdayname[] =
{ "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" };
const wchar_t * _WLocale_abbrev_dayofweek(struct _Locale_time * ltime, int n,
wchar_t* buf, size_t bufSize)
{ return abbrev_wdayname[n]; }
const wchar_t* _WLocale_am_str(struct _Locale_time* ltime,
wchar_t* buf, size_t bufSize)
{ return "AM"; }
const wchar_t* _WLocale_pm_str(struct _Locale_time* ltime,
wchar_t* buf, size_t bufSize)
{ return "PM"; }
#else /* WCHAR_MAX != 255 */
static const wchar_t* full_wmonthname[] =
{ L"January", L"February", L"March", L"April", L"May", L"June",
L"July", L"August", L"September", L"October", L"November", L"December" };
const wchar_t * _WLocale_full_monthname(struct _Locale_time * ltime, int n,
wchar_t* buf, size_t bufSize)
{ return full_wmonthname[n]; }
static const wchar_t* abbrev_wmonthname[] =
{ L"Jan", L"Feb", L"Mar", L"Apr", L"May", L"Jun",
L"Jul", L"Aug", L"Sep", L"Oct", L"Nov", L"Dec" };
const wchar_t * _WLocale_abbrev_monthname(struct _Locale_time * ltime, int n,
wchar_t* buf, size_t bufSize)
{ return abbrev_wmonthname[n]; }
static const wchar_t* full_wdayname[] =
{ L"Sunday", L"Monday", L"Tuesday", L"Wednesday", L"Thursday", L"Friday", L"Saturday" };
const wchar_t * _WLocale_full_dayofweek(struct _Locale_time * ltime, int n,
wchar_t* buf, size_t bufSize)
{ return full_wdayname[n]; }
static const wchar_t* abbrev_wdayname[] =
{ L"Sun", L"Mon", L"Tue", L"Wed", L"Thu", L"Fri", L"Sat" };
const wchar_t * _WLocale_abbrev_dayofweek(struct _Locale_time * ltime, int n,
wchar_t* buf, size_t bufSize)
{ return abbrev_wdayname[n]; }
const wchar_t* _WLocale_am_str(struct _Locale_time* ltime,
wchar_t* buf, size_t bufSize)
{ return L"AM"; }
const wchar_t* _WLocale_pm_str(struct _Locale_time* ltime,
wchar_t* buf, size_t bufSize)
{ return L"PM"; }
#endif /* WCHAR_MAX != 255 */
#endif
/* Messages */
nl_catd_type _Locale_catopen(struct _Locale_messages* lmes, const char* name)
{ return -1; }
void _Locale_catclose(struct _Locale_messages* lmes, nl_catd_type cat) {}
const char* _Locale_catgets(struct _Locale_messages* lmes, nl_catd_type cat,
int setid, int msgid, const char *dfault)
{ return dfault; }

Просмотреть файл

@ -1,705 +0,0 @@
#include <locale.h>
#include <langinfo.h>
#include <stdio.h>
#include <stdlib.h>
#include <wctype.h>
#include <string.h>
#include <stdint.h>
static const char *_empty_str = "";
static const char *_C_name = "C";
static wchar_t* _ToWChar(const char* buf, wchar_t *wbuf, size_t wbufSize) {
wchar_t *wcur = wbuf;
wchar_t *wend = wbuf + wbufSize - 1;
for (; wcur != wend && *buf != 0; ++buf, ++wcur)
*wcur = *buf;
*wcur = 0;
return wbuf;
}
#if 0
struct _Locale_ctype
{
locale_t __cloc;
};
struct _Locale_numeric
{
locale_t __cloc;
};
struct _Locale_time
{
locale_t __cloc;
};
struct _Locale_collate
{
locale_t __cloc;
};
struct _Locale_monetary
{
locale_t __cloc;
};
struct _Locale_messages
{
locale_t __cloc;
};
#endif
void _Locale_init()
{}
void _Locale_final()
{}
struct _Locale_ctype *_Locale_ctype_create(const char *nm, struct _Locale_name_hint* hint,
int *__err_code) {
*__err_code = _STLP_LOC_UNKNOWN_NAME;
return (struct _Locale_ctype*)newlocale(LC_CTYPE_MASK, nm, NULL);
}
struct _Locale_codecvt *_Locale_codecvt_create(const char *nm, struct _Locale_name_hint* hint,
int *__err_code) {
// Glibc do not support multibyte manipulation for the moment, it simply implements "C".
if (nm[0] == 'C' && nm[1] == 0)
{ return (struct _Locale_codecvt*)0x01; }
*__err_code = _STLP_LOC_NO_PLATFORM_SUPPORT; return 0;
}
struct _Locale_numeric *_Locale_numeric_create(const char *nm, struct _Locale_name_hint* hint,
int *__err_code) {
*__err_code = _STLP_LOC_UNKNOWN_NAME;
return (struct _Locale_numeric*)newlocale(LC_NUMERIC_MASK, nm, NULL);
}
struct _Locale_time *_Locale_time_create(const char *nm, struct _Locale_name_hint* hint,
int *__err_code) {
*__err_code = _STLP_LOC_UNKNOWN_NAME;
return (struct _Locale_time*)newlocale(LC_TIME_MASK, nm, NULL);
}
struct _Locale_collate *_Locale_collate_create(const char *nm, struct _Locale_name_hint* hint,
int *__err_code) {
*__err_code = _STLP_LOC_UNKNOWN_NAME;
return (struct _Locale_collate*)newlocale(LC_COLLATE_MASK, nm, NULL);
}
struct _Locale_monetary *_Locale_monetary_create(const char *nm, struct _Locale_name_hint* hint,
int *__err_code) {
*__err_code = _STLP_LOC_UNKNOWN_NAME;
return (struct _Locale_monetary*)newlocale(LC_MONETARY_MASK, nm, NULL);
}
struct _Locale_messages *_Locale_messages_create(const char *nm, struct _Locale_name_hint* hint,
int *__err_code) {
*__err_code = _STLP_LOC_UNKNOWN_NAME;
return (struct _Locale_messages*)newlocale(LC_MESSAGES_MASK, nm, NULL);
}
/*
try to see locale category LC should be used from environment;
according POSIX, the order is
1. LC_ALL
2. category (LC_CTYPE, LC_NUMERIC, ... )
3. LANG
If set nothing, return "C" (this really implementation-specific).
*/
static const char *_Locale_aux_default( const char *LC, char *nm )
{
char *name = getenv( "LC_ALL" );
if ( name != NULL && *name != 0 ) {
return name;
}
name = getenv( LC );
if ( name != NULL && *name != 0 ) {
return name;
}
name = getenv( "LANG" );
if ( name != NULL && *name != 0 ) {
return name;
}
return _C_name;
}
const char *_Locale_ctype_default( char *nm )
{
return _Locale_aux_default( "LC_CTYPE", nm );
}
const char *_Locale_numeric_default( char *nm )
{
return _Locale_aux_default( "LC_NUMERIC", nm );
}
const char *_Locale_time_default( char *nm )
{
return _Locale_aux_default( "LC_TIME", nm );
}
const char *_Locale_collate_default( char *nm )
{
return _Locale_aux_default( "LC_COLLATE", nm );
}
const char *_Locale_monetary_default( char *nm )
{
return _Locale_aux_default( "LC_MONETARY", nm );
}
const char *_Locale_messages_default( char *nm )
{
return _Locale_aux_default( "LC_MESSAGES", nm );
}
char const*_Locale_ctype_name( const struct _Locale_ctype *__loc, char *buf )
{
return ((locale_t)__loc)->__names[LC_CTYPE];
}
char const*_Locale_codecvt_name( const struct _Locale_codecvt *__loc, char *buf )
{
return _C_name;
}
char const*_Locale_numeric_name( const struct _Locale_numeric *__loc, char *buf )
{
return ((locale_t)__loc)->__names[LC_NUMERIC];
}
char const*_Locale_time_name( const struct _Locale_time *__loc, char *buf )
{
return ((locale_t)__loc)->__names[LC_TIME];
}
char const*_Locale_collate_name( const struct _Locale_collate *__loc, char *buf )
{
return ((locale_t)__loc)->__names[LC_COLLATE];
}
char const*_Locale_monetary_name( const struct _Locale_monetary *__loc, char *buf )
{
return ((locale_t)__loc)->__names[LC_MONETARY];
}
char const*_Locale_messages_name( const struct _Locale_messages *__loc, char *buf )
{
return ((locale_t)__loc)->__names[LC_MESSAGES];
}
void _Locale_ctype_destroy( struct _Locale_ctype *__loc )
{ freelocale((locale_t)__loc); }
void _Locale_codecvt_destroy( struct _Locale_codecvt *__loc )
{}
void _Locale_numeric_destroy( struct _Locale_numeric *__loc )
{ freelocale((locale_t)__loc); }
void _Locale_time_destroy( struct _Locale_time *__loc )
{ freelocale((locale_t)__loc); }
void _Locale_collate_destroy( struct _Locale_collate *__loc )
{ freelocale((locale_t)__loc); }
void _Locale_monetary_destroy( struct _Locale_monetary *__loc )
{ freelocale((locale_t)__loc); }
void _Locale_messages_destroy( struct _Locale_messages* __loc )
{ freelocale((locale_t)__loc); }
/*
* locale loc expected either locale name indeed (platform-specific)
* or string like "LC_CTYPE=LocaleNameForCType;LC_NUMERIC=LocaleNameForNum;"
*
*/
static char const*__Extract_locale_name( const char *loc, const char *category, char *buf )
{
char *expr;
size_t len_name;
if( loc[0]=='L' && loc[1]=='C' && loc[2]=='_') {
expr = strstr( (char*)loc, category );
if ( expr == NULL )
return NULL; /* Category not found. */
++expr;
len_name = strcspn( expr, ";" );
len_name = len_name >= _Locale_MAX_SIMPLE_NAME ? _Locale_MAX_SIMPLE_NAME - 1 : len_name;
strncpy( buf, expr, len_name );
buf[len_name] = 0;
return buf;
}
return loc;
}
char const*_Locale_extract_ctype_name(const char *loc, char *buf,
struct _Locale_name_hint* hint, int *__err_code)
{ return __Extract_locale_name( loc, "LC_CTYPE=", buf ); }
char const*_Locale_extract_numeric_name(const char *loc, char *buf,
struct _Locale_name_hint* hint, int *__err_code)
{ return __Extract_locale_name( loc, "LC_NUMERIC=", buf ); }
char const*_Locale_extract_time_name(const char *loc, char *buf,
struct _Locale_name_hint* hint, int *__err_code)
{ return __Extract_locale_name( loc, "LC_TIME=", buf ); }
char const*_Locale_extract_collate_name(const char *loc, char *buf,
struct _Locale_name_hint* hint, int *__err_code)
{ return __Extract_locale_name( loc, "LC_COLLATE=", buf ); }
char const*_Locale_extract_monetary_name(const char *loc, char *buf,
struct _Locale_name_hint* hint, int *__err_code)
{ return __Extract_locale_name( loc, "LC_MONETARY=", buf ); }
char const*_Locale_extract_messages_name(const char *loc, char *buf,
struct _Locale_name_hint* hint, int *__err_code)
{ return __Extract_locale_name( loc, "LC_MESSAGES=", buf ); }
struct _Locale_name_hint* _Locale_get_ctype_hint(struct _Locale_ctype* ctype)
{ return 0; }
struct _Locale_name_hint* _Locale_get_numeric_hint(struct _Locale_numeric* numeric)
{ return 0; }
struct _Locale_name_hint* _Locale_get_time_hint(struct _Locale_time* time)
{ return 0; }
struct _Locale_name_hint* _Locale_get_collate_hint(struct _Locale_collate* collate)
{ return 0; }
struct _Locale_name_hint* _Locale_get_monetary_hint(struct _Locale_monetary* monetary)
{ return 0; }
struct _Locale_name_hint* _Locale_get_messages_hint(struct _Locale_messages* messages)
{ return 0; }
/* ctype */
const _Locale_mask_t *_Locale_ctype_table( struct _Locale_ctype *__loc )
{
/* return table with masks (upper, lower, alpha, etc.) */
_STLP_STATIC_ASSERT( sizeof(_Locale_mask_t) == sizeof(((locale_t)__loc)->__ctype_b[0]) )
return ((locale_t)__loc)->__ctype_b;
}
int _Locale_toupper( struct _Locale_ctype *__loc, int c )
{ return ((locale_t)__loc)->__ctype_toupper[c]; }
int _Locale_tolower( struct _Locale_ctype *__loc, int c )
{ return ((locale_t)__loc)->__ctype_tolower[c]; }
#if !defined (_STLP_NO_WCHAR_T)
_Locale_mask_t _WLocale_ctype( struct _Locale_ctype *__loc, wint_t wc, _Locale_mask_t __mask )
{
_Locale_mask_t ret = 0;
if ((__mask & _Locale_ALPHA) != 0 && iswalpha_l(wc, (locale_t)__loc))
ret |= _Locale_ALPHA;
if ((__mask & _Locale_CNTRL) != 0 && iswcntrl_l(wc, (locale_t)__loc))
ret |= _Locale_CNTRL;
if ((__mask & _Locale_DIGIT) != 0 && iswdigit_l(wc, (locale_t)__loc))
ret |= _Locale_DIGIT;
if ((__mask & _Locale_PRINT) != 0 && iswprint_l(wc, (locale_t)__loc))
ret |= _Locale_PRINT;
if ((__mask & _Locale_PUNCT) != 0 && iswpunct_l(wc, (locale_t)__loc))
ret |= _Locale_PUNCT;
if ((__mask & _Locale_SPACE) != 0 && iswspace_l(wc, (locale_t)__loc))
ret |= _Locale_SPACE;
if ((__mask & _Locale_XDIGIT) != 0 && iswxdigit_l(wc, (locale_t)__loc))
ret |= _Locale_XDIGIT;
if ((__mask & _Locale_UPPER) != 0 && iswupper_l(wc, (locale_t)__loc))
ret |= _Locale_UPPER;
if ((__mask & _Locale_LOWER) != 0 && iswlower_l(wc, (locale_t)__loc))
ret |= _Locale_LOWER;
return ret;
}
wint_t _WLocale_tolower( struct _Locale_ctype *__loc, wint_t c )
{
return towlower_l( c, ((locale_t)__loc) );
}
wint_t _WLocale_toupper( struct _Locale_ctype *__loc, wint_t c )
{
return towupper_l( c, ((locale_t)__loc) );
}
#endif
int _WLocale_mb_cur_max( struct _Locale_codecvt * lcodecvt) { return 1; }
int _WLocale_mb_cur_min( struct _Locale_codecvt * lcodecvt) { return 1; }
int _WLocale_is_stateless( struct _Locale_codecvt * lcodecvt) { return 1; }
#if !defined (_STLP_NO_WCHAR_T)
size_t _WLocale_mbtowc(struct _Locale_codecvt *lcodecvt,
wchar_t *to,
const char *from, size_t n,
mbstate_t *st)
{ *to = *from; return 1; }
size_t _WLocale_wctomb(struct _Locale_codecvt *lcodecvt,
char *to, size_t n,
const wchar_t c,
mbstate_t *st)
{ *to = (char)c; return 1; }
#endif
size_t _WLocale_unshift(struct _Locale_codecvt *lcodecvt,
mbstate_t *st,
char *buf, size_t n, char ** next)
{ *next = buf; return 0; }
/* Collate */
int _Locale_strcmp(struct _Locale_collate * __loc,
const char *s1, size_t n1,
const char *s2, size_t n2) {
int ret = 0;
char buf1[64], buf2[64];
while (n1 > 0 || n2 > 0) {
size_t bufsize1 = n1 < 63 ? n1 : 63;
size_t bufsize2 = n2 < 63 ? n2 : 63;
strncpy(buf1, s1, bufsize1); buf1[bufsize1] = 0;
strncpy(buf2, s2, bufsize2); buf2[bufsize2] = 0;
ret = strcoll_l(buf1, buf2, (locale_t)__loc);
if (ret != 0) return ret;
s1 += bufsize1; n1 -= bufsize1;
s2 += bufsize2; n2 -= bufsize2;
}
return ret;
}
#if !defined (_STLP_NO_WCHAR_T)
int _WLocale_strcmp(struct _Locale_collate *__loc,
const wchar_t *s1, size_t n1,
const wchar_t *s2, size_t n2) {
int ret = 0;
wchar_t buf1[64], buf2[64];
while (n1 > 0 || n2 > 0) {
size_t bufsize1 = n1 < 63 ? n1 : 63;
size_t bufsize2 = n2 < 63 ? n2 : 63;
wcsncpy(buf1, s1, bufsize1); buf1[bufsize1] = 0;
wcsncpy(buf2, s2, bufsize2); buf2[bufsize2] = 0;
ret = wcscoll_l(buf1, buf2, (locale_t)__loc);
if (ret != 0) return ret;
s1 += bufsize1; n1 -= bufsize1;
s2 += bufsize2; n2 -= bufsize2;
}
return ret;
}
#endif
size_t _Locale_strxfrm(struct _Locale_collate *__loc,
char *dest, size_t dest_n,
const char *src, size_t src_n )
{
const char *real_src;
char *buf = NULL;
size_t result;
if (src_n == 0)
{
if (dest != NULL) dest[0] = 0;
return 0;
}
if (src[src_n] != 0) {
buf = malloc(src_n + 1);
strncpy(buf, src, src_n);
buf[src_n] = 0;
real_src = buf;
}
else
real_src = src;
result = strxfrm_l(dest, real_src, dest_n, (locale_t)__loc);
if (buf != NULL) free(buf);
return result;
}
# ifndef _STLP_NO_WCHAR_T
size_t _WLocale_strxfrm( struct _Locale_collate *__loc,
wchar_t *dest, size_t dest_n,
const wchar_t *src, size_t src_n )
{
const wchar_t *real_src;
wchar_t *buf = NULL;
size_t result;
if (src_n == 0)
{
if (dest != NULL) dest[0] = 0;
return 0;
}
if (src[src_n] != 0) {
buf = malloc((src_n + 1) * sizeof(wchar_t));
wcsncpy(buf, src, src_n);
buf[src_n] = 0;
real_src = buf;
}
else
real_src = src;
result = wcsxfrm_l(dest, real_src, dest_n, (locale_t)__loc);
if (buf != NULL) free(buf);
return result;
}
# endif
/* Numeric */
char _Locale_decimal_point(struct _Locale_numeric *__loc)
{
return *(nl_langinfo_l(RADIXCHAR, (locale_t)__loc));
}
char _Locale_thousands_sep(struct _Locale_numeric *__loc)
{
return *(nl_langinfo_l(THOUSEP, (locale_t)__loc));
}
const char* _Locale_grouping(struct _Locale_numeric *__loc)
{
return (_Locale_thousands_sep(__loc) != 0 ) ? (nl_langinfo_l(GROUPING, (locale_t)__loc)) : _empty_str;
}
const char *_Locale_true(struct _Locale_numeric *__loc)
{
return nl_langinfo_l(YESSTR, (locale_t)__loc);
}
const char *_Locale_false(struct _Locale_numeric *__loc)
{
return nl_langinfo_l(NOSTR, (locale_t)__loc);
}
#ifndef _STLP_NO_WCHAR_T
wchar_t _WLocale_decimal_point(struct _Locale_numeric *__loc)
{ return (wchar_t)_Locale_decimal_point(__loc); }
wchar_t _WLocale_thousands_sep(struct _Locale_numeric *__loc)
{ return (wchar_t)_Locale_thousands_sep(__loc); }
const wchar_t *_WLocale_true(struct _Locale_numeric *__loc, wchar_t *buf, size_t bufSize)
{ return _ToWChar(_Locale_true(__loc), buf, bufSize); }
const wchar_t *_WLocale_false(struct _Locale_numeric *__loc, wchar_t *buf, size_t bufSize)
{ return _ToWChar(_Locale_false(__loc), buf, bufSize); }
#endif
/* Monetary */
const char *_Locale_int_curr_symbol(struct _Locale_monetary *__loc)
{
return nl_langinfo_l(INT_CURR_SYMBOL, (locale_t)__loc);
}
const char *_Locale_currency_symbol(struct _Locale_monetary *__loc)
{
return nl_langinfo_l(CURRENCY_SYMBOL, (locale_t)__loc);
}
char _Locale_mon_decimal_point(struct _Locale_monetary * __loc)
{
return *(nl_langinfo_l(MON_DECIMAL_POINT,(locale_t)__loc));
}
char _Locale_mon_thousands_sep(struct _Locale_monetary *__loc)
{
return *(nl_langinfo_l(MON_THOUSANDS_SEP, (locale_t)__loc));
}
#ifndef _STLP_NO_WCHAR_T
const wchar_t *_WLocale_int_curr_symbol(struct _Locale_monetary *__loc, wchar_t *buf, size_t bufSize)
{ return _ToWChar(_Locale_int_curr_symbol(__loc), buf, bufSize); }
const wchar_t *_WLocale_currency_symbol(struct _Locale_monetary *__loc, wchar_t *buf, size_t bufSize)
{ return _ToWChar(_Locale_currency_symbol(__loc), buf, bufSize); }
wchar_t _WLocale_mon_decimal_point(struct _Locale_monetary * __loc)
{ return (wchar_t)_Locale_mon_decimal_point(__loc); }
wchar_t _WLocale_mon_thousands_sep(struct _Locale_monetary * __loc)
{ return (wchar_t)_Locale_mon_thousands_sep(__loc); }
const wchar_t *_WLocale_positive_sign(struct _Locale_monetary *__loc, wchar_t *buf, size_t bufSize)
{ return _ToWChar(_Locale_positive_sign(__loc), buf, bufSize); }
const wchar_t *_WLocale_negative_sign(struct _Locale_monetary *__loc, wchar_t *buf, size_t bufSize)
{ return _ToWChar(_Locale_negative_sign(__loc), buf, bufSize); }
#endif
const char *_Locale_mon_grouping(struct _Locale_monetary *__loc)
{
return (_Locale_mon_thousands_sep( __loc ) != 0 ) ? nl_langinfo_l(MON_GROUPING, (locale_t)__loc) : _empty_str;
}
const char *_Locale_positive_sign(struct _Locale_monetary *__loc)
{
return nl_langinfo_l(POSITIVE_SIGN, (locale_t)__loc);
}
const char *_Locale_negative_sign(struct _Locale_monetary *__loc)
{
return nl_langinfo_l(NEGATIVE_SIGN, (locale_t)__loc);
}
char _Locale_int_frac_digits(struct _Locale_monetary *__loc)
{
/* We are forced to manually handled the "C" locale for consistency with
* the default implementation in STLport. */
const char* lname = ((locale_t)__loc)->__names[LC_MONETARY];
if (lname[0] == 'C' && lname[1] == 0)
return 0;
return *(nl_langinfo_l(INT_FRAC_DIGITS, (locale_t)__loc));
}
char _Locale_frac_digits(struct _Locale_monetary *__loc)
{
/* We are forced to manually handled the "C" locale for consistency with
* the default implementation in STLport. */
const char* lname = ((locale_t)__loc)->__names[LC_MONETARY];
if (lname[0] == 'C' && lname[1] == 0)
return 0;
return *(nl_langinfo_l(FRAC_DIGITS, (locale_t)__loc));
}
/* 1 if currency_symbol precedes a positive value, 0 if succeeds */
int _Locale_p_cs_precedes(struct _Locale_monetary *__loc)
{
return *(nl_langinfo_l(P_CS_PRECEDES, (locale_t)__loc));
}
/* 1 if a space separates currency_symbol from a positive value. */
int _Locale_p_sep_by_space(struct _Locale_monetary *__loc)
{
return *(nl_langinfo_l(P_SEP_BY_SPACE, (locale_t)__loc));
}
/*
* 0 Parentheses surround the quantity and currency_symbol
* 1 The sign string precedes the quantity and currency_symbol
* 2 The sign string succeeds the quantity and currency_symbol.
* 3 The sign string immediately precedes the currency_symbol.
* 4 The sign string immediately succeeds the currency_symbol.
*/
int _Locale_p_sign_posn(struct _Locale_monetary *__loc)
{
return *(nl_langinfo_l(P_SIGN_POSN, (locale_t)__loc));
}
/* 1 if currency_symbol precedes a negative value, 0 if succeeds */
int _Locale_n_cs_precedes(struct _Locale_monetary *__loc)
{
return *(nl_langinfo_l(N_CS_PRECEDES, (locale_t)__loc));
}
/* 1 if a space separates currency_symbol from a negative value. */
int _Locale_n_sep_by_space(struct _Locale_monetary *__loc)
{
return *(nl_langinfo_l(N_SEP_BY_SPACE, (locale_t)__loc));
}
/*
* 0 Parentheses surround the quantity and currency_symbol
* 1 The sign string precedes the quantity and currency_symbol
* 2 The sign string succeeds the quantity and currency_symbol.
* 3 The sign string immediately precedes the currency_symbol.
* 4 The sign string immediately succeeds the currency_symbol.
*/
int _Locale_n_sign_posn(struct _Locale_monetary *__loc)
{
return *(nl_langinfo_l(N_SIGN_POSN, (locale_t)__loc));
}
/* Time */
const char *_Locale_full_monthname(struct _Locale_time *__loc, int _m )
{
return nl_langinfo_l(MON_1 + _m, (locale_t)__loc);
}
const char *_Locale_abbrev_monthname(struct _Locale_time *__loc, int _m )
{
return nl_langinfo_l(ABMON_1 + _m, (locale_t)__loc);
}
const char *_Locale_full_dayofweek(struct _Locale_time *__loc, int _d )
{
return nl_langinfo_l(DAY_1 + _d, (locale_t)__loc);
}
const char *_Locale_abbrev_dayofweek(struct _Locale_time *__loc, int _d )
{
return nl_langinfo_l(ABDAY_1 + _d, (locale_t)__loc);
}
const char *_Locale_d_t_fmt(struct _Locale_time *__loc)
{
return nl_langinfo_l(D_T_FMT, (locale_t)__loc);
}
const char *_Locale_d_fmt(struct _Locale_time *__loc )
{
return nl_langinfo_l(D_FMT, (locale_t)__loc);
}
const char *_Locale_t_fmt(struct _Locale_time *__loc )
{
return nl_langinfo_l(T_FMT, (locale_t)__loc);
}
const char *_Locale_long_d_t_fmt(struct _Locale_time *__loc )
{
return nl_langinfo_l(ERA_D_T_FMT, (locale_t)__loc);
}
const char *_Locale_long_d_fmt(struct _Locale_time *__loc )
{
return nl_langinfo_l(ERA_D_FMT, (locale_t)__loc);
}
const char *_Locale_am_str(struct _Locale_time *__loc )
{
return nl_langinfo_l(AM_STR, (locale_t)__loc);
}
const char *_Locale_pm_str(struct _Locale_time* __loc )
{
return nl_langinfo_l(PM_STR, (locale_t)__loc);
}
#ifndef _STLP_NO_WCHAR_T
const wchar_t *_WLocale_full_monthname(struct _Locale_time *__loc, int _m, wchar_t *buf, size_t bufSize)
{ return _ToWChar(_Locale_full_monthname(__loc, _m), buf, bufSize); }
const wchar_t *_WLocale_abbrev_monthname(struct _Locale_time *__loc, int _m, wchar_t *buf, size_t bufSize)
{ return _ToWChar(_Locale_abbrev_monthname(__loc, _m), buf, bufSize); }
const wchar_t *_WLocale_full_dayofweek(struct _Locale_time *__loc, int _d, wchar_t *buf, size_t bufSize)
{ return _ToWChar(_Locale_full_dayofweek(__loc, _d), buf, bufSize); }
const wchar_t *_WLocale_abbrev_dayofweek(struct _Locale_time *__loc, int _d, wchar_t *buf, size_t bufSize)
{ return _ToWChar(_Locale_abbrev_dayofweek(__loc, _d), buf, bufSize); }
const wchar_t *_WLocale_am_str(struct _Locale_time *__loc, wchar_t *buf, size_t bufSize)
{ return _ToWChar(_Locale_am_str(__loc), buf, bufSize); }
const wchar_t *_WLocale_pm_str(struct _Locale_time* __loc, wchar_t *buf, size_t bufSize)
{ return _ToWChar(_Locale_pm_str(__loc), buf, bufSize); }
#endif
/* Messages */
nl_catd_type _Locale_catopen(struct _Locale_messages *__loc, const char *__cat_name )
{
return catopen( __cat_name, NL_CAT_LOCALE );
}
void _Locale_catclose(struct _Locale_messages *__loc, nl_catd_type __cat )
{
catclose( __cat );
}
const char *_Locale_catgets(struct _Locale_messages *__loc, nl_catd_type __cat,
int __setid, int __msgid, const char *dfault)
{
return catgets( __cat, __setid, __msgid, dfault );
}

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -1,314 +0,0 @@
/*
* Copyright (c) 2007 2008
* Francois Dumont
*
* This material is provided "as is", with absolutely no warranty expressed
* or implied. Any use is at your own risk.
*
* Permission to use or copy this software for any purpose is hereby granted
* without fee, provided the above notices are retained on all copies.
* Permission to modify the code and to distribute modified code is granted,
* provided the above notices are retained, and a notice that the code was
* modified is included with the above copyright notice.
*
*/
#if defined (_STLP_USE_SAFE_STRING_FUNCTIONS)
# define _STLP_WCSNCPY(D, DS, S, C) wcsncpy_s(D, DS, S, C)
#else
# define _STLP_WCSNCPY(D, DS, S, C) wcsncpy(D, S, C)
#endif
static const wchar_t* __wtrue_name = L"true";
static const wchar_t* __wfalse_name = L"false";
typedef struct _Locale_codecvt {
_Locale_lcid_t lc;
UINT cp;
unsigned char cleads[256 / CHAR_BIT];
unsigned char max_char_size;
DWORD mbtowc_flags;
DWORD wctomb_flags;
} _Locale_codecvt_t;
/* Ctype */
_Locale_mask_t _WLocale_ctype(_Locale_ctype_t* ltype, wint_t c,
_Locale_mask_t which_bits) {
wchar_t buf[2];
WORD out[2];
buf[0] = c; buf[1] = 0;
GetStringTypeW(CT_CTYPE1, buf, -1, out);
_STLP_MARK_PARAMETER_AS_UNUSED(ltype)
return (_Locale_mask_t)(MapCtypeMask(out[0]) & which_bits);
}
wint_t _WLocale_tolower(_Locale_ctype_t* ltype, wint_t c) {
wchar_t in_c = c;
wchar_t res;
LCMapStringW(ltype->lc.id, LCMAP_LOWERCASE, &in_c, 1, &res, 1);
return res;
}
wint_t _WLocale_toupper(_Locale_ctype_t* ltype, wint_t c) {
wchar_t in_c = c;
wchar_t res;
LCMapStringW(ltype->lc.id, LCMAP_UPPERCASE, &in_c, 1, &res, 1);
return res;
}
_Locale_codecvt_t* _Locale_codecvt_create(const char * name, _Locale_lcid_t* lc_hint, int *__err_code) {
char cp_name[MAX_CP_LEN + 1];
unsigned char *ptr;
CPINFO CPInfo;
int i;
_Locale_codecvt_t *lcodecvt = (_Locale_codecvt_t*)malloc(sizeof(_Locale_codecvt_t));
if (!lcodecvt) { *__err_code = _STLP_LOC_NO_MEMORY; return lcodecvt; }
memset(lcodecvt, 0, sizeof(_Locale_codecvt_t));
if (__GetLCIDFromName(name, &lcodecvt->lc.id, cp_name, lc_hint) == -1)
{ free(lcodecvt); *__err_code = _STLP_LOC_UNKNOWN_NAME; return NULL; }
lcodecvt->cp = atoi(cp_name);
if (!GetCPInfo(lcodecvt->cp, &CPInfo)) { free(lcodecvt); return NULL; }
if (lcodecvt->cp != CP_UTF7 && lcodecvt->cp != CP_UTF8) {
lcodecvt->mbtowc_flags = MB_PRECOMPOSED;
lcodecvt->wctomb_flags = WC_COMPOSITECHECK | WC_SEPCHARS;
}
lcodecvt->max_char_size = CPInfo.MaxCharSize;
if (CPInfo.MaxCharSize > 1) {
for (ptr = (unsigned char*)CPInfo.LeadByte; *ptr && *(ptr + 1); ptr += 2)
for (i = *ptr; i <= *(ptr + 1); ++i) lcodecvt->cleads[i / CHAR_BIT] |= (0x01 << i % CHAR_BIT);
}
return lcodecvt;
}
char const* _Locale_codecvt_name(const _Locale_codecvt_t* lcodecvt, char* buf) {
char cp_buf[MAX_CP_LEN + 1];
my_ltoa(lcodecvt->cp, cp_buf);
return __GetLocaleName(lcodecvt->lc.id, cp_buf, buf);
}
void _Locale_codecvt_destroy(_Locale_codecvt_t* lcodecvt) {
if (!lcodecvt) return;
free(lcodecvt);
}
int _WLocale_mb_cur_max (_Locale_codecvt_t * lcodecvt)
{ return lcodecvt->max_char_size; }
int _WLocale_mb_cur_min (_Locale_codecvt_t *lcodecvt) {
_STLP_MARK_PARAMETER_AS_UNUSED(lcodecvt)
return 1;
}
int _WLocale_is_stateless (_Locale_codecvt_t * lcodecvt)
{ return (lcodecvt->max_char_size == 1) ? 1 : 0; }
static int __isleadbyte(int i, unsigned char *ctable) {
unsigned char c = (unsigned char)i;
return (ctable[c / CHAR_BIT] & (0x01 << c % CHAR_BIT));
}
static int __mbtowc(_Locale_codecvt_t *l, wchar_t *dst, const char *from, unsigned int count) {
int result;
if (l->cp == CP_UTF7 || l->cp == CP_UTF8) {
result = MultiByteToWideChar(l->cp, l->mbtowc_flags, from, count, dst, 1);
if (result == 0) {
switch (GetLastError()) {
case ERROR_NO_UNICODE_TRANSLATION:
return -2;
default:
return -1;
}
}
}
else {
if (count == 1 && __isleadbyte(*from, l->cleads)) return (size_t)-2;
result = MultiByteToWideChar(l->cp, l->mbtowc_flags, from, count, dst, 1);
if (result == 0) return -1;
}
return result;
}
size_t _WLocale_mbtowc(_Locale_codecvt_t *lcodecvt, wchar_t *to,
const char *from, size_t n, mbstate_t *shift_state) {
int result;
_STLP_MARK_PARAMETER_AS_UNUSED(shift_state)
if (lcodecvt->max_char_size == 1) { /* Single byte encoding. */
result = MultiByteToWideChar(lcodecvt->cp, lcodecvt->mbtowc_flags, from, 1, to, 1);
if (result == 0) return (size_t)-1;
return result;
}
else { /* Multi byte encoding. */
int retval;
unsigned int count = 1;
while (n--) {
retval = __mbtowc(lcodecvt, to, from, count);
if (retval == -2)
{ if (++count > ((unsigned int)lcodecvt->max_char_size)) return (size_t)-1; }
else if (retval == -1)
{ return (size_t)-1; }
else
{ return count; }
}
return (size_t)-2;
}
}
size_t _WLocale_wctomb(_Locale_codecvt_t *lcodecvt, char *to, size_t n,
const wchar_t c, mbstate_t *shift_state) {
int size = WideCharToMultiByte(lcodecvt->cp, lcodecvt->wctomb_flags, &c, 1, NULL, 0, NULL, NULL);
if (!size) return (size_t)-1;
if ((size_t)size > n) return (size_t)-2;
if (n > INT_MAX)
/* Limiting the output buf size to INT_MAX seems like reasonable to transform a single wchar_t. */
n = INT_MAX;
WideCharToMultiByte(lcodecvt->cp, lcodecvt->wctomb_flags, &c, 1, to, (int)n, NULL, NULL);
_STLP_MARK_PARAMETER_AS_UNUSED(shift_state)
return (size_t)size;
}
size_t _WLocale_unshift(_Locale_codecvt_t *lcodecvt, mbstate_t *st,
char *buf, size_t n, char **next) {
/* _WLocale_wctomb do not even touch to st, there is nothing to unshift in this localization implementation. */
_STLP_MARK_PARAMETER_AS_UNUSED(lcodecvt)
_STLP_MARK_PARAMETER_AS_UNUSED(st)
_STLP_MARK_PARAMETER_AS_UNUSED(&n)
*next = buf;
return 0;
}
/* Collate */
/* This function takes care of the potential size_t DWORD different size. */
static int _WLocale_strcmp_aux(_Locale_collate_t* lcol,
const wchar_t* s1, size_t n1,
const wchar_t* s2, size_t n2) {
int result = CSTR_EQUAL;
while (n1 > 0 || n2 > 0) {
DWORD size1 = trim_size_t_to_DWORD(n1);
DWORD size2 = trim_size_t_to_DWORD(n2);
result = CompareStringW(lcol->lc.id, 0, s1, size1, s2, size2);
if (result != CSTR_EQUAL)
break;
n1 -= size1;
n2 -= size2;
}
return result;
}
int _WLocale_strcmp(_Locale_collate_t* lcol,
const wchar_t* s1, size_t n1,
const wchar_t* s2, size_t n2) {
int result;
result = _WLocale_strcmp_aux(lcol, s1, n1, s2, n2);
return (result == CSTR_EQUAL) ? 0 : (result == CSTR_LESS_THAN) ? -1 : 1;
}
size_t _WLocale_strxfrm(_Locale_collate_t* lcol,
wchar_t* dst, size_t dst_size,
const wchar_t* src, size_t src_size) {
int result, i;
/* see _Locale_strxfrm: */
if (src_size > INT_MAX) {
if (dst != 0) {
_STLP_WCSNCPY(dst, dst_size, src, src_size);
}
return src_size;
}
if (dst_size > INT_MAX) {
dst_size = INT_MAX;
}
result = LCMapStringW(lcol->lc.id, LCMAP_SORTKEY, src, (int)src_size, dst, (int)dst_size);
if (result != 0 && dst != 0) {
for (i = result - 1; i >= 0; --i) {
dst[i] = ((unsigned char*)dst)[i];
}
}
return result != 0 ? result - 1 : 0;
}
/* Numeric */
wchar_t _WLocale_decimal_point(_Locale_numeric_t* lnum) {
wchar_t buf[4];
GetLocaleInfoW(lnum->lc.id, LOCALE_SDECIMAL, buf, 4);
return buf[0];
}
wchar_t _WLocale_thousands_sep(_Locale_numeric_t* lnum) {
wchar_t buf[4];
GetLocaleInfoW(lnum->lc.id, LOCALE_STHOUSAND, buf, 4);
return buf[0];
}
const wchar_t * _WLocale_true(_Locale_numeric_t* lnum, wchar_t* buf, size_t bufSize) {
_STLP_MARK_PARAMETER_AS_UNUSED(lnum)
_STLP_MARK_PARAMETER_AS_UNUSED(buf)
_STLP_MARK_PARAMETER_AS_UNUSED(&bufSize)
return __wtrue_name;
}
const wchar_t * _WLocale_false(_Locale_numeric_t* lnum, wchar_t* buf, size_t bufSize) {
_STLP_MARK_PARAMETER_AS_UNUSED(lnum)
_STLP_MARK_PARAMETER_AS_UNUSED(buf)
_STLP_MARK_PARAMETER_AS_UNUSED(&bufSize)
return __wfalse_name;
}
/* Monetary */
const wchar_t* _WLocale_int_curr_symbol(_Locale_monetary_t * lmon, wchar_t* buf, size_t bufSize)
{ GetLocaleInfoW(lmon->lc.id, LOCALE_SINTLSYMBOL, buf, (int)bufSize); return buf; }
const wchar_t* _WLocale_currency_symbol(_Locale_monetary_t * lmon, wchar_t* buf, size_t bufSize)
{ GetLocaleInfoW(lmon->lc.id, LOCALE_SCURRENCY, buf, (int)bufSize); return buf; }
wchar_t _WLocale_mon_decimal_point(_Locale_monetary_t * lmon)
{ return lmon->decimal_point[0]; }
wchar_t _WLocale_mon_thousands_sep(_Locale_monetary_t * lmon)
{ return lmon->thousands_sep[0]; }
const wchar_t* _WLocale_positive_sign(_Locale_monetary_t * lmon, wchar_t* buf, size_t bufSize)
{ GetLocaleInfoW(lmon->lc.id, LOCALE_SPOSITIVESIGN, buf, (int)bufSize); return buf; }
const wchar_t* _WLocale_negative_sign(_Locale_monetary_t * lmon, wchar_t* buf, size_t bufSize)
{ GetLocaleInfoW(lmon->lc.id, LOCALE_SNEGATIVESIGN, buf, (int)bufSize); return buf; }
/* Time */
const wchar_t * _WLocale_full_monthname(_Locale_time_t * ltime, int month,
wchar_t* buf, size_t bufSize)
{ GetLocaleInfoW(ltime->lc.id, LOCALE_SMONTHNAME1 + month, buf, (int)bufSize); return buf; }
const wchar_t * _WLocale_abbrev_monthname(_Locale_time_t * ltime, int month,
wchar_t* buf, size_t bufSize)
{ GetLocaleInfoW(ltime->lc.id, LOCALE_SABBREVMONTHNAME1 + month, buf, (int)bufSize); return buf; }
const wchar_t * _WLocale_full_dayofweek(_Locale_time_t * ltime, int day,
wchar_t* buf, size_t bufSize)
{ GetLocaleInfoW(ltime->lc.id, LOCALE_SDAYNAME1 + day, buf, (int)bufSize); return buf; }
const wchar_t * _WLocale_abbrev_dayofweek(_Locale_time_t * ltime, int day,
wchar_t* buf, size_t bufSize)
{ GetLocaleInfoW(ltime->lc.id, LOCALE_SABBREVDAYNAME1 + day, buf, (int)bufSize); return buf; }
const wchar_t* _WLocale_am_str(_Locale_time_t* ltime,
wchar_t* buf, size_t bufSize)
{ GetLocaleInfoW(ltime->lc.id, LOCALE_S1159, buf, (int)bufSize); return buf; }
const wchar_t* _WLocale_pm_str(_Locale_time_t* ltime,
wchar_t* buf, size_t bufSize)
{ GetLocaleInfoW(ltime->lc.id, LOCALE_S2359, buf, (int)bufSize); return buf; }

Просмотреть файл

@ -1,143 +0,0 @@
/*
* Copyright (c) 1999
* Silicon Graphics Computer Systems, Inc.
*
* Copyright (c) 1999
* Boris Fomitchev
*
* This material is provided "as is", with absolutely no warranty expressed
* or implied. Any use is at your own risk.
*
* Permission to use or copy this software for any purpose is hereby granted
* without fee, provided the above notices are retained on all copies.
* Permission to modify the code and to distribute modified code is granted,
* provided the above notices are retained, and a notice that the code was
* modified is included with the above copyright notice.
*
*/
#include "stlport_prefix.h"
#include <locale>
#include <algorithm>
_STLP_BEGIN_NAMESPACE
//----------------------------------------------------------------------
// codecvt<char, char, mbstate_t>
codecvt<char, char, mbstate_t>::~codecvt() {}
int codecvt<char, char, mbstate_t>::do_length(state_type&,
const char* from,
const char* end,
size_t mx) const
{ return (int)(min) ( __STATIC_CAST(size_t, (end - from)), mx); }
int codecvt<char, char, mbstate_t>::do_max_length() const _STLP_NOTHROW
{ return 1; }
bool
codecvt<char, char, mbstate_t>::do_always_noconv() const _STLP_NOTHROW
{ return true; }
int
codecvt<char, char, mbstate_t>::do_encoding() const _STLP_NOTHROW
{ return 1; }
codecvt_base::result
codecvt<char, char, mbstate_t>::do_unshift(state_type& /* __state */,
char* __to,
char* /* __to_limit */,
char*& __to_next) const
{ __to_next = __to; return noconv; }
codecvt_base::result
codecvt<char, char, mbstate_t>::do_in (state_type& /* __state */ ,
const char* __from,
const char* /* __from_end */,
const char*& __from_next,
char* __to,
char* /* __to_end */,
char*& __to_next) const
{ __from_next = __from; __to_next = __to; return noconv; }
codecvt_base::result
codecvt<char, char, mbstate_t>::do_out(state_type& /* __state */,
const char* __from,
const char* /* __from_end */,
const char*& __from_next,
char* __to,
char* /* __to_limit */,
char*& __to_next) const
{ __from_next = __from; __to_next = __to; return noconv; }
#if !defined (_STLP_NO_WCHAR_T)
//----------------------------------------------------------------------
// codecvt<wchar_t, char, mbstate_t>
codecvt<wchar_t, char, mbstate_t>::~codecvt() {}
codecvt<wchar_t, char, mbstate_t>::result
codecvt<wchar_t, char, mbstate_t>::do_out(state_type& /* state */,
const intern_type* from,
const intern_type* from_end,
const intern_type*& from_next,
extern_type* to,
extern_type* to_limit,
extern_type*& to_next) const {
ptrdiff_t len = (min) (from_end - from, to_limit - to);
copy(from, from + len, to);
from_next = from + len;
to_next = to + len;
return ok;
}
codecvt<wchar_t, char, mbstate_t>::result
codecvt<wchar_t, char, mbstate_t>::do_in (state_type& /* state */,
const extern_type* from,
const extern_type* from_end,
const extern_type*& from_next,
intern_type* to,
intern_type* to_limit,
intern_type*& to_next) const {
ptrdiff_t len = (min) (from_end - from, to_limit - to);
copy(__REINTERPRET_CAST(const unsigned char*, from),
__REINTERPRET_CAST(const unsigned char*, from) + len, to);
from_next = from + len;
to_next = to + len;
return ok;
}
codecvt<wchar_t, char, mbstate_t>::result
codecvt<wchar_t, char, mbstate_t>::do_unshift(state_type& /* state */,
extern_type* to,
extern_type* ,
extern_type*& to_next) const {
to_next = to;
return noconv;
}
int codecvt<wchar_t, char, mbstate_t>::do_encoding() const _STLP_NOTHROW
{ return 1; }
bool codecvt<wchar_t, char, mbstate_t>::do_always_noconv() const _STLP_NOTHROW
{ return true; }
int codecvt<wchar_t, char, mbstate_t>::do_length(state_type&,
const extern_type* from,
const extern_type* end,
size_t mx) const
{ return (int)(min) ((size_t) (end - from), mx); }
int codecvt<wchar_t, char, mbstate_t>::do_max_length() const _STLP_NOTHROW
{ return 1; }
#endif /* wchar_t */
_STLP_END_NAMESPACE
// Local Variables:
// mode:C++
// End:

Просмотреть файл

@ -1,69 +0,0 @@
/*
* Copyright (c) 1999
* Silicon Graphics Computer Systems, Inc.
*
* Copyright (c) 1999
* Boris Fomitchev
*
* This material is provided "as is", with absolutely no warranty expressed
* or implied. Any use is at your own risk.
*
* Permission to use or copy this software for any purpose is hereby granted
* without fee, provided the above notices are retained on all copies.
* Permission to modify the code and to distribute modified code is granted,
* provided the above notices are retained, and a notice that the code was
* modified is included with the above copyright notice.
*
*/
#include "stlport_prefix.h"
#include <locale>
_STLP_BEGIN_NAMESPACE
// collate<char>
collate<char>::~collate() {}
int collate<char>::do_compare(const char* low1, const char* high1,
const char* low2, const char* high2) const
{ return _STLP_PRIV __lexicographical_compare_3way(low1, high1, low2, high2); }
string collate<char>::do_transform(const char* low, const char* high) const
{ return string(low, high); }
long collate<char>::do_hash(const char* low, const char* high) const {
unsigned long result = 0;
for ( ; low < high; ++low)
result = 5 * result + *low;
return result;
}
#if !defined (_STLP_NO_WCHAR_T)
// collate<wchar_t>
collate<wchar_t>::~collate() {}
int
collate<wchar_t>::do_compare(const wchar_t* low1, const wchar_t* high1,
const wchar_t* low2, const wchar_t* high2) const
{ return _STLP_PRIV __lexicographical_compare_3way(low1, high1, low2, high2); }
wstring collate<wchar_t>::do_transform(const wchar_t* low, const wchar_t* high) const
{ return wstring(low, high); }
long collate<wchar_t>::do_hash(const wchar_t* low, const wchar_t* high) const {
unsigned long result = 0;
for ( ; low < high; ++low)
result = 5 * result + *low;
return result;
}
#endif
_STLP_END_NAMESPACE
// Local Variables:
// mode:C++
// End:

Просмотреть файл

@ -1,353 +0,0 @@
/*
* Copyright (c) 1999
* Silicon Graphics Computer Systems, Inc.
*
* Copyright (c) 1999
* Boris Fomitchev
*
* This material is provided "as is", with absolutely no warranty expressed
* or implied. Any use is at your own risk.
*
* Permission to use or copy this software for any purpose is hereby granted
* without fee, provided the above notices are retained on all copies.
* Permission to modify the code and to distribute modified code is granted,
* provided the above notices are retained, and a notice that the code was
* modified is included with the above copyright notice.
*
*/
#include "stlport_prefix.h"
#include <numeric>
#include <cmath>
#include <complex>
#if defined (_STLP_MSVC_LIB) && (_STLP_MSVC_LIB >= 1400)
// hypot is deprecated.
# if defined (_STLP_MSVC)
# pragma warning (disable : 4996)
# elif defined (__ICL)
# pragma warning (disable : 1478)
# endif
#endif
_STLP_BEGIN_NAMESPACE
// Complex division and square roots.
// Absolute value
_STLP_TEMPLATE_NULL
_STLP_DECLSPEC float _STLP_CALL abs(const complex<float>& __z)
{ return ::hypot(__z._M_re, __z._M_im); }
_STLP_TEMPLATE_NULL
_STLP_DECLSPEC double _STLP_CALL abs(const complex<double>& __z)
{ return ::hypot(__z._M_re, __z._M_im); }
#if !defined (_STLP_NO_LONG_DOUBLE)
_STLP_TEMPLATE_NULL
_STLP_DECLSPEC long double _STLP_CALL abs(const complex<long double>& __z)
{ return ::hypot(__z._M_re, __z._M_im); }
#endif
// Phase
_STLP_TEMPLATE_NULL
_STLP_DECLSPEC float _STLP_CALL arg(const complex<float>& __z)
{ return ::atan2(__z._M_im, __z._M_re); }
_STLP_TEMPLATE_NULL
_STLP_DECLSPEC double _STLP_CALL arg(const complex<double>& __z)
{ return ::atan2(__z._M_im, __z._M_re); }
#if !defined (_STLP_NO_LONG_DOUBLE)
_STLP_TEMPLATE_NULL
_STLP_DECLSPEC long double _STLP_CALL arg(const complex<long double>& __z)
{ return ::atan2(__z._M_im, __z._M_re); }
#endif
// Construct a complex number from polar representation
_STLP_TEMPLATE_NULL
_STLP_DECLSPEC complex<float> _STLP_CALL polar(const float& __rho, const float& __phi)
{ return complex<float>(__rho * ::cos(__phi), __rho * ::sin(__phi)); }
_STLP_TEMPLATE_NULL
_STLP_DECLSPEC complex<double> _STLP_CALL polar(const double& __rho, const double& __phi)
{ return complex<double>(__rho * ::cos(__phi), __rho * ::sin(__phi)); }
#if !defined (_STLP_NO_LONG_DOUBLE)
_STLP_TEMPLATE_NULL
_STLP_DECLSPEC complex<long double> _STLP_CALL polar(const long double& __rho, const long double& __phi)
{ return complex<long double>(__rho * ::cos(__phi), __rho * ::sin(__phi)); }
#endif
// Division
template <class _Tp>
static void _divT(const _Tp& __z1_r, const _Tp& __z1_i,
const _Tp& __z2_r, const _Tp& __z2_i,
_Tp& __res_r, _Tp& __res_i) {
_Tp __ar = __z2_r >= 0 ? __z2_r : -__z2_r;
_Tp __ai = __z2_i >= 0 ? __z2_i : -__z2_i;
if (__ar <= __ai) {
_Tp __ratio = __z2_r / __z2_i;
_Tp __denom = __z2_i * (1 + __ratio * __ratio);
__res_r = (__z1_r * __ratio + __z1_i) / __denom;
__res_i = (__z1_i * __ratio - __z1_r) / __denom;
}
else {
_Tp __ratio = __z2_i / __z2_r;
_Tp __denom = __z2_r * (1 + __ratio * __ratio);
__res_r = (__z1_r + __z1_i * __ratio) / __denom;
__res_i = (__z1_i - __z1_r * __ratio) / __denom;
}
}
template <class _Tp>
static void _divT(const _Tp& __z1_r,
const _Tp& __z2_r, const _Tp& __z2_i,
_Tp& __res_r, _Tp& __res_i) {
_Tp __ar = __z2_r >= 0 ? __z2_r : -__z2_r;
_Tp __ai = __z2_i >= 0 ? __z2_i : -__z2_i;
if (__ar <= __ai) {
_Tp __ratio = __z2_r / __z2_i;
_Tp __denom = __z2_i * (1 + __ratio * __ratio);
__res_r = (__z1_r * __ratio) / __denom;
__res_i = - __z1_r / __denom;
}
else {
_Tp __ratio = __z2_i / __z2_r;
_Tp __denom = __z2_r * (1 + __ratio * __ratio);
__res_r = __z1_r / __denom;
__res_i = - (__z1_r * __ratio) / __denom;
}
}
void _STLP_CALL
complex<float>::_div(const float& __z1_r, const float& __z1_i,
const float& __z2_r, const float& __z2_i,
float& __res_r, float& __res_i)
{ _divT(__z1_r, __z1_i, __z2_r, __z2_i, __res_r, __res_i); }
void _STLP_CALL
complex<float>::_div(const float& __z1_r,
const float& __z2_r, const float& __z2_i,
float& __res_r, float& __res_i)
{ _divT(__z1_r, __z2_r, __z2_i, __res_r, __res_i); }
void _STLP_CALL
complex<double>::_div(const double& __z1_r, const double& __z1_i,
const double& __z2_r, const double& __z2_i,
double& __res_r, double& __res_i)
{ _divT(__z1_r, __z1_i, __z2_r, __z2_i, __res_r, __res_i); }
void _STLP_CALL
complex<double>::_div(const double& __z1_r,
const double& __z2_r, const double& __z2_i,
double& __res_r, double& __res_i)
{ _divT(__z1_r, __z2_r, __z2_i, __res_r, __res_i); }
#if !defined (_STLP_NO_LONG_DOUBLE)
void _STLP_CALL
complex<long double>::_div(const long double& __z1_r, const long double& __z1_i,
const long double& __z2_r, const long double& __z2_i,
long double& __res_r, long double& __res_i)
{ _divT(__z1_r, __z1_i, __z2_r, __z2_i, __res_r, __res_i); }
void _STLP_CALL
complex<long double>::_div(const long double& __z1_r,
const long double& __z2_r, const long double& __z2_i,
long double& __res_r, long double& __res_i)
{ _divT(__z1_r, __z2_r, __z2_i, __res_r, __res_i); }
#endif
//----------------------------------------------------------------------
// Square root
template <class _Tp>
static complex<_Tp> sqrtT(const complex<_Tp>& z) {
_Tp re = z._M_re;
_Tp im = z._M_im;
_Tp mag = ::hypot(re, im);
complex<_Tp> result;
if (mag == 0.f) {
result._M_re = result._M_im = 0.f;
} else if (re > 0.f) {
result._M_re = ::sqrt(0.5f * (mag + re));
result._M_im = im/result._M_re/2.f;
} else {
result._M_im = ::sqrt(0.5f * (mag - re));
if (im < 0.f)
result._M_im = - result._M_im;
result._M_re = im/result._M_im/2.f;
}
return result;
}
complex<float> _STLP_CALL
sqrt(const complex<float>& z) { return sqrtT(z); }
complex<double> _STLP_CALL
sqrt(const complex<double>& z) { return sqrtT(z); }
#if !defined (_STLP_NO_LONG_DOUBLE)
complex<long double> _STLP_CALL
sqrt(const complex<long double>& z) { return sqrtT(z); }
#endif
// exp, log, pow for complex<float>, complex<double>, and complex<long double>
//----------------------------------------------------------------------
// exp
template <class _Tp>
static complex<_Tp> expT(const complex<_Tp>& z) {
_Tp expx = ::exp(z._M_re);
return complex<_Tp>(expx * ::cos(z._M_im),
expx * ::sin(z._M_im));
}
_STLP_DECLSPEC complex<float> _STLP_CALL exp(const complex<float>& z)
{ return expT(z); }
_STLP_DECLSPEC complex<double> _STLP_CALL exp(const complex<double>& z)
{ return expT(z); }
#if !defined (_STLP_NO_LONG_DOUBLE)
_STLP_DECLSPEC complex<long double> _STLP_CALL exp(const complex<long double>& z)
{ return expT(z); }
#endif
//----------------------------------------------------------------------
// log10
template <class _Tp>
static complex<_Tp> log10T(const complex<_Tp>& z, const _Tp& ln10_inv) {
complex<_Tp> r;
r._M_im = ::atan2(z._M_im, z._M_re) * ln10_inv;
r._M_re = ::log10(::hypot(z._M_re, z._M_im));
return r;
}
_STLP_DECLSPEC complex<float> _STLP_CALL log10(const complex<float>& z)
{
const float LN10_INVF = 1.f / ::log(10.f);
return log10T(z, LN10_INVF);
}
_STLP_DECLSPEC complex<double> _STLP_CALL log10(const complex<double>& z)
{
const double LN10_INV = 1. / ::log10(10.);
return log10T(z, LN10_INV);
}
#if !defined (_STLP_NO_LONG_DOUBLE)
_STLP_DECLSPEC complex<long double> _STLP_CALL log10(const complex<long double>& z)
{
const long double LN10_INVL = 1.l / ::log(10.l);
return log10T(z, LN10_INVL);
}
#endif
//----------------------------------------------------------------------
// log
template <class _Tp>
static complex<_Tp> logT(const complex<_Tp>& z) {
complex<_Tp> r;
r._M_im = ::atan2(z._M_im, z._M_re);
r._M_re = ::log(::hypot(z._M_re, z._M_im));
return r;
}
_STLP_DECLSPEC complex<float> _STLP_CALL log(const complex<float>& z)
{ return logT(z); }
_STLP_DECLSPEC complex<double> _STLP_CALL log(const complex<double>& z)
{ return logT(z); }
#ifndef _STLP_NO_LONG_DOUBLE
_STLP_DECLSPEC complex<long double> _STLP_CALL log(const complex<long double>& z)
{ return logT(z); }
# endif
//----------------------------------------------------------------------
// pow
template <class _Tp>
static complex<_Tp> powT(const _Tp& a, const complex<_Tp>& b) {
_Tp logr = ::log(a);
_Tp x = ::exp(logr * b._M_re);
_Tp y = logr * b._M_im;
return complex<_Tp>(x * ::cos(y), x * ::sin(y));
}
template <class _Tp>
static complex<_Tp> powT(const complex<_Tp>& z_in, int n) {
complex<_Tp> z = z_in;
z = _STLP_PRIV __power(z, (n < 0 ? -n : n), multiplies< complex<_Tp> >());
if (n < 0)
return _Tp(1.0) / z;
else
return z;
}
template <class _Tp>
static complex<_Tp> powT(const complex<_Tp>& a, const _Tp& b) {
_Tp logr = ::log(::hypot(a._M_re,a._M_im));
_Tp logi = ::atan2(a._M_im, a._M_re);
_Tp x = ::exp(logr * b);
_Tp y = logi * b;
return complex<_Tp>(x * ::cos(y), x * ::sin(y));
}
template <class _Tp>
static complex<_Tp> powT(const complex<_Tp>& a, const complex<_Tp>& b) {
_Tp logr = ::log(::hypot(a._M_re,a._M_im));
_Tp logi = ::atan2(a._M_im, a._M_re);
_Tp x = ::exp(logr * b._M_re - logi * b._M_im);
_Tp y = logr * b._M_im + logi * b._M_re;
return complex<_Tp>(x * ::cos(y), x * ::sin(y));
}
_STLP_DECLSPEC complex<float> _STLP_CALL pow(const float& a, const complex<float>& b)
{ return powT(a, b); }
_STLP_DECLSPEC complex<float> _STLP_CALL pow(const complex<float>& z_in, int n)
{ return powT(z_in, n); }
_STLP_DECLSPEC complex<float> _STLP_CALL pow(const complex<float>& a, const float& b)
{ return powT(a, b); }
_STLP_DECLSPEC complex<float> _STLP_CALL pow(const complex<float>& a, const complex<float>& b)
{ return powT(a, b); }
_STLP_DECLSPEC complex<double> _STLP_CALL pow(const double& a, const complex<double>& b)
{ return powT(a, b); }
_STLP_DECLSPEC complex<double> _STLP_CALL pow(const complex<double>& z_in, int n)
{ return powT(z_in, n); }
_STLP_DECLSPEC complex<double> _STLP_CALL pow(const complex<double>& a, const double& b)
{ return powT(a, b); }
_STLP_DECLSPEC complex<double> _STLP_CALL pow(const complex<double>& a, const complex<double>& b)
{ return powT(a, b); }
#if !defined (_STLP_NO_LONG_DOUBLE)
_STLP_DECLSPEC complex<long double> _STLP_CALL pow(const long double& a,
const complex<long double>& b)
{ return powT(a, b); }
_STLP_DECLSPEC complex<long double> _STLP_CALL pow(const complex<long double>& z_in, int n)
{ return powT(z_in, n); }
_STLP_DECLSPEC complex<long double> _STLP_CALL pow(const complex<long double>& a,
const long double& b)
{ return powT(a, b); }
_STLP_DECLSPEC complex<long double> _STLP_CALL pow(const complex<long double>& a,
const complex<long double>& b)
{ return powT(a, b); }
#endif
_STLP_END_NAMESPACE

Просмотреть файл

@ -1,157 +0,0 @@
/*
* Copyright (c) 1999
* Silicon Graphics Computer Systems, Inc.
*
* Copyright (c) 1999
* Boris Fomitchev
*
* This material is provided "as is", with absolutely no warranty expressed
* or implied. Any use is at your own risk.
*
* Permission to use or copy this software for any purpose is hereby granted
* without fee, provided the above notices are retained on all copies.
* Permission to modify the code and to distribute modified code is granted,
* provided the above notices are retained, and a notice that the code was
* modified is included with the above copyright notice.
*
*/
#include "stlport_prefix.h"
#include <complex>
#include <istream>
_STLP_BEGIN_NAMESPACE
// Specializations for narrow characters; lets us avoid the nuisance of
// widening.
_STLP_OPERATOR_SPEC
basic_ostream<char, char_traits<char> >& _STLP_CALL
operator<< (basic_ostream<char, char_traits<char> >& __os, const complex<float>& __z)
{ return __os << '(' << (double)__z.real() << ',' << (double)__z.imag() << ')'; }
_STLP_OPERATOR_SPEC
basic_ostream<char, char_traits<char> >& _STLP_CALL
operator<< (basic_ostream<char, char_traits<char> >& __os, const complex<double>& __z)
{ return __os << '(' << __z.real() << ',' << __z.imag() << ')'; }
#ifndef _STLP_NO_LONG_DOUBLE
_STLP_OPERATOR_SPEC
basic_ostream<char, char_traits<char> >& _STLP_CALL
operator<< (basic_ostream<char, char_traits<char> >& __os, const complex<long double>& __z)
{ return __os << '(' << __z.real() << ',' << __z.imag() << ')'; }
#endif
// Specialization for narrow characters; lets us avoid widen.
_STLP_OPERATOR_SPEC
basic_istream<char, char_traits<char> >& _STLP_CALL
operator>>(basic_istream<char, char_traits<char> >& __is, complex<float>& __z) {
float __re = 0;
float __im = 0;
char __c;
__is >> __c;
if (__c == '(') {
__is >> __re >> __c;
if (__c == ',')
__is >> __im >> __c;
if (__c != ')')
__is.setstate(ios_base::failbit);
}
else {
__is.putback(__c);
__is >> __re;
}
if (__is)
__z = complex<float>(__re, __im);
return __is;
}
_STLP_OPERATOR_SPEC
basic_istream<char, char_traits<char> >& _STLP_CALL
operator>>(basic_istream<char, char_traits<char> >& __is, complex<double>& __z) {
double __re = 0;
double __im = 0;
char __c;
__is >> __c;
if (__c == '(') {
__is >> __re >> __c;
if (__c == ',')
__is >> __im >> __c;
if (__c != ')')
__is.setstate(ios_base::failbit);
}
else {
__is.putback(__c);
__is >> __re;
}
if (__is)
__z = complex<double>(__re, __im);
return __is;
}
#ifndef _STLP_NO_LONG_DOUBLE
_STLP_OPERATOR_SPEC
basic_istream<char, char_traits<char> >& _STLP_CALL
operator>>(basic_istream<char, char_traits<char> >& __is, complex<long double>& __z) {
long double __re = 0;
long double __im = 0;
char __c;
__is >> __c;
if (__c == '(') {
__is >> __re >> __c;
if (__c == ',')
__is >> __im >> __c;
if (__c != ')')
__is.setstate(ios_base::failbit);
}
else {
__is.putback(__c);
__is >> __re;
}
if (__is)
__z = complex<long double>(__re, __im);
return __is;
}
#endif
// Force instantiation of complex I/O functions
#if !(defined (_STLP_NO_FORCE_INSTANTIATE) || defined (_STLP_NO_WCHAR_T))
_STLP_OPERATOR_SPEC basic_istream<wchar_t, char_traits<wchar_t> >& _STLP_CALL
operator>>(basic_istream<wchar_t, char_traits<wchar_t> >&, complex<float>&);
_STLP_OPERATOR_SPEC basic_istream<wchar_t, char_traits<wchar_t> >& _STLP_CALL
operator>>(basic_istream<wchar_t, char_traits<wchar_t> >&, complex<double>&);
#ifndef _STLP_NO_LONG_DOUBLE
_STLP_OPERATOR_SPEC basic_istream<wchar_t, char_traits<wchar_t> >& _STLP_CALL
operator>>(basic_istream<wchar_t, char_traits<wchar_t> >&, complex<long double>&);
_STLP_OPERATOR_SPEC basic_ostream<wchar_t, char_traits<wchar_t> >& _STLP_CALL
operator<<(basic_ostream<wchar_t, char_traits<wchar_t> >&, const complex<long double>&);
#endif
_STLP_OPERATOR_SPEC basic_ostream<wchar_t, char_traits<wchar_t> >& _STLP_CALL
operator<<(basic_ostream<wchar_t, char_traits<wchar_t> >&, const complex<float>&);
_STLP_OPERATOR_SPEC basic_ostream<wchar_t, char_traits<wchar_t> >& _STLP_CALL
operator<<(basic_ostream<wchar_t, char_traits<wchar_t> >&, const complex<double>&);
#endif /* _STLP_NO_WCHAR_T */
_STLP_END_NAMESPACE
// Local Variables:
// mode:C++
// End:

Просмотреть файл

@ -1,192 +0,0 @@
/*
* Copyright (c) 1999
* Silicon Graphics Computer Systems, Inc.
*
* Copyright (c) 1999
* Boris Fomitchev
*
* This material is provided "as is", with absolutely no warranty expressed
* or implied. Any use is at your own risk.
*
* Permission to use or copy this software for any purpose is hereby granted
* without fee, provided the above notices are retained on all copies.
* Permission to modify the code and to distribute modified code is granted,
* provided the above notices are retained, and a notice that the code was
* modified is included with the above copyright notice.
*
*/
#include "stlport_prefix.h"
// Trigonometric and hyperbolic functions for complex<float>,
// complex<double>, and complex<long double>
#include <complex>
#include <cfloat>
#include <cmath>
_STLP_BEGIN_NAMESPACE
//----------------------------------------------------------------------
// helpers
#if defined (__sgi)
static const union { unsigned int i; float f; } float_ulimit = { 0x42b2d4fc };
static const float float_limit = float_ulimit.f;
static union {
struct { unsigned int h; unsigned int l; } w;
double d;
} double_ulimit = { 0x408633ce, 0x8fb9f87d };
static const double double_limit = double_ulimit.d;
static union {
struct { unsigned int h[2]; unsigned int l[2]; } w;
long double ld;
} ldouble_ulimit = {0x408633ce, 0x8fb9f87e, 0xbd23b659, 0x4e9bd8b1};
# if !defined (_STLP_NO_LONG_DOUBLE)
# define ldouble_limit ldouble_ulimit.ld
# endif
#else
# if defined (M_LN2) && defined (FLT_MAX_EXP)
static const float float_limit = float(M_LN2 * FLT_MAX_EXP);
static const double double_limit = M_LN2 * DBL_MAX_EXP;
# else
static const float float_limit = ::log(FLT_MAX);
static const double double_limit = ::log(DBL_MAX);
# endif
# if !defined (_STLP_NO_LONG_DOUBLE)
# if defined (M_LN2l)
# define ldouble_limit (M_LN2l * LDBL_MAX_EXP)
# else
# define ldouble_limit ::log(LDBL_MAX)
# endif
# endif
#endif
//----------------------------------------------------------------------
// sin
template <class _Tp>
static complex<_Tp> sinT(const complex<_Tp>& z) {
return complex<_Tp>(::sin(z._M_re) * ::cosh(z._M_im),
::cos(z._M_re) * ::sinh(z._M_im));
}
_STLP_DECLSPEC complex<float> _STLP_CALL sin(const complex<float>& z)
{ return sinT(z); }
_STLP_DECLSPEC complex<double> _STLP_CALL sin(const complex<double>& z)
{ return sinT(z); }
#if !defined (_STLP_NO_LONG_DOUBLE)
_STLP_DECLSPEC complex<long double> _STLP_CALL sin(const complex<long double>& z)
{ return sinT(z); }
#endif
//----------------------------------------------------------------------
// cos
template <class _Tp>
static complex<_Tp> cosT(const complex<_Tp>& z) {
return complex<_Tp>(::cos(z._M_re) * ::cosh(z._M_im),
-::sin(z._M_re) * ::sinh(z._M_im));
}
_STLP_DECLSPEC complex<float> _STLP_CALL cos(const complex<float>& z)
{ return cosT(z); }
_STLP_DECLSPEC complex<double> _STLP_CALL cos(const complex<double>& z)
{ return cosT(z); }
#if !defined (_STLP_NO_LONG_DOUBLE)
_STLP_DECLSPEC complex<long double> _STLP_CALL cos(const complex<long double>& z)
{ return cosT(z); }
#endif
//----------------------------------------------------------------------
// tan
template <class _Tp>
static complex<_Tp> tanT(const complex<_Tp>& z, const _Tp& Tp_limit) {
_Tp re2 = 2.f * z._M_re;
_Tp im2 = 2.f * z._M_im;
if (::abs(im2) > Tp_limit)
return complex<_Tp>(0.f, (im2 > 0 ? 1.f : -1.f));
else {
_Tp den = ::cos(re2) + ::cosh(im2);
return complex<_Tp>(::sin(re2) / den, ::sinh(im2) / den);
}
}
_STLP_DECLSPEC complex<float> _STLP_CALL tan(const complex<float>& z)
{ return tanT(z, float_limit); }
_STLP_DECLSPEC complex<double> _STLP_CALL tan(const complex<double>& z)
{ return tanT(z, double_limit); }
#if !defined (_STLP_NO_LONG_DOUBLE)
_STLP_DECLSPEC complex<long double> _STLP_CALL tan(const complex<long double>& z)
{ return tanT(z, ldouble_limit); }
#endif
//----------------------------------------------------------------------
// sinh
template <class _Tp>
static complex<_Tp> sinhT(const complex<_Tp>& z) {
return complex<_Tp>(::sinh(z._M_re) * ::cos(z._M_im),
::cosh(z._M_re) * ::sin(z._M_im));
}
_STLP_DECLSPEC complex<float> _STLP_CALL sinh(const complex<float>& z)
{ return sinhT(z); }
_STLP_DECLSPEC complex<double> _STLP_CALL sinh(const complex<double>& z)
{ return sinhT(z); }
#if !defined (_STLP_NO_LONG_DOUBLE)
_STLP_DECLSPEC complex<long double> _STLP_CALL sinh(const complex<long double>& z)
{ return sinhT(z); }
#endif
//----------------------------------------------------------------------
// cosh
template <class _Tp>
static complex<_Tp> coshT(const complex<_Tp>& z) {
return complex<_Tp>(::cosh(z._M_re) * ::cos(z._M_im),
::sinh(z._M_re) * ::sin(z._M_im));
}
_STLP_DECLSPEC complex<float> _STLP_CALL cosh(const complex<float>& z)
{ return coshT(z); }
_STLP_DECLSPEC complex<double> _STLP_CALL cosh(const complex<double>& z)
{ return coshT(z); }
#if !defined (_STLP_NO_LONG_DOUBLE)
_STLP_DECLSPEC complex<long double> _STLP_CALL cosh(const complex<long double>& z)
{ return coshT(z); }
#endif
//----------------------------------------------------------------------
// tanh
template <class _Tp>
static complex<_Tp> tanhT(const complex<_Tp>& z, const _Tp& Tp_limit) {
_Tp re2 = 2.f * z._M_re;
_Tp im2 = 2.f * z._M_im;
if (::abs(re2) > Tp_limit)
return complex<_Tp>((re2 > 0 ? 1.f : -1.f), 0.f);
else {
_Tp den = ::cosh(re2) + ::cos(im2);
return complex<_Tp>(::sinh(re2) / den, ::sin(im2) / den);
}
}
_STLP_DECLSPEC complex<float> _STLP_CALL tanh(const complex<float>& z)
{ return tanhT(z, float_limit); }
_STLP_DECLSPEC complex<double> _STLP_CALL tanh(const complex<double>& z)
{ return tanhT(z, double_limit); }
#if !defined (_STLP_NO_LONG_DOUBLE)
_STLP_DECLSPEC complex<long double> _STLP_CALL tanh(const complex<long double>& z)
{ return tanhT(z, ldouble_limit); }
#endif
_STLP_END_NAMESPACE

Просмотреть файл

@ -1,486 +0,0 @@
/*
* Copyright (c) 1999
* Silicon Graphics Computer Systems, Inc.
*
* Copyright (c) 1999
* Boris Fomitchev
*
* This material is provided "as is", with absolutely no warranty expressed
* or implied. Any use is at your own risk.
*
* Permission to use or copy this software for any purpose is hereby granted
* without fee, provided the above notices are retained on all copies.
* Permission to modify the code and to distribute modified code is granted,
* provided the above notices are retained, and a notice that the code was
* modified is included with the above copyright notice.
*
*/
#include "stlport_prefix.h"
#include <algorithm>
#include <locale>
#include <functional>
#include "c_locale.h"
_STLP_BEGIN_NAMESPACE
//----------------------------------------------------------------------
// ctype<char>
// The classic table: static data members.
#if !defined (_STLP_STATIC_CONST_INIT_BUG) && !defined (_STLP_NO_STATIC_CONST_DEFINITION)
//*TY 02/25/2000 - added workaround for MPW compilers; they confuse on in-class static const
const size_t ctype<char>::table_size;
#endif
// This macro is specifically for platforms where isprint() relies
// on separate flag
const ctype_base::mask*
ctype<char>::classic_table() _STLP_NOTHROW {
/* Ctype table for the ASCII character set. */
static const ctype_base::mask _S_classic_table[table_size] = {
cntrl /* null */,
cntrl /* ^A */,
cntrl /* ^B */,
cntrl /* ^C */,
cntrl /* ^D */,
cntrl /* ^E */,
cntrl /* ^F */,
cntrl /* ^G */,
cntrl /* ^H */,
ctype_base::mask(space | cntrl) /* tab */,
ctype_base::mask(space | cntrl) /* LF */,
ctype_base::mask(space | cntrl) /* ^K */,
ctype_base::mask(space | cntrl) /* FF */,
ctype_base::mask(space | cntrl) /* ^M */,
cntrl /* ^N */,
cntrl /* ^O */,
cntrl /* ^P */,
cntrl /* ^Q */,
cntrl /* ^R */,
cntrl /* ^S */,
cntrl /* ^T */,
cntrl /* ^U */,
cntrl /* ^V */,
cntrl /* ^W */,
cntrl /* ^X */,
cntrl /* ^Y */,
cntrl /* ^Z */,
cntrl /* esc */,
cntrl /* ^\ */,
cntrl /* ^] */,
cntrl /* ^^ */,
cntrl /* ^_ */,
ctype_base::mask(space | print) /* */,
ctype_base::mask(punct | print) /* ! */,
ctype_base::mask(punct | print) /* " */,
ctype_base::mask(punct | print) /* # */,
ctype_base::mask(punct | print) /* $ */,
ctype_base::mask(punct | print) /* % */,
ctype_base::mask(punct | print) /* & */,
ctype_base::mask(punct | print) /* ' */,
ctype_base::mask(punct | print) /* ( */,
ctype_base::mask(punct | print) /* ) */,
ctype_base::mask(punct | print) /* * */,
ctype_base::mask(punct | print) /* + */,
ctype_base::mask(punct | print) /* , */,
ctype_base::mask(punct | print) /* - */,
ctype_base::mask(punct | print) /* . */,
ctype_base::mask(punct | print) /* / */,
ctype_base::mask(digit | print | xdigit) /* 0 */,
ctype_base::mask(digit | print | xdigit) /* 1 */,
ctype_base::mask(digit | print | xdigit) /* 2 */,
ctype_base::mask(digit | print | xdigit) /* 3 */,
ctype_base::mask(digit | print | xdigit) /* 4 */,
ctype_base::mask(digit | print | xdigit) /* 5 */,
ctype_base::mask(digit | print | xdigit) /* 6 */,
ctype_base::mask(digit | print | xdigit) /* 7 */,
ctype_base::mask(digit | print | xdigit) /* 8 */,
ctype_base::mask(digit | print | xdigit) /* 9 */,
ctype_base::mask(punct | print) /* : */,
ctype_base::mask(punct | print) /* ; */,
ctype_base::mask(punct | print) /* < */,
ctype_base::mask(punct | print) /* = */,
ctype_base::mask(punct | print) /* > */,
ctype_base::mask(punct | print) /* ? */,
ctype_base::mask(punct | print) /* ! */,
ctype_base::mask(alpha | print | upper | xdigit) /* A */,
ctype_base::mask(alpha | print | upper | xdigit) /* B */,
ctype_base::mask(alpha | print | upper | xdigit) /* C */,
ctype_base::mask(alpha | print | upper | xdigit) /* D */,
ctype_base::mask(alpha | print | upper | xdigit) /* E */,
ctype_base::mask(alpha | print | upper | xdigit) /* F */,
ctype_base::mask(alpha | print | upper) /* G */,
ctype_base::mask(alpha | print | upper) /* H */,
ctype_base::mask(alpha | print | upper) /* I */,
ctype_base::mask(alpha | print | upper) /* J */,
ctype_base::mask(alpha | print | upper) /* K */,
ctype_base::mask(alpha | print | upper) /* L */,
ctype_base::mask(alpha | print | upper) /* M */,
ctype_base::mask(alpha | print | upper) /* N */,
ctype_base::mask(alpha | print | upper) /* O */,
ctype_base::mask(alpha | print | upper) /* P */,
ctype_base::mask(alpha | print | upper) /* Q */,
ctype_base::mask(alpha | print | upper) /* R */,
ctype_base::mask(alpha | print | upper) /* S */,
ctype_base::mask(alpha | print | upper) /* T */,
ctype_base::mask(alpha | print | upper) /* U */,
ctype_base::mask(alpha | print | upper) /* V */,
ctype_base::mask(alpha | print | upper) /* W */,
ctype_base::mask(alpha | print | upper) /* X */,
ctype_base::mask(alpha | print | upper) /* Y */,
ctype_base::mask(alpha | print | upper) /* Z */,
ctype_base::mask(punct | print) /* [ */,
ctype_base::mask(punct | print) /* \ */,
ctype_base::mask(punct | print) /* ] */,
ctype_base::mask(punct | print) /* ^ */,
ctype_base::mask(punct | print) /* _ */,
ctype_base::mask(punct | print) /* ` */,
ctype_base::mask(alpha | print | lower | xdigit) /* a */,
ctype_base::mask(alpha | print | lower | xdigit) /* b */,
ctype_base::mask(alpha | print | lower | xdigit) /* c */,
ctype_base::mask(alpha | print | lower | xdigit) /* d */,
ctype_base::mask(alpha | print | lower | xdigit) /* e */,
ctype_base::mask(alpha | print | lower | xdigit) /* f */,
ctype_base::mask(alpha | print | lower) /* g */,
ctype_base::mask(alpha | print | lower) /* h */,
ctype_base::mask(alpha | print | lower) /* i */,
ctype_base::mask(alpha | print | lower) /* j */,
ctype_base::mask(alpha | print | lower) /* k */,
ctype_base::mask(alpha | print | lower) /* l */,
ctype_base::mask(alpha | print | lower) /* m */,
ctype_base::mask(alpha | print | lower) /* n */,
ctype_base::mask(alpha | print | lower) /* o */,
ctype_base::mask(alpha | print | lower) /* p */,
ctype_base::mask(alpha | print | lower) /* q */,
ctype_base::mask(alpha | print | lower) /* r */,
ctype_base::mask(alpha | print | lower) /* s */,
ctype_base::mask(alpha | print | lower) /* t */,
ctype_base::mask(alpha | print | lower) /* u */,
ctype_base::mask(alpha | print | lower) /* v */,
ctype_base::mask(alpha | print | lower) /* w */,
ctype_base::mask(alpha | print | lower) /* x */,
ctype_base::mask(alpha | print | lower) /* y */,
ctype_base::mask(alpha | print | lower) /* z */,
ctype_base::mask(punct | print) /* { */,
ctype_base::mask(punct | print) /* | */,
ctype_base::mask(punct | print) /* } */,
ctype_base::mask(punct | print) /* ~ */,
cntrl /* del (0x7f)*/,
/* ASCII is a 7-bit code, so everything else is non-ASCII */
ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0),
ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0),
ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0),
ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0),
ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0),
ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0),
ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0),
ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0),
ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0),
ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0),
ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0),
ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0),
ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0),
ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0),
ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0),
ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0), ctype_base::mask(0)
};
return _S_classic_table;
}
// For every c in the range 0 <= c < 256, _S_upper[c] is the
// uppercased version of c and _S_lower[c] is the lowercased
// version. As before, these two tables assume the ASCII character
// set.
const unsigned char _S_upper[ctype<char>::table_size] =
{
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27,
0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f,
0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57,
0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f,
0x60, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f,
0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57,
0x58, 0x59, 0x5a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f,
0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f,
0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97,
0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f,
0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7,
0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf,
0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7,
0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf,
0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7,
0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf,
0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7,
0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf,
0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7,
0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef,
0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
};
const unsigned char _S_lower[ctype<char>::table_size] =
{
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27,
0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
0x40, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67,
0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f,
0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77,
0x78, 0x79, 0x7a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f,
0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67,
0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f,
0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77,
0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f,
0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f,
0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97,
0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f,
0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7,
0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf,
0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7,
0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf,
0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7,
0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf,
0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7,
0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf,
0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7,
0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef,
0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
};
//An helper struct to check wchar_t index without generating warnings
//under some compilers (gcc) because of a limited range of value
//(when wchar_t is unsigned)
template <bool _IsSigned>
struct _WCharIndexT;
#if !(defined (__BORLANDC__) && !defined(__linux__)) && \
!(defined (__GNUC__) && (defined (__MINGW32__) || defined (__CYGWIN__))) && \
!defined (__ICL)
_STLP_TEMPLATE_NULL
struct _WCharIndexT<true> {
static bool in_range(wchar_t c, size_t upperBound) {
return c >= 0 && size_t(c) < upperBound;
}
};
#endif
_STLP_TEMPLATE_NULL
struct _WCharIndexT<false> {
static bool in_range(wchar_t c, size_t upperBound) {
return size_t(c) < upperBound;
}
};
typedef _WCharIndexT<wchar_t(-1) < 0> _WCharIndex;
// Some helper functions used in ctype<>::scan_is and scan_is_not.
struct _Ctype_is_mask : public unary_function<char, bool> {
ctype_base::mask _Mask;
const ctype_base::mask* _M_table;
_Ctype_is_mask(ctype_base::mask __m, const ctype_base::mask* __t) : _Mask(__m), _M_table(__t) {}
bool operator()(char __c) const { return (_M_table[(unsigned char) __c] & _Mask) != 0; }
};
struct _Ctype_not_mask : public unary_function<char, bool> {
ctype_base::mask _Mask;
const ctype_base::mask* _M_table;
_Ctype_not_mask(ctype_base::mask __m, const ctype_base::mask* __t) : _Mask(__m), _M_table(__t) {}
bool operator()(char __c) const { return (_M_table[(unsigned char) __c] & _Mask) == 0; }
};
ctype<char>::ctype(const ctype_base::mask * __tab, bool __del, size_t __refs) :
locale::facet(__refs),
_M_ctype_table(__tab ? __tab : classic_table()),
_M_delete(__tab && __del)
{}
ctype<char>::~ctype() {
if (_M_delete)
delete[] __CONST_CAST(ctype_base::mask *, _M_ctype_table);
}
const char*
#if defined (__DMC__)
_STLP_DECLSPEC
#endif
ctype<char>::scan_is(ctype_base::mask __m, const char* __low, const char* __high) const
{ return _STLP_STD::find_if(__low, __high, _Ctype_is_mask(__m, _M_ctype_table)); }
const char*
#if defined (__DMC__)
_STLP_DECLSPEC
#endif
ctype<char>::scan_not(ctype_base::mask __m, const char* __low, const char* __high) const
{ return _STLP_STD::find_if(__low, __high, _Ctype_not_mask(__m, _M_ctype_table)); }
char ctype<char>::do_toupper(char __c) const
{ return (char) _S_upper[(unsigned char) __c]; }
char ctype<char>::do_tolower(char __c) const
{ return (char) _S_lower[(unsigned char) __c]; }
const char* ctype<char>::do_toupper(char* __low, const char* __high) const {
for ( ; __low < __high; ++__low)
*__low = (char) _S_upper[(unsigned char) *__low];
return __high;
}
const char* ctype<char>::do_tolower(char* __low, const char* __high) const {
for ( ; __low < __high; ++__low)
*__low = (char) _S_lower[(unsigned char) *__low];
return __high;
}
char
ctype<char>::do_widen(char __c) const { return __c; }
const char*
ctype<char>::do_widen(const char* __low, const char* __high,
char* __to) const {
_STLP_PRIV __copy_trivial(__low, __high, __to);
return __high;
}
char
ctype<char>::do_narrow(char __c, char /* dfault */ ) const { return __c; }
const char*
ctype<char>::do_narrow(const char* __low, const char* __high,
char /* dfault */, char* __to) const {
_STLP_PRIV __copy_trivial(__low, __high, __to);
return __high;
}
#if !defined (_STLP_NO_WCHAR_T)
struct _Ctype_w_is_mask : public unary_function<wchar_t, bool> {
ctype_base::mask M;
const ctype_base::mask* table;
_Ctype_w_is_mask(ctype_base::mask m, const ctype_base::mask* t)
: M(m), table(t) {}
bool operator()(wchar_t c) const
{ return _WCharIndex::in_range(c, ctype<char>::table_size) && (table[c] & M); }
};
//----------------------------------------------------------------------
// ctype<wchar_t>
ctype<wchar_t>::~ctype() {}
bool ctype<wchar_t>::do_is(ctype_base::mask m, wchar_t c) const {
const ctype_base::mask * table = ctype<char>::classic_table();
return _WCharIndex::in_range(c, ctype<char>::table_size) && (m & table[c]);
}
const wchar_t* ctype<wchar_t>::do_is(const wchar_t* low, const wchar_t* high,
ctype_base::mask * vec) const {
// boris : not clear if this is the right thing to do...
const ctype_base::mask * table = ctype<char>::classic_table();
wchar_t c;
for ( ; low < high; ++low, ++vec) {
c = *low;
*vec = _WCharIndex::in_range(c, ctype<char>::table_size) ? table[c] : ctype_base::mask(0);
}
return high;
}
const wchar_t*
ctype<wchar_t>::do_scan_is(ctype_base::mask m,
const wchar_t* low, const wchar_t* high) const {
return find_if(low, high, _Ctype_w_is_mask(m, ctype<char>::classic_table()));
}
const wchar_t*
ctype<wchar_t>::do_scan_not(ctype_base::mask m,
const wchar_t* low, const wchar_t* high) const {
return find_if(low, high, not1(_Ctype_w_is_mask(m, ctype<char>::classic_table())));
}
wchar_t ctype<wchar_t>::do_toupper(wchar_t c) const {
return _WCharIndex::in_range(c, ctype<char>::table_size) ? (wchar_t)_S_upper[c]
: c;
}
const wchar_t*
ctype<wchar_t>::do_toupper(wchar_t* low, const wchar_t* high) const {
for ( ; low < high; ++low) {
wchar_t c = *low;
*low = _WCharIndex::in_range(c, ctype<char>::table_size) ? (wchar_t)_S_upper[c]
: c;
}
return high;
}
wchar_t ctype<wchar_t>::do_tolower(wchar_t c) const {
return _WCharIndex::in_range(c, ctype<char>::table_size) ? (wchar_t)_S_lower[c]
: c;
}
const wchar_t*
ctype<wchar_t>::do_tolower(wchar_t* low, const wchar_t* high) const {
for ( ; low < high; ++low) {
wchar_t c = *low;
*low = _WCharIndex::in_range(c, ctype<char>::table_size) ? (wchar_t)_S_lower[c]
: c;
}
return high;
}
wchar_t ctype<wchar_t>::do_widen(char c) const {
return (wchar_t)(unsigned char)c;
}
const char*
ctype<wchar_t>::do_widen(const char* low, const char* high,
wchar_t* dest) const {
while (low != high)
*dest++ = (wchar_t)(unsigned char)*low++;
return high;
}
char ctype<wchar_t>::do_narrow(wchar_t c, char dfault) const
{ return (unsigned char)c == c ? (char)c : dfault; }
const wchar_t* ctype<wchar_t>::do_narrow(const wchar_t* low,
const wchar_t* high,
char dfault, char* dest) const {
while (low != high) {
wchar_t c = *low++;
*dest++ = (unsigned char)c == c ? (char)c : dfault;
}
return high;
}
# endif
_STLP_END_NAMESPACE
// Local Variables:
// mode:C++
// End:

Просмотреть файл

@ -1,198 +0,0 @@
#include "stlport_prefix.h"
#if defined(__unix) && defined(__GNUC__)
#ifdef __FreeBSD__
# include <osreldate.h>
#endif
#if (defined(__FreeBSD__) && (__FreeBSD_version < 503001)) || defined(__sun) || defined (__hpux)
/* Note: __cxa_finalize and __cxa_atexit present in libc in FreeBSD 5.3 */
#include <stdlib.h>
#include <stdio.h>
#include <pthread.h>
/* __asm__ (".symver " "__cxa_finalize" "," "__cxa_finalize" "@" "STLPORT_5_0_0"); */
/* __asm__ (".symver " "__cxa_finalize" "," "__cxa_finalize" "@@" "STLPORT_5_0_0"); */
/* Not atomic! */
/* But we can use static mutexes here: I hope that performance issue isn't very
significant on unloading (for only few calls, ~10) - ptr */
/*
#define atomic_compare_and_exchange_bool_acq(mem, newval, oldval) \
({ __typeof (mem) __gmemp = (mem); \
__typeof (*mem) __gnewval = (newval); \
\
*__gmemp == (oldval) ? (*__gmemp = __gnewval, 0) : 1; })
*/
enum {
ef_free, /* `ef_free' MUST be zero! */
ef_us,
ef_on,
ef_at,
ef_cxa
};
struct exit_function
{
/* `flavour' should be of type of the `enum' above but since we need
this element in an atomic operation we have to use `long int'. */
long int flavor;
union {
void (*at)(void);
struct {
void (*fn)(int status, void *arg);
void *arg;
} on;
struct {
void (*fn)(void *arg, int status);
void *arg;
void *dso_handle;
} cxa;
} func;
};
struct exit_function_list
{
struct exit_function_list *next;
size_t idx;
struct exit_function fns[32];
};
struct exit_function *__new_exitfn (void);
/* Register a function to be called by exit or when a shared library
is unloaded. This function is only called from code generated by
the C++ compiler. */
int __cxa_atexit(void (*func)(void *), void *arg, void *d)
{
struct exit_function *new = __new_exitfn ();
if ( new == NULL )
return -1;
new->flavor = ef_cxa;
new->func.cxa.fn = (void (*) (void *, int)) func;
new->func.cxa.arg = arg;
new->func.cxa.dso_handle = d;
return 0;
}
/* We change global data, so we need locking. */
#ifdef __linux__
static pthread_mutex_t lock = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
#endif
/* #ifdef __FreeBSD__ */
#if 0
static pthread_mutex_t lock =
{ PTHREAD_MUTEX_RECURSIVE /* PTHREAD_MUTEX_DEFAULT */, PTHREAD_PRIO_NONE, {NULL,NULL},
NULL, { NULL }, /* MUTEX_FLAGS_PRIVATE */ 0x1, 0, 0, 0, {NULL, NULL},
{ 0, 0, 0, 0 } };
#endif
#ifdef __sun
static pthread_mutex_t lock =
{{0, 0, 0, PTHREAD_MUTEX_RECURSIVE, _MUTEX_MAGIC}, {{{0}}}, 0};
#endif
#ifdef __hpux
static pthread_mutex_t lock = PTHREAD_MUTEX_RECURSIVE_INITIALIZER_NP;
# ifdef __ia64
void *__dso_handle = (void *) &__dso_handle;
# endif
#endif
static struct exit_function_list initial;
struct exit_function_list *__exit_funcs = &initial;
struct exit_function *__new_exitfn(void)
{
struct exit_function_list *l;
size_t i = 0;
#ifndef __FreeBSD__
pthread_mutex_lock( &lock );
#endif
for (l = __exit_funcs; l != NULL; l = l->next) {
for (i = 0; i < l->idx; ++i)
if (l->fns[i].flavor == ef_free)
break;
if ( i < l->idx )
break;
if (l->idx < sizeof (l->fns) / sizeof (l->fns[0])) {
i = l->idx++;
break;
}
}
if (l == NULL) {
l = (struct exit_function_list *)malloc( sizeof(struct exit_function_list) );
if (l != NULL) {
l->next = __exit_funcs;
__exit_funcs = l;
l->idx = 1;
i = 0;
}
}
/* Mark entry as used, but we don't know the flavor now. */
if ( l != NULL )
l->fns[i].flavor = ef_us;
#ifndef __FreeBSD__
pthread_mutex_unlock( &lock );
#endif
return l == NULL ? NULL : &l->fns[i];
}
/* If D is non-NULL, call all functions registered with `__cxa_atexit'
with the same dso handle. Otherwise, if D is NULL, call all of the
registered handlers. */
/*
* Note, that original __cxa_finalize don't use lock, but use __exit_funcs
* i.e. global data.
*/
void __cxa_finalize(void *d)
{
struct exit_function_list *funcs;
#ifndef __FreeBSD__
pthread_mutex_lock( &lock );
#endif
for (funcs = __exit_funcs; funcs; funcs = funcs->next) {
struct exit_function *f;
for (f = &funcs->fns[funcs->idx - 1]; f >= &funcs->fns[0]; --f) {
if ( (d == NULL || d == f->func.cxa.dso_handle) && (f->flavor == ef_cxa) ) {
f->flavor = ef_free;
(*f->func.cxa.fn) (f->func.cxa.arg, 0);
}
}
}
/* Remove the registered fork handlers. We do not have to
unregister anything if the program is going to terminate anyway. */
#ifdef UNREGISTER_ATFORK
if (d != NULL)
UNREGISTER_ATFORK (d);
#endif
#ifndef __FreeBSD__
pthread_mutex_unlock( &lock );
#endif
}
/* __asm__ (".symver " "__cxa_finalize" "," "__cxa_finalize" "@@" "STLPORT_5_0_0"); */
/* void __cxa_finalize(void *d) __attribute__ ((weak)); */
#endif /* OS name */
#endif /* __unix */

Просмотреть файл

@ -1,387 +0,0 @@
/*
* Copyright (c) 1999
* Silicon Graphics Computer Systems, Inc.
*
* Copyright (c) 1999
* Boris Fomitchev
*
* This material is provided "as is", with absolutely no warranty expressed
* or implied. Any use is at your own risk.
*
* Permission to use or copy this software for any purpose is hereby granted
* without fee, provided the above notices are retained on all copies.
* Permission to modify the code and to distribute modified code is granted,
* provided the above notices are retained, and a notice that the code was
* modified is included with the above copyright notice.
*
*/
#if defined (__SUNPPRO_CC) && !defined (_STLP_NO_NEW_C_HEADERS)
# include <time.h>
// For sunpro, it chokes if time.h is included through stat.h
#endif
#include <fstream>
#ifdef __CYGWIN__
# define __int64 long long
#endif
#include <cstdio>
#if !defined(__ISCPP__)
extern "C" {
# include <sys/stat.h>
}
#endif
#if defined( __MSL__ )
# include <unix.h>
#endif
#if defined(__ISCPP__)
# include <c_locale_is/filestat.h>
#endif
#if defined(__BEOS__) && defined(__INTEL__)
# include <fcntl.h>
# include <sys/stat.h> // For _fstat
#endif
#if defined (_STLP_MSVC) || defined (__MINGW32__)
# include <fcntl.h>
# define S_IREAD _S_IREAD
# define S_IWRITE _S_IWRITE
# define S_IFREG _S_IFREG
// map permission masks
# ifndef S_IRUSR
# define S_IRUSR _S_IREAD
# define S_IWUSR _S_IWRITE
# endif
# ifndef S_IRGRP
# define S_IRGRP _S_IREAD
# define S_IWGRP _S_IWRITE
# endif
# ifndef S_IROTH
# define S_IROTH _S_IREAD
# define S_IWOTH _S_IWRITE
# endif
# ifndef O_RDONLY
# define O_RDONLY _O_RDONLY
# define O_WRONLY _O_WRONLY
# define O_RDWR _O_RDWR
# define O_APPEND _O_APPEND
# define O_CREAT _O_CREAT
# define O_TRUNC _O_TRUNC
# define O_TEXT _O_TEXT
# define O_BINARY _O_BINARY
# endif
# ifndef O_ACCMODE
# define O_ACCMODE (O_RDONLY|O_WRONLY|O_RDWR)
# endif
#endif
const _STLP_fd INVALID_STLP_FD = -1;
# ifdef __MSL__
# define _O_TEXT 0x0
# if !defined( O_TEXT )
# define O_TEXT _O_TEXT
# endif
# define _S_IFREG S_IFREG
# define S_IREAD S_IRUSR
# define S_IWRITE S_IWUSR
# define S_IEXEC S_IXUSR
# define _S_IWRITE S_IWRITE
# define _S_IREAD S_IREAD
# define _open open
# define _close close
# define _read read
# define _write write
# endif
_STLP_BEGIN_NAMESPACE
// Compare with streamoff definition in stl/char_traits.h!
#if defined (_STLP_USE_DEFAULT_FILE_OFFSET) || \
(!defined(_LARGEFILE_SOURCE) && !defined(_LARGEFILE64_SOURCE))
# define FOPEN fopen
# define FSEEK fseek
# define FSTAT fstat
# define STAT stat
# define FTELL ftell
#else
# define FOPEN fopen64
# define FSEEK fseeko64
# define FSTAT fstat64
# define STAT stat64
# define FTELL ftello64
#endif
_STLP_MOVE_TO_PRIV_NAMESPACE
// Helper functions for _Filebuf_base.
static bool __is_regular_file(_STLP_fd fd) {
struct STAT buf;
return FSTAT(fd, &buf) == 0 && (buf.st_mode & S_IFREG) != 0 ;
}
// Number of characters in the file.
static streamoff __file_size(_STLP_fd fd) {
streamoff ret = 0;
struct STAT buf;
if (FSTAT(fd, &buf) == 0 && (buf.st_mode & S_IFREG) != 0)
ret = buf.st_size > 0 ? buf.st_size : 0;
return ret;
}
_STLP_MOVE_TO_STD_NAMESPACE
// All version of Unix have mmap and lseek system calls. Some also have
// longer versions of those system calls to accommodate 64-bit offsets.
// If we're on a Unix system, define some macros to encapsulate those
// differences.
size_t _Filebuf_base::_M_page_size = 4096;
_Filebuf_base::_Filebuf_base()
: _M_file_id(INVALID_STLP_FD),
_M_openmode(0),
_M_is_open(false),
_M_should_close(false)
{}
void _Filebuf_base::_S_initialize()
{
}
// Return the size of the file. This is a wrapper for stat.
// Returns zero if the size cannot be determined or is ill-defined.
streamoff _Filebuf_base::_M_file_size()
{
return _STLP_PRIV __file_size(_M_file_id);
}
bool _Filebuf_base::_M_open(const char* name, ios_base::openmode openmode,
long permission)
{
_STLP_fd file_no;
if (_M_is_open)
return false;
// use FILE-based i/o
const char* flags;
switch (openmode & (~ios_base::ate)) {
case ios_base::out:
case ios_base::out | ios_base::trunc:
flags = "w";
break;
case ios_base::out | ios_base::binary:
case ios_base::out | ios_base::trunc | ios_base::binary:
flags = "wb";
break;
case ios_base::out | ios_base::app:
flags = "a";
break;
case ios_base::out | ios_base::app | ios_base::binary:
flags = "ab";
break;
case ios_base::in:
flags = "r";
break;
case ios_base::in | ios_base::binary:
flags = "rb";
break;
case ios_base::in | ios_base::out:
flags = "r+";
break;
case ios_base::in | ios_base::out | ios_base::binary:
flags = "r+b";
break;
case ios_base::in | ios_base::out | ios_base::trunc:
flags = "w+";
break;
case ios_base::in | ios_base::out | ios_base::trunc | ios_base::binary:
flags = "w+b";
break;
default: // The above are the only combinations of
return false; // flags allowed by the C++ standard.
}
// fbp : TODO : set permissions !
(void)permission; // currently unused //*TY 02/26/2000 - added to suppress warning message
_M_file = FOPEN(name, flags);
if (_M_file) {
file_no = fileno(_M_file);
} else {
return false;
}
// unset buffering immediately
setbuf(_M_file, 0);
_M_is_open = true;
if (openmode & ios_base::ate) {
if (FSEEK(_M_file, 0, SEEK_END) != 0)
_M_is_open = false;
}
_M_file_id = file_no;
_M_should_close = _M_is_open;
_M_openmode = openmode;
if (_M_is_open)
_M_regular_file = _STLP_PRIV __is_regular_file(_M_file_id);
return (_M_is_open != 0);
}
bool _Filebuf_base::_M_open(const char* name, ios_base::openmode openmode)
{
// This doesn't really grant everyone in the world read/write
// access. On Unix, file-creation system calls always clear
// bits that are set in the umask from the permissions flag.
return this->_M_open(name, openmode, S_IRUSR | S_IWUSR | S_IRGRP |
S_IWGRP | S_IROTH | S_IWOTH);
}
// Associated the filebuf with a file descriptor pointing to an already-
// open file. Mode is set to be consistent with the way that the file
// was opened.
bool _Filebuf_base::_M_open( int file_no, ios_base::openmode )
{
if (_M_is_open || file_no < 0)
return false;
struct STAT buf;
if (FSTAT(file_no, &buf) != 0)
return false;
int mode = buf.st_mode;
switch ( mode & (S_IWRITE | S_IREAD) ) {
case S_IREAD:
_M_openmode = ios_base::in;
break;
case S_IWRITE:
_M_openmode = ios_base::out;
break;
case (S_IWRITE | S_IREAD):
_M_openmode = ios_base::in | ios_base::out;
break;
default:
return false;
}
_M_file_id = file_no;
_M_is_open = true;
_M_should_close = false;
_M_regular_file = _STLP_PRIV __is_regular_file(_M_file_id);
return true;
}
bool _Filebuf_base::_M_close()
{
if (!_M_is_open)
return false;
bool ok = _M_should_close ? (fclose(_M_file) == 0) : true;
_M_is_open = _M_should_close = false;
_M_openmode = 0;
return ok;
}
// Read up to n characters into a buffer. Return value is number of
// characters read.
ptrdiff_t _Filebuf_base::_M_read(char* buf, ptrdiff_t n) {
return fread(buf, 1, n, _M_file);
}
// Write n characters from a buffer. Return value: true if we managed
// to write the entire buffer, false if we didn't.
bool _Filebuf_base::_M_write(char* buf, ptrdiff_t n)
{
for (;;) {
ptrdiff_t written = fwrite(buf, 1, n, _M_file);
if (n == written) {
return true;
}
if (written > 0 && written < n) {
n -= written;
buf += written;
} else {
return false;
}
}
}
// Wrapper for lseek or the like.
streamoff _Filebuf_base::_M_seek(streamoff offset, ios_base::seekdir dir)
{
int whence;
switch ( dir ) {
case ios_base::beg:
if (offset < 0 /* || offset > _M_file_size() */ )
return streamoff(-1);
whence = SEEK_SET;
break;
case ios_base::cur:
whence = SEEK_CUR;
break;
case ios_base::end:
if (/* offset > 0 || */ -offset > _M_file_size() )
return streamoff(-1);
whence = SEEK_END;
break;
default:
return streamoff(-1);
}
if ( FSEEK(_M_file, offset, whence) == 0 ) {
return FTELL(_M_file);
}
return streamoff(-1);
}
// Attempts to memory-map len bytes of the current file, starting
// at position offset. Precondition: offset is a multiple of the
// page size. Postcondition: return value is a null pointer if the
// memory mapping failed. Otherwise the return value is a pointer to
// the memory-mapped file and the file position is set to offset.
void *_Filebuf_base::_M_mmap(streamoff, streamoff )
{
return 0;
}
void _Filebuf_base::_M_unmap(void*, streamoff)
{
// precondition : there is a valid mapping at the moment
}
_STLP_END_NAMESPACE

Просмотреть файл

@ -1,347 +0,0 @@
/*
* Copyright (c) 1999
* Silicon Graphics Computer Systems, Inc.
*
* Copyright (c) 1999
* Boris Fomitchev
*
* This material is provided "as is", with absolutely no warranty expressed
* or implied. Any use is at your own risk.
*
* Permission to use or copy this software for any purpose is hereby granted
* without fee, provided the above notices are retained on all copies.
* Permission to modify the code and to distribute modified code is granted,
* provided the above notices are retained, and a notice that the code was
* modified is included with the above copyright notice.
*
*/
#if defined (__SUNPPRO_CC) && !defined (_STLP_NO_NEW_C_HEADERS)
# include <time.h>
// For sunpro, it chokes if time.h is included through stat.h
#endif
#include <fstream>
#ifdef __CYGWIN__
# define __int64 long long
#endif
extern "C" {
// open/close/read/write
#include <sys/stat.h> // For stat
#if !defined (_CRAY) && ! defined (__EMX__)
# include <sys/mman.h> // For mmap
#endif
// on HP-UX 11, this one contradicts with pthread.h on pthread_atfork, unless we unset this
#if defined (__hpux) && defined (__GNUC__)
# undef _INCLUDE_POSIX1C_SOURCE
#endif
#include <unistd.h>
#include <fcntl.h>
}
#ifdef __APPLE__
# include <sys/sysctl.h>
#endif
const _STLP_fd INVALID_STLP_FD = -1;
#ifndef O_ACCMODE
# define O_ACCMODE (O_RDONLY|O_WRONLY|O_RDWR)
#endif
// Compare with streamoff definition in stl/char_traits.h!
#if defined (_STLP_USE_DEFAULT_FILE_OFFSET) || \
(!defined(_LARGEFILE_SOURCE) && !defined (_LARGEFILE64_SOURCE))
# define FSTAT fstat
# define STAT stat
# define LSEEK lseek
# define MMAP mmap
# define OPEN open
#else
# define FSTAT fstat64
# define STAT stat64
# define LSEEK lseek64
# define MMAP mmap64
# define OPEN open64
#endif
#ifndef MAP_FAILED /* MMAP failure return code */
# define MAP_FAILED -1
#endif
_STLP_BEGIN_NAMESPACE
static ios_base::openmode flag_to_openmode(int mode)
{
ios_base::openmode ret = ios_base::__default_mode;
switch ( mode & O_ACCMODE ) {
case O_RDONLY:
ret = ios_base::in;
break;
case O_WRONLY:
ret = ios_base::out;
break;
case O_RDWR:
ret = ios_base::in | ios_base::out;
break;
}
if ( mode & O_APPEND )
ret |= ios_base::app;
return ret;
}
_STLP_MOVE_TO_PRIV_NAMESPACE
// Helper functions for _Filebuf_base.
static bool __is_regular_file(_STLP_fd fd) {
struct STAT buf;
return FSTAT(fd, &buf) == 0 && S_ISREG(buf.st_mode);
}
// Number of characters in the file.
static streamoff __file_size(_STLP_fd fd) {
streamoff ret = 0;
struct STAT buf;
if (FSTAT(fd, &buf) == 0 && S_ISREG(buf.st_mode))
ret = buf.st_size > 0 ? buf.st_size : 0;
return ret;
}
_STLP_MOVE_TO_STD_NAMESPACE
size_t _Filebuf_base::_M_page_size = 4096;
_Filebuf_base::_Filebuf_base()
: _M_file_id(INVALID_STLP_FD),
_M_openmode(0),
_M_is_open(false),
_M_should_close(false)
{}
void _Filebuf_base::_S_initialize()
{
#if defined (__APPLE__)
int mib[2];
size_t pagesize, len;
mib[0] = CTL_HW;
mib[1] = HW_PAGESIZE;
len = sizeof(pagesize);
sysctl(mib, 2, &pagesize, &len, NULL, 0);
_M_page_size = pagesize;
#elif defined (__DJGPP) && defined (_CRAY)
_M_page_size = BUFSIZ;
#else
_M_page_size = sysconf(_SC_PAGESIZE);
#endif
}
// Return the size of the file. This is a wrapper for stat.
// Returns zero if the size cannot be determined or is ill-defined.
streamoff _Filebuf_base::_M_file_size()
{
return _STLP_PRIV __file_size(_M_file_id);
}
bool _Filebuf_base::_M_open(const char* name, ios_base::openmode openmode,
long permission)
{
_STLP_fd file_no;
if (_M_is_open)
return false;
int flags = 0;
// Unix makes no distinction between text and binary files.
switch ( openmode & (~ios_base::ate & ~ios_base::binary) ) {
case ios_base::out:
case ios_base::out | ios_base::trunc:
flags = O_WRONLY | O_CREAT | O_TRUNC;
break;
case ios_base::app:
case ios_base::out | ios_base::app:
flags = O_WRONLY | O_CREAT | O_APPEND;
break;
case ios_base::in:
flags = O_RDONLY;
permission = 0; // Irrelevant unless we're writing.
break;
case ios_base::in | ios_base::out:
flags = O_RDWR;
break;
case ios_base::in | ios_base::out | ios_base::trunc:
flags = O_RDWR | O_CREAT | O_TRUNC;
break;
case ios_base::in | ios_base::app:
case ios_base::in | ios_base::out | ios_base::app:
flags = O_RDWR | O_CREAT | O_APPEND;
break;
default: // The above are the only combinations of
return false; // flags allowed by the C++ standard.
}
file_no = OPEN(name, flags, permission);
if (file_no < 0)
return false;
_M_is_open = true;
if ((openmode & (ios_base::ate | ios_base::app)) && (LSEEK(file_no, 0, SEEK_END) == -1)) {
_M_is_open = false;
}
_M_file_id = file_no;
_M_should_close = _M_is_open;
_M_openmode = openmode;
if (_M_is_open)
_M_regular_file = _STLP_PRIV __is_regular_file(_M_file_id);
return (_M_is_open != 0);
}
bool _Filebuf_base::_M_open(const char* name, ios_base::openmode openmode)
{
// This doesn't really grant everyone in the world read/write
// access. On Unix, file-creation system calls always clear
// bits that are set in the umask from the permissions flag.
return this->_M_open(name, openmode, S_IRUSR | S_IWUSR | S_IRGRP |
S_IWGRP | S_IROTH | S_IWOTH);
}
// Associated the filebuf with a file descriptor pointing to an already-
// open file. Mode is set to be consistent with the way that the file
// was opened.
bool _Filebuf_base::_M_open(int file_no, ios_base::openmode)
{
if (_M_is_open || file_no < 0)
return false;
int mode = fcntl(file_no, F_GETFL);
if (mode == -1)
return false;
_M_openmode = flag_to_openmode(mode);
_M_file_id = file_no;
_M_is_open = true;
_M_should_close = false;
_M_regular_file = _STLP_PRIV __is_regular_file(_M_file_id);
return true;
}
bool _Filebuf_base::_M_close()
{
if (!_M_is_open)
return false;
bool ok = _M_should_close ? (close(_M_file_id) == 0) : true;
_M_is_open = _M_should_close = false;
_M_openmode = 0;
return ok;
}
// Read up to n characters into a buffer. Return value is number of
// characters read.
ptrdiff_t _Filebuf_base::_M_read(char* buf, ptrdiff_t n)
{
return read(_M_file_id, buf, n);
}
// Write n characters from a buffer. Return value: true if we managed
// to write the entire buffer, false if we didn't.
bool _Filebuf_base::_M_write(char* buf, ptrdiff_t n)
{
for (;;) {
ptrdiff_t written = write(_M_file_id, buf, n);
if (n == written) {
return true;
}
if (written > 0 && written < n) {
n -= written;
buf += written;
} else {
return false;
}
}
}
// Wrapper for lseek or the like.
streamoff _Filebuf_base::_M_seek(streamoff offset, ios_base::seekdir dir)
{
int whence;
switch ( dir ) {
case ios_base::beg:
if (offset < 0 /* || offset > _M_file_size() */ )
return streamoff(-1);
whence = SEEK_SET;
break;
case ios_base::cur:
whence = SEEK_CUR;
break;
case ios_base::end:
if (/* offset > 0 || */ -offset > _M_file_size() )
return streamoff(-1);
whence = SEEK_END;
break;
default:
return streamoff(-1);
}
return LSEEK(_M_file_id, offset, whence);
}
// Attempts to memory-map len bytes of the current file, starting
// at position offset. Precondition: offset is a multiple of the
// page size. Postcondition: return value is a null pointer if the
// memory mapping failed. Otherwise the return value is a pointer to
// the memory-mapped file and the file position is set to offset.
void* _Filebuf_base::_M_mmap(streamoff offset, streamoff len)
{
void* base;
#if !defined (__DJGPP) && !defined (_CRAY)
base = MMAP(0, len, PROT_READ, MAP_PRIVATE, _M_file_id, offset);
if (base != (void*)MAP_FAILED) {
if (LSEEK(_M_file_id, offset + len, SEEK_SET) < 0) {
this->_M_unmap(base, len);
base = 0;
}
} else
base =0;
#else
_STLP_MARK_PARAMETER_AS_UNUSED(&offset)
_STLP_MARK_PARAMETER_AS_UNUSED(&len)
base = 0;
#endif
return base;
}
void _Filebuf_base::_M_unmap(void* base, streamoff len)
{
// precondition : there is a valid mapping at the moment
#if !defined (__DJGPP) && !defined (_CRAY)
munmap((char*)base, len);
#else
_STLP_MARK_PARAMETER_AS_UNUSED(&len)
_STLP_MARK_PARAMETER_AS_UNUSED(base)
#endif
}
_STLP_END_NAMESPACE

Просмотреть файл

@ -1,629 +0,0 @@
/*
* Copyright (c) 1999
* Silicon Graphics Computer Systems, Inc.
*
* Copyright (c) 1999
* Boris Fomitchev
*
* This material is provided "as is", with absolutely no warranty expressed
* or implied. Any use is at your own risk.
*
* Permission to use or copy this software for any purpose is hereby granted
* without fee, provided the above notices are retained on all copies.
* Permission to modify the code and to distribute modified code is granted,
* provided the above notices are retained, and a notice that the code was
* modified is included with the above copyright notice.
*
*/
#include <fstream>
#if !defined (_STLP_WCE)
# ifdef __BORLANDC__
# include <cfcntl.h> // For _O_RDONLY, etc
# else
# include <io.h> // For _get_osfhandle
# include <fcntl.h> // For _O_RDONLY, etc
# endif
# include <sys/stat.h> // For _fstat
#endif
#define _TEXTBUF_SIZE 0x1000
const _STLP_fd INVALID_STLP_FD = INVALID_HANDLE_VALUE;
#if !defined (INVALID_SET_FILE_POINTER)
# define INVALID_SET_FILE_POINTER 0xffffffff
#endif
#ifndef O_ACCMODE
# define O_ACCMODE (O_RDONLY|O_WRONLY|O_RDWR)
#endif
_STLP_BEGIN_NAMESPACE
#if !defined(__MSL__) && !defined(_STLP_WCE)
static ios_base::openmode flag_to_openmode(int mode) {
ios_base::openmode ret = ios_base::__default_mode;
switch (mode & O_ACCMODE) {
case O_RDONLY:
ret = ios_base::in; break;
case O_WRONLY:
ret = ios_base::out; break;
case O_RDWR:
ret = ios_base::in | ios_base::out; break;
}
if (mode & O_APPEND)
ret |= ios_base::app;
if (mode & O_BINARY)
ret |= ios_base::binary;
return ret;
}
#endif
_STLP_MOVE_TO_PRIV_NAMESPACE
// Helper functions for _Filebuf_base.
static bool __is_regular_file(_STLP_fd fd) {
BY_HANDLE_FILE_INFORMATION info;
// Return true if the file handle isn't a directory.
return GetFileInformationByHandle(fd, &info) &&
((info.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0);
}
// Number of characters in the file.
static streamoff __file_size(_STLP_fd fd) {
streamoff ret = 0;
LARGE_INTEGER li;
li.LowPart = GetFileSize(fd, (unsigned long*) &li.HighPart);
if (li.LowPart != INVALID_FILE_SIZE || GetLastError() == NO_ERROR)
ret = li.QuadPart;
return ret;
}
_STLP_MOVE_TO_STD_NAMESPACE
// Visual C++ and Intel use this, but not Metrowerks
// Also MinGW, msvcrt.dll (but not crtdll.dll) dependent version
#if (defined (_STLP_MSVC_LIB) && !defined (_STLP_WCE)) || \
(defined (__MINGW32__) && defined (__MSVCRT__))
// fcntl(fileno, F_GETFL) for Microsoft library
// 'semi-documented' defines:
# define IOINFO_L2E 5
# define IOINFO_ARRAY_ELTS (1 << IOINFO_L2E)
# define _pioinfo(i) ( __pioinfo[(i) >> IOINFO_L2E] + \
((i) & (IOINFO_ARRAY_ELTS - 1)) )
# define FAPPEND 0x20 // O_APPEND flag
# define FTEXT 0x80 // O_TEXT flag
// end of 'semi-documented' defines
// 'semi-documented' internal structure
extern "C" {
struct ioinfo {
long osfhnd; // the real os HANDLE
char osfile; // file handle flags
char pipech; // pipe buffer
# if defined (_MT)
// multi-threaded locking
int lockinitflag;
CRITICAL_SECTION lock;
# endif
};
# if defined (__MINGW32__)
__MINGW_IMPORT ioinfo * __pioinfo[];
# else
extern _CRTIMP ioinfo * __pioinfo[];
# endif
} // extern "C"
// end of 'semi-documented' declarations
static ios_base::openmode _get_osfflags(int fd, HANDLE oshandle) {
char dosflags = 0;
if (fd >= 0)
dosflags = _pioinfo(fd)->osfile;
//else
//the file will be considered as open in binary mode with no append attribute
// end of 'semi-documented' stuff
int mode = 0;
if (dosflags & FAPPEND)
mode |= O_APPEND;
if (dosflags & FTEXT)
mode |= O_TEXT;
else
mode |= O_BINARY;
// For Read/Write access we have to guess
DWORD dummy, dummy2;
BOOL writeOk = WriteFile(oshandle, &dummy2, 0, &dummy, 0);
BOOL readOk = ReadFile(oshandle, &dummy2, 0, &dummy, NULL);
if (writeOk && readOk)
mode |= O_RDWR;
else if (readOk)
mode |= O_RDONLY;
else
mode |= O_WRONLY;
return flag_to_openmode(mode);
}
#elif defined (__DMC__)
# define FHND_APPEND 0x04
# define FHND_DEVICE 0x08
# define FHND_TEXT 0x10
extern "C" unsigned char __fhnd_info[_NFILE];
static ios_base::openmode _get_osfflags(int fd, HANDLE oshandle) {
int mode = 0;
if (__fhnd_info[fd] & FHND_APPEND)
mode |= O_APPEND;
if (__fhnd_info[fd] & FHND_TEXT == 0)
mode |= O_BINARY;
for (FILE *fp = &_iob[0]; fp < &_iob[_NFILE]; fp++) {
if ((fileno(fp) == fd) && (fp->_flag & (_IOREAD | _IOWRT | _IORW))) {
const int osflags = fp->_flag;
if ((osflags & _IOREAD) && !(osflags & _IOWRT) && !(osflags & _IORW))
mode |= O_RDONLY;
else if ((osflags & _IOWRT) && !(osflags & _IOREAD) && !(osflags & _IORW))
mode |= O_WRONLY;
else
mode |= O_RDWR;
break;
}
}
return flag_to_openmode(mode);
}
#endif
size_t _Filebuf_base::_M_page_size = 4096;
_Filebuf_base::_Filebuf_base()
: _M_file_id(INVALID_STLP_FD),
_M_openmode(0),
_M_is_open(false),
_M_should_close(false),
_M_view_id(0)
{}
void _Filebuf_base::_S_initialize() {
SYSTEM_INFO SystemInfo;
GetSystemInfo(&SystemInfo);
_M_page_size = SystemInfo.dwPageSize;
// might be .dwAllocationGranularity
}
// Return the size of the file. This is a wrapper for stat.
// Returns zero if the size cannot be determined or is ill-defined.
streamoff _Filebuf_base::_M_file_size() {
return _STLP_PRIV __file_size(_M_file_id);
}
bool _Filebuf_base::_M_open(const char* name, ios_base::openmode openmode,
long permission) {
_STLP_fd file_no;
if (_M_is_open)
return false;
DWORD dwDesiredAccess, dwCreationDisposition;
bool doTruncate = false;
switch (openmode & (~ios_base::ate & ~ios_base::binary)) {
case ios_base::out:
case ios_base::out | ios_base::trunc:
dwDesiredAccess = GENERIC_WRITE;
dwCreationDisposition = OPEN_ALWAYS;
// boris : even though it is very non-intuitive, standard
// requires them both to behave same.
doTruncate = true;
break;
case ios_base::out | ios_base::app:
dwDesiredAccess = GENERIC_WRITE;
dwCreationDisposition = OPEN_ALWAYS;
break;
case ios_base::in:
dwDesiredAccess = GENERIC_READ;
dwCreationDisposition = OPEN_EXISTING;
permission = 0; // Irrelevant unless we're writing.
break;
case ios_base::in | ios_base::out:
dwDesiredAccess = GENERIC_READ | GENERIC_WRITE;
dwCreationDisposition = OPEN_EXISTING;
break;
case ios_base::in | ios_base::out | ios_base::trunc:
dwDesiredAccess = GENERIC_READ | GENERIC_WRITE;
dwCreationDisposition = OPEN_ALWAYS;
doTruncate = true;
break;
default: // The above are the only combinations of
return false; // flags allowed by the C++ standard.
}
DWORD dwShareMode = FILE_SHARE_READ | FILE_SHARE_WRITE;
#if defined(_STLP_USE_WIDE_INTERFACE)
file_no = CreateFile (_STLP_PRIV __ASCIIToWide(name).c_str(),
#else
file_no = CreateFileA(name,
#endif
dwDesiredAccess, dwShareMode, 0,
dwCreationDisposition, permission, 0);
if (file_no == INVALID_STLP_FD)
return false;
if (
#if !defined (_STLP_WCE)
GetFileType(file_no) == FILE_TYPE_DISK &&
#endif
((doTruncate && SetEndOfFile(file_no) == 0) ||
(((openmode & ios_base::ate) != 0) &&
(SetFilePointer(file_no, 0, NULL, FILE_END) == INVALID_SET_FILE_POINTER)))) {
CloseHandle(file_no);
return false;
}
_M_is_open = true;
_M_file_id = file_no;
_M_should_close = _M_is_open;
_M_openmode = openmode;
if (_M_is_open)
_M_regular_file = _STLP_PRIV __is_regular_file(_M_file_id);
return (_M_is_open != 0);
}
bool _Filebuf_base::_M_open(const char* name, ios_base::openmode openmode) {
// This doesn't really grant everyone in the world read/write
// access. On Unix, file-creation system calls always clear
// bits that are set in the umask from the permissions flag.
return this->_M_open(name, openmode, FILE_ATTRIBUTE_NORMAL);
}
bool _Filebuf_base::_M_open(_STLP_fd __id, ios_base::openmode init_mode) {
#if (defined (_STLP_MSVC_LIB) && !defined (_STLP_WCE)) || \
(defined (__MINGW32__) && defined (__MSVCRT__)) || defined (__DMC__)
if (_M_is_open || __id == INVALID_STLP_FD)
return false;
if (init_mode != ios_base::__default_mode)
_M_openmode = init_mode;
else
_M_openmode = _get_osfflags(-1, __id);
_M_is_open = true;
_M_file_id = __id;
_M_should_close = false;
_M_regular_file = _STLP_PRIV __is_regular_file(_M_file_id);
return true;
#else
(void)__id;
(void)init_mode; // dwa 4/27/00 - suppress unused parameter warning
// not available for the API
return false;
#endif
}
// Associated the filebuf with a file descriptor pointing to an already-
// open file. Mode is set to be consistent with the way that the file
// was opened.
bool _Filebuf_base::_M_open(int file_no, ios_base::openmode init_mode) {
if (_M_is_open || file_no < 0)
return false;
#if (defined (_STLP_MSVC_LIB) && !defined (_STLP_WCE)) || \
(defined (__MINGW32__) && defined (__MSVCRT__)) || defined (__DMC__)
HANDLE oshandle = (HANDLE)_get_osfhandle(file_no);
if (oshandle == INVALID_STLP_FD)
return false;
if (init_mode != ios_base::__default_mode)
_M_openmode = init_mode;
else
_M_openmode = _get_osfflags(file_no, oshandle);
_M_file_id = oshandle;
_M_is_open = true;
_M_should_close = false;
_M_regular_file = _STLP_PRIV __is_regular_file(_M_file_id);
return true;
#else
_STLP_MARK_PARAMETER_AS_UNUSED(&init_mode)
// not available for the API
return false;
#endif
}
bool _Filebuf_base::_M_close() {
if (!_M_is_open)
return false;
bool ok;
if (!_M_should_close)
ok = true;
else {
if (_M_file_id != INVALID_STLP_FD) {
ok = (CloseHandle(_M_file_id) != 0);
}
else {
ok = false;
}
}
_M_is_open = _M_should_close = false;
_M_openmode = 0;
return ok;
}
#define _STLP_LF 10
#define _STLP_CR 13
#define _STLP_CTRLZ 26
// Read up to n characters into a buffer. Return value is number of
// characters read.
ptrdiff_t _Filebuf_base::_M_read(char* buf, ptrdiff_t n) {
ptrdiff_t readen = 0;
//Here cast to size_t is safe as n cannot be negative.
size_t chunkSize = (min)(size_t(0xffffffff), __STATIC_CAST(size_t, n));
// The following, while validating that we are still able to extract chunkSize
// charaters to the buffer, avoids extraction of too small chunk of datas
// which would be counter performant.
while (__STATIC_CAST(size_t, (n - readen)) >= chunkSize) {
DWORD numberOfBytesRead;
ReadFile(_M_file_id, buf + readen, __STATIC_CAST(DWORD, chunkSize), &numberOfBytesRead, 0);
if (numberOfBytesRead == 0)
break;
if (!(_M_openmode & ios_base::binary)) {
// translate CR-LFs to LFs in the buffer
char *to = buf + readen;
char *from = to;
char *last = from + numberOfBytesRead - 1;
for (; from <= last && *from != _STLP_CTRLZ; ++from) {
if (*from != _STLP_CR)
*to++ = *from;
else { // found CR
if (from < last) { // not at buffer end
if (*(from + 1) != _STLP_LF)
*to++ = _STLP_CR;
}
else { // last char is CR, peek for LF
char peek = ' ';
DWORD NumberOfBytesPeeked;
ReadFile(_M_file_id, (LPVOID)&peek, 1, &NumberOfBytesPeeked, 0);
if (NumberOfBytesPeeked != 0) {
if (peek != _STLP_LF) { //not a <CR><LF> combination
*to++ = _STLP_CR;
if ((to < buf + n) && (peek != _STLP_CR))
//We have enough place to store peek and it is no a special
//_STLP_CR character, we can store it.
*to++ = peek;
else
SetFilePointer(_M_file_id, (LONG)-1, 0, FILE_CURRENT);
}
else {
// A <CR><LF> combination, we keep the <LF>:
*to++ = _STLP_LF;
}
}
else {
/* This case is tedious, we could
* - put peek back in the file but this would then generate an infinite loop
* - report an error as we don't know if in a future call to ReadFile we won't then
* get a <LF>. Doing so would make all files with a <CR> last an invalid file
* for STLport, a hard solution for STLport clients.
* - store the <CR> in the returned buffer, the chosen solution, even if in this
* case we could miss a <CR><LF> combination.
*/
*to++ = _STLP_CR;
}
}
} // found CR
} // for
readen = to - buf;
// seek back to TEXT end of file if hit CTRL-Z
if (from <= last) { // terminated due to CTRLZ
SetFilePointer(_M_file_id, -(LONG)((last + 1) - from), 0, FILE_CURRENT);
break;
}
}
else
readen += numberOfBytesRead;
}
return readen;
}
// Write n characters from a buffer. Return value: true if we managed
// to write the entire buffer, false if we didn't.
bool _Filebuf_base::_M_write(char* buf, ptrdiff_t n) {
for (;;) {
ptrdiff_t written;
//In the following implementation we are going to cast most of the ptrdiff_t
//values in size_t to work with coherent unsigned values. Doing so make code
//more simple especially in the min function call.
// In append mode, every write does an implicit seek to the end
// of the file.
if (_M_openmode & ios_base::app)
_M_seek(0, ios_base::end);
if (_M_openmode & ios_base::binary) {
// binary mode
size_t bytes_to_write = (size_t)n;
DWORD NumberOfBytesWritten;
written = 0;
for (; bytes_to_write != 0;) {
WriteFile(_M_file_id, buf + written,
__STATIC_CAST(DWORD, (min)(size_t(0xffffffff), bytes_to_write)),
&NumberOfBytesWritten, 0);
if (NumberOfBytesWritten == 0)
return false;
bytes_to_write -= NumberOfBytesWritten;
written += NumberOfBytesWritten;
}
}
else {
char textbuf[_TEXTBUF_SIZE + 1]; // extra 1 in case LF at end
char * nextblock = buf, * ptrtextbuf = textbuf;
char * endtextbuf = textbuf + _TEXTBUF_SIZE;
char * endblock = buf + n;
ptrdiff_t nextblocksize = (min) (n, (ptrdiff_t)_TEXTBUF_SIZE);
char * nextlf;
while ( (nextblocksize > 0) &&
(nextlf = (char *)memchr(nextblock, _STLP_LF, nextblocksize)) != 0) {
ptrdiff_t linelength = nextlf - nextblock;
memcpy(ptrtextbuf, nextblock, linelength);
ptrtextbuf += linelength;
nextblock += (linelength + 1);
* ptrtextbuf ++ = _STLP_CR;
* ptrtextbuf ++ = _STLP_LF;
nextblocksize = (min) (ptrdiff_t(endblock - nextblock),
(max) (ptrdiff_t(0), ptrdiff_t(endtextbuf - ptrtextbuf)));
}
// write out what's left, > condition is here since for LF at the end ,
// endtextbuf may get < ptrtextbuf ...
if (nextblocksize > 0) {
memcpy(ptrtextbuf, nextblock, nextblocksize);
ptrtextbuf += nextblocksize;
nextblock += nextblocksize;
}
// now write out the translated buffer
char * writetextbuf = textbuf;
for (size_t NumberOfBytesToWrite = (size_t)(ptrtextbuf - textbuf);
NumberOfBytesToWrite;) {
DWORD NumberOfBytesWritten;
WriteFile((HANDLE)_M_file_id, writetextbuf,
__STATIC_CAST(DWORD, (min)(size_t(0xffffffff), NumberOfBytesToWrite)),
&NumberOfBytesWritten, 0);
if (!NumberOfBytesWritten) // write shortfall
return false;
writetextbuf += NumberOfBytesWritten;
NumberOfBytesToWrite -= NumberOfBytesWritten;
}
// count non-translated characters
written = (nextblock - buf);
}
if (n == written)
return true;
else if (written > 0 && written < n) {
n -= written;
buf += written;
}
else
return false;
}
}
// Wrapper for lseek or the like.
streamoff _Filebuf_base::_M_seek(streamoff offset, ios_base::seekdir dir) {
streamoff result = -1;
int whence;
switch(dir) {
case ios_base::beg:
if (offset < 0 /* || offset > _M_file_size() */ )
return streamoff(-1);
whence = FILE_BEGIN;
break;
case ios_base::cur:
whence = FILE_CURRENT;
break;
case ios_base::end:
if (/* offset > 0 || */ -offset > _M_file_size() )
return streamoff(-1);
whence = FILE_END;
break;
default:
return streamoff(-1);
}
LARGE_INTEGER li;
li.QuadPart = offset;
li.LowPart = SetFilePointer(_M_file_id, li.LowPart, &li.HighPart, whence);
if (li.LowPart != INVALID_SET_FILE_POINTER || GetLastError() == NO_ERROR)
result = li.QuadPart;
return result;
}
// Attempts to memory-map len bytes of the current file, starting
// at position offset. Precondition: offset is a multiple of the
// page size. Postcondition: return value is a null pointer if the
// memory mapping failed. Otherwise the return value is a pointer to
// the memory-mapped file and the file position is set to offset.
void* _Filebuf_base::_M_mmap(streamoff offset, streamoff len) {
void* base;
_M_view_id = CreateFileMapping(_M_file_id, (PSECURITY_ATTRIBUTES)0 ,
PAGE_READONLY, 0 /* len >> 32 */ ,
0 /* len & 0xFFFFFFFF */ , // low-order DWORD of size
0);
if (_M_view_id) {
#if 0
/*
printf("view %x created from file %x, error = %d, size = %d, map_offset = %d map_len = %d\n",
_M_view_id, _M_file_id, GetLastError(),
(int)cur_filesize, ULL(offset) & 0xffffffff, len);
*/
#endif
LARGE_INTEGER li;
li.QuadPart = offset;
base = MapViewOfFile(_M_view_id, FILE_MAP_READ, li.HighPart, li.LowPart,
#if !defined (__DMC__)
__STATIC_CAST(SIZE_T, len));
#else
__STATIC_CAST(DWORD, len));
#endif
// check if mapping succeded and is usable
if (base == 0 || _M_seek(offset + len, ios_base::beg) < 0) {
this->_M_unmap(base, len);
base = 0;
}
} else
base = 0;
return base;
}
void _Filebuf_base::_M_unmap(void* base, streamoff len) {
// precondition : there is a valid mapping at the moment
if (base != NULL)
UnmapViewOfFile(base);
// destroy view handle as well
if (_M_view_id != NULL)
CloseHandle(_M_view_id);
_M_view_id = NULL;
(void)len; //unused variable
}
_STLP_END_NAMESPACE

Просмотреть файл

@ -1,262 +0,0 @@
/*
*
* Copyright (c) 1994
* Hewlett-Packard Company
*
* Copyright (c) 1996,1997
* Silicon Graphics Computer Systems, Inc.
*
* Copyright (c) 1997
* Moscow Center for SPARC Technology
*
* Copyright (c) 1999
* Boris Fomitchev
*
* This material is provided "as is", with absolutely no warranty expressed
* or implied. Any use is at your own risk.
*
* Permission to use or copy this software for any purpose is hereby granted
* without fee, provided the above notices are retained on all copies.
* Permission to modify the code and to distribute modified code is granted,
* provided the above notices are retained, and a notice that the code was
* modified is included with the above copyright notice.
*
*/
#define _STLP_EXPOSE_GLOBALS_IMPLEMENTATION
#include "stlport_prefix.h"
#if !defined (_STLP_DEBUG) && ! defined (_STLP_ASSERTIONS)
# if !defined (__APPLE__) || !defined (__GNUC__) || (__GNUC__ < 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ < 3))
/* dums: Please if the following code was being uncommented please explain why
* as for the moment it only looks like a source of inconsistency in the way
* STLport different translation units are compiled.
*/
//# define _STLP_ASSERTIONS 1
# endif
#endif
#include <utility>
#include <memory>
#include <vector>
#include <set>
#include <list>
#include <slist>
#include <deque>
#include <hash_map>
#include <limits>
#include <string>
#include <stdexcept>
#include <bitset>
#include <locale>
#if defined (__DMC__)
// for rope static members
# include <rope>
#endif
#include <stl/_range_errors.c>
_STLP_BEGIN_NAMESPACE
#if defined (_STLP_NO_EXCEPTION_HEADER) || defined (_STLP_BROKEN_EXCEPTION_CLASS)
exception::exception() _STLP_NOTHROW {}
exception::~exception() _STLP_NOTHROW {}
bad_exception::bad_exception() _STLP_NOTHROW {}
bad_exception::~bad_exception() _STLP_NOTHROW {}
const char* exception::what() const _STLP_NOTHROW { return "class exception"; }
const char* bad_exception::what() const _STLP_NOTHROW { return "class bad_exception"; }
#endif
#if defined (_STLP_OWN_STDEXCEPT)
# include <stl/_stdexcept_base.c>
// boris : those are needed to force typeinfo nodes to be created in here only
logic_error::~logic_error() _STLP_NOTHROW_INHERENTLY {}
runtime_error::~runtime_error() _STLP_NOTHROW_INHERENTLY {}
domain_error::~domain_error() _STLP_NOTHROW_INHERENTLY {}
invalid_argument::~invalid_argument() _STLP_NOTHROW_INHERENTLY {}
length_error::~length_error() _STLP_NOTHROW_INHERENTLY {}
out_of_range::~out_of_range() _STLP_NOTHROW_INHERENTLY {}
range_error::~range_error() _STLP_NOTHROW_INHERENTLY {}
overflow_error::~overflow_error() _STLP_NOTHROW_INHERENTLY {}
underflow_error::~underflow_error() _STLP_NOTHROW_INHERENTLY {}
#endif
#if !defined(_STLP_WCE_EVC3)
# if defined (_STLP_NO_BAD_ALLOC)
const nothrow_t nothrow /* = {} */;
# endif
#endif
#if !defined (_STLP_NO_FORCE_INSTANTIATE)
# if defined (_STLP_DEBUG) || defined (_STLP_ASSERTIONS)
_STLP_MOVE_TO_PRIV_NAMESPACE
template class _STLP_CLASS_DECLSPEC __stl_debug_engine<bool>;
_STLP_MOVE_TO_STD_NAMESPACE
# endif
template class _STLP_CLASS_DECLSPEC __debug_alloc<__node_alloc>;
template class _STLP_CLASS_DECLSPEC __debug_alloc<__new_alloc>;
//Export of the types used to represent buckets in the hashtable implementation.
/*
* For the vector class we do not use any MSVC6 workaround even if we export it from
* the STLport dynamic libraries because we know what methods are called and none is
* a template method. Moreover the exported class is an instanciation of vector with
* _Slist_node_base struct that is an internal STLport class that no user should ever
* use.
*/
# if !defined (_STLP_USE_PTR_SPECIALIZATIONS)
template class _STLP_CLASS_DECLSPEC allocator<_STLP_PRIV _Slist_node_base*>;
_STLP_MOVE_TO_PRIV_NAMESPACE
template class _STLP_CLASS_DECLSPEC _STLP_alloc_proxy<_Slist_node_base**, _Slist_node_base*,
allocator<_Slist_node_base*> >;
template class _STLP_CLASS_DECLSPEC _Vector_base<_Slist_node_base*,
allocator<_Slist_node_base*> >;
_STLP_MOVE_TO_STD_NAMESPACE
# endif
# if defined (_STLP_DEBUG)
_STLP_MOVE_TO_PRIV_NAMESPACE
template class _STLP_CLASS_DECLSPEC _STLP_NON_DBG_NAME(vector)<_Slist_node_base*,
allocator<_Slist_node_base*> >;
_STLP_MOVE_TO_STD_NAMESPACE
# endif
template class _STLP_CLASS_DECLSPEC vector<_STLP_PRIV _Slist_node_base*,
allocator<_STLP_PRIV _Slist_node_base*> >;
//End of hashtable bucket types export.
//Export of _Locale_impl facets container:
# if !defined (_STLP_USE_PTR_SPECIALIZATIONS)
template class _STLP_CLASS_DECLSPEC allocator<locale::facet*>;
_STLP_MOVE_TO_PRIV_NAMESPACE
template class _STLP_CLASS_DECLSPEC _STLP_alloc_proxy<locale::facet**, locale::facet*, allocator<locale::facet*> >;
template class _STLP_CLASS_DECLSPEC _Vector_base<locale::facet*, allocator<locale::facet*> >;
_STLP_MOVE_TO_STD_NAMESPACE
# endif
# if defined (_STLP_DEBUG)
_STLP_MOVE_TO_PRIV_NAMESPACE
# define _STLP_NON_DBG_VECTOR _STLP_NON_DBG_NAME(vector)
template class _STLP_CLASS_DECLSPEC __construct_checker<_STLP_PRIV _STLP_NON_DBG_VECTOR<locale::facet*, allocator<locale::facet*> > >;
template class _STLP_CLASS_DECLSPEC _STLP_NON_DBG_VECTOR<locale::facet*, allocator<locale::facet*> >;
# undef _STLP_NON_DBG_VECTOR
_STLP_MOVE_TO_STD_NAMESPACE
# endif
template class _STLP_CLASS_DECLSPEC vector<locale::facet*, allocator<locale::facet*> >;
//End of export of _Locale_impl facets container.
# if defined (_STLP_USE_PTR_SPECIALIZATIONS)
template class _STLP_CLASS_DECLSPEC allocator<void*>;
typedef _STLP_PRIV _List_node<void*> _VoidPtr_Node;
template class _STLP_CLASS_DECLSPEC allocator<_VoidPtr_Node>;
_STLP_MOVE_TO_PRIV_NAMESPACE
template class _STLP_CLASS_DECLSPEC _STLP_alloc_proxy<void**, void*, allocator<void*> >;
template class _STLP_CLASS_DECLSPEC _Vector_base<void*, allocator<void*> >;
template class _STLP_CLASS_DECLSPEC _STLP_PTR_IMPL_NAME(vector)<void*, allocator<void*> >;
template class _STLP_CLASS_DECLSPEC _List_node<void*>;
template class _STLP_CLASS_DECLSPEC _STLP_alloc_proxy<_List_node_base, _VoidPtr_Node, allocator<_VoidPtr_Node> >;
template class _STLP_CLASS_DECLSPEC _List_base<void*, allocator<void*> >;
template class _STLP_CLASS_DECLSPEC _STLP_PTR_IMPL_NAME(list)<void*, allocator<void*> >;
template class _STLP_CLASS_DECLSPEC _Slist_node<void*>;
template class _STLP_CLASS_DECLSPEC _STLP_alloc_proxy<_Slist_node_base, _Slist_node<void*>, allocator<_Slist_node<void*> > >;
template class _STLP_CLASS_DECLSPEC _Slist_base<void*, allocator<void*> >;
template class _STLP_CLASS_DECLSPEC _STLP_PTR_IMPL_NAME(slist)<void*, allocator<void*> >;
template class _STLP_CLASS_DECLSPEC _STLP_alloc_proxy<size_t, void*, allocator<void*> >;
template class _STLP_CLASS_DECLSPEC _STLP_alloc_proxy<void***, void**, allocator<void**> >;
template struct _STLP_CLASS_DECLSPEC _Deque_iterator<void*, _Nonconst_traits<void*> >;
template class _STLP_CLASS_DECLSPEC _Deque_base<void*, allocator<void*> >;
template class _STLP_CLASS_DECLSPEC _STLP_PTR_IMPL_NAME(deque)<void*, allocator<void*> >;
_STLP_MOVE_TO_STD_NAMESPACE
# endif /* _STLP_USE_PTR_SPECIALIZATIONS */
_STLP_MOVE_TO_PRIV_NAMESPACE
template class _STLP_CLASS_DECLSPEC _Rb_global<bool>;
template class _STLP_CLASS_DECLSPEC _List_global<bool>;
template class _STLP_CLASS_DECLSPEC _Sl_global<bool>;
template class _STLP_CLASS_DECLSPEC _Stl_prime<bool>;
template class _STLP_CLASS_DECLSPEC _LimG<bool>;
_STLP_MOVE_TO_STD_NAMESPACE
#endif /* _STLP_NO_FORCE_INSTANTIATE */
_STLP_END_NAMESPACE
#if defined (_STLP_SIGNAL_RUNTIME_COMPATIBILITY)
extern "C" void _STLP_DECLSPEC _STLP_CALL _STLP_SIGNAL_RUNTIME_COMPATIBILITY() {}
#endif
#define FORCE_SYMBOL extern
#if defined (_WIN32) && defined (_STLP_USE_DECLSPEC) && !defined (_STLP_USE_STATIC_LIB)
// stlportmt.cpp : Defines the entry point for the DLL application.
//
# undef FORCE_SYMBOL
# define FORCE_SYMBOL APIENTRY
extern "C" {
BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID) {
switch (ul_reason_for_call) {
case DLL_PROCESS_ATTACH:
DisableThreadLibraryCalls((HINSTANCE)hModule);
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}
} /* extern "C" */
#if !defined (_STLP_MSVC) && !defined (__MINGW32__)
_STLP_BEGIN_NAMESPACE
static void FORCE_SYMBOL
force_link() {
set<int>::iterator iter;
// _M_increment; _M_decrement instantiation
++iter;
--iter;
}
_STLP_END_NAMESPACE
#endif
#endif /* _WIN32 */
#if defined (__ICL) && (__ICL >= 900) && (_STLP_MSVC_LIB < 1300)
# undef std
namespace std
{
void _STLP_CALL unexpected() {
unexpected_handler hdl;
set_unexpected(hdl = set_unexpected((unexpected_handler)0));
hdl();
}
}
#endif

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -1,114 +0,0 @@
/*
* Copyright (c) 1999
* Silicon Graphics Computer Systems, Inc.
*
* Copyright (c) 1999
* Boris Fomitchev
*
* This material is provided "as is", with absolutely no warranty expressed
* or implied. Any use is at your own risk.
*
* Permission to use or copy this software for any purpose is hereby granted
* without fee, provided the above notices are retained on all copies.
* Permission to modify the code and to distribute modified code is granted,
* provided the above notices are retained, and a notice that the code was
* modified is included with the above copyright notice.
*
*/
#include "stlport_prefix.h"
#ifdef _STLP_USE_UNIX_IO
# include "details/fstream_unistd.cpp"
#elif defined(_STLP_USE_STDIO_IO)
# include "details/fstream_stdio.cpp"
#elif defined(_STLP_USE_WIN32_IO)
# include "details/fstream_win32io.cpp"
#else
# error "Can't recognize IO scheme to use"
#endif
_STLP_BEGIN_NAMESPACE
// fbp : let us map 1 MB maximum, just be sure not to trash VM
#define MMAP_CHUNK 0x100000L
_Underflow< char, char_traits<char> >::int_type _STLP_CALL
_Underflow< char, char_traits<char> >::_M_doit(basic_filebuf<char, char_traits<char> >* __this)
{
typedef char_traits<char> traits_type;
typedef traits_type::int_type int_type;
if (!__this->_M_in_input_mode) {
if (!__this->_M_switch_to_input_mode())
return traits_type::eof();
}
else if (__this->_M_in_putback_mode) {
__this->_M_exit_putback_mode();
if (__this->gptr() != __this->egptr()) {
int_type __c = traits_type::to_int_type(*__this->gptr());
return __c;
}
}
// If it's a disk file, and if the internal and external character
// sequences are guaranteed to be identical, then try to use memory
// mapped I/O. Otherwise, revert to ordinary read.
if (__this->_M_base.__regular_file()
&& __this->_M_always_noconv
&& __this->_M_base._M_in_binary_mode()) {
// If we've mmapped part of the file already, then unmap it.
if (__this->_M_mmap_base)
__this->_M_base._M_unmap(__this->_M_mmap_base, __this->_M_mmap_len);
// Determine the position where we start mapping. It has to be
// a multiple of the page size.
streamoff __cur = __this->_M_base._M_seek(0, ios_base::cur);
streamoff __size = __this->_M_base._M_file_size();
if (__size > 0 && __cur >= 0 && __cur < __size) {
streamoff __offset = (__cur / __this->_M_base.__page_size()) * __this->_M_base.__page_size();
streamoff __remainder = __cur - __offset;
__this->_M_mmap_len = __size - __offset;
if (__this->_M_mmap_len > MMAP_CHUNK)
__this->_M_mmap_len = MMAP_CHUNK;
if ((__this->_M_mmap_base = __this->_M_base._M_mmap(__offset, __this->_M_mmap_len)) != 0) {
__this->setg(__STATIC_CAST(char*, __this->_M_mmap_base),
__STATIC_CAST(char*, __this->_M_mmap_base) + __STATIC_CAST(ptrdiff_t, __remainder),
__STATIC_CAST(char*, __this->_M_mmap_base) + __STATIC_CAST(ptrdiff_t, __this->_M_mmap_len));
return traits_type::to_int_type(*__this->gptr());
}
else
__this->_M_mmap_len = 0;
}
else {
__this->_M_mmap_base = 0;
__this->_M_mmap_len = 0;
}
}
return __this->_M_underflow_aux();
}
//----------------------------------------------------------------------
// Force instantiation of filebuf and fstream classes.
#if !defined(_STLP_NO_FORCE_INSTANTIATE)
template class basic_filebuf<char, char_traits<char> >;
template class basic_ifstream<char, char_traits<char> >;
template class basic_ofstream<char, char_traits<char> >;
template class basic_fstream<char, char_traits<char> >;
# if !defined (_STLP_NO_WCHAR_T)
template class _Underflow<wchar_t, char_traits<wchar_t> >;
template class basic_filebuf<wchar_t, char_traits<wchar_t> >;
template class basic_ifstream<wchar_t, char_traits<wchar_t> >;
template class basic_ofstream<wchar_t, char_traits<wchar_t> >;
template class basic_fstream<wchar_t, char_traits<wchar_t> >;
# endif /* _STLP_NO_WCHAR_T */
#endif
_STLP_END_NAMESPACE

Просмотреть файл

@ -1,320 +0,0 @@
/*
* Copyright (c) 1999
* Silicon Graphics Computer Systems, Inc.
*
* Copyright (c) 1999
* Boris Fomitchev
*
* This material is provided "as is", with absolutely no warranty expressed
* or implied. Any use is at your own risk.
*
* Permission to use or copy this software for any purpose is hereby granted
* without fee, provided the above notices are retained on all copies.
* Permission to modify the code and to distribute modified code is granted,
* provided the above notices are retained, and a notice that the code was
* modified is included with the above copyright notice.
*
*/
#include "stlport_prefix.h"
#include <algorithm>
#include <ios>
#include <locale>
#include <ostream> // for __get_ostreambuf definition
#include "aligned_buffer.h"
_STLP_BEGIN_NAMESPACE
//----------------------------------------------------------------------
// ios_base members
#ifdef _STLP_USE_EXCEPTIONS
// class ios_base::failure, a subclass of exception. It's used solely
// for reporting errors.
ios_base::failure::failure(const string& s)
: __Named_exception(s)
{}
ios_base::failure::~failure() _STLP_NOTHROW_INHERENTLY {}
#endif
#if !defined (_STLP_STATIC_CONST_INIT_BUG) && !defined (_STLP_NO_STATIC_CONST_DEFINITION)
// Definitions of ios_base's formatting flags.
const ios_base::fmtflags ios_base::left;
const ios_base::fmtflags ios_base::right;
const ios_base::fmtflags ios_base::internal;
const ios_base::fmtflags ios_base::dec;
const ios_base::fmtflags ios_base::hex;
const ios_base::fmtflags ios_base::oct;
const ios_base::fmtflags ios_base::fixed;
const ios_base::fmtflags ios_base::scientific;
const ios_base::fmtflags ios_base::boolalpha;
const ios_base::fmtflags ios_base::showbase;
const ios_base::fmtflags ios_base::showpoint;
const ios_base::fmtflags ios_base::showpos;
const ios_base::fmtflags ios_base::skipws;
const ios_base::fmtflags ios_base::unitbuf;
const ios_base::fmtflags ios_base::uppercase;
const ios_base::fmtflags ios_base::adjustfield;
const ios_base::fmtflags ios_base::basefield;
const ios_base::fmtflags ios_base::floatfield;
// Definitions of ios_base's state flags.
const ios_base::iostate ios_base::goodbit;
const ios_base::iostate ios_base::badbit;
const ios_base::iostate ios_base::eofbit;
const ios_base::iostate ios_base::failbit;
// Definitions of ios_base's openmode flags.
const ios_base::openmode ios_base::app;
const ios_base::openmode ios_base::ate;
const ios_base::openmode ios_base::binary;
const ios_base::openmode ios_base::in;
const ios_base::openmode ios_base::out;
const ios_base::openmode ios_base::trunc;
// Definitions of ios_base's seekdir flags.
const ios_base::seekdir ios_base::beg;
const ios_base::seekdir ios_base::cur;
const ios_base::seekdir ios_base::end;
#endif
// Internal functions used for managing exponentially-growing arrays of
// POD types.
// array is a pointer to N elements of type PODType. Expands the array,
// if necessary, so that array[index] is meaningful. All new elements are
// initialized to zero. Returns a pointer to the new array, and the new
// size.
template <class PODType>
static pair<PODType*, size_t>
_Stl_expand_array(PODType* __array, size_t N, int index) {
if ((int)N < index + 1) {
size_t new_N = (max)(2 * N, size_t(index + 1));
PODType* new_array
= __STATIC_CAST(PODType*,realloc(__array, new_N * sizeof(PODType)));
if (new_array) {
fill(new_array + N, new_array + new_N, PODType());
return pair<PODType*, size_t>(new_array, new_N);
}
else
return pair<PODType*, size_t>(__STATIC_CAST(PODType*,0), 0);
}
else
return pair<PODType*, size_t>(__array, N);
}
// array is a pointer to N elements of type PODType. Allocate a new
// array of N elements, copying the values from the old array to the new.
// Return a pointer to the new array. It is assumed that array is non-null
// and N is nonzero.
template <class PODType>
static PODType* _Stl_copy_array(const PODType* __array, size_t N) {
PODType* result = __STATIC_CAST(PODType*,malloc(N * sizeof(PODType)));
if (result)
copy(__array, __array + N, result);
return result;
}
locale ios_base::imbue(const locale& loc) {
if (loc != _M_locale) {
locale previous = _M_locale;
_M_locale = loc;
_M_invoke_callbacks(imbue_event);
return previous;
}
else {
_M_invoke_callbacks(imbue_event);
return _M_locale;
}
}
int _STLP_CALL ios_base::xalloc() {
#if defined (_STLP_THREADS) && \
defined (_STLP_WIN32THREADS) && defined (_STLP_NEW_PLATFORM_SDK)
static volatile __stl_atomic_t _S_index = 0;
return _STLP_ATOMIC_INCREMENT(&_S_index);
#else
static int _S_index = 0;
static _STLP_STATIC_MUTEX __lock _STLP_MUTEX_INITIALIZER;
_STLP_auto_lock sentry(__lock);
return _S_index++;
#endif
}
long& ios_base::iword(int index) {
static long dummy = 0;
pair<long*, size_t> tmp = _Stl_expand_array(_M_iwords, _M_num_iwords, index);
if (tmp.first) { // The allocation, if any, succeeded.
_M_iwords = tmp.first;
_M_num_iwords = tmp.second;
return _M_iwords[index];
}
else {
_M_setstate_nothrow(badbit);
_M_check_exception_mask();
return dummy;
}
}
void*& ios_base::pword(int index) {
static void* dummy = 0;
pair<void**, size_t> tmp = _Stl_expand_array(_M_pwords, _M_num_pwords, index);
if (tmp.first) { // The allocation, if any, succeeded.
_M_pwords = tmp.first;
_M_num_pwords = tmp.second;
return _M_pwords[index];
}
else {
_M_setstate_nothrow(badbit);
_M_check_exception_mask();
return dummy;
}
}
void ios_base::register_callback(event_callback __fn, int index) {
pair<pair<event_callback, int>*, size_t> tmp
= _Stl_expand_array(_M_callbacks, _M_num_callbacks, (int)_M_callback_index /* fbp: index ??? */ );
if (tmp.first) {
_M_callbacks = tmp.first;
_M_num_callbacks = tmp.second;
_M_callbacks[_M_callback_index++] = make_pair(__fn, index);
}
else {
_M_setstate_nothrow(badbit);
_M_check_exception_mask();
}
}
// Invokes all currently registered callbacks for a particular event.
// Behaves correctly even if one of the callbacks adds a new callback.
void ios_base::_M_invoke_callbacks(event E) {
for (size_t i = _M_callback_index; i > 0; --i) {
event_callback f = _M_callbacks[i-1].first;
int n = _M_callbacks[i-1].second;
f(E, *this, n);
}
}
// This function is called if the state, rdstate(), has a bit set
// that is also set in the exception mask exceptions().
void ios_base::_M_throw_failure() {
const char* arg ;
# if 0
char buffer[256];
char* ptr;
strcpy(buffer, "ios failure: rdstate = 0x");
ptr = __write_integer(buffer+strlen(buffer), ios_base::hex, __STATIC_CAST(unsigned long,_M_iostate));
strcpy(ptr, " mask = 0x");
ptr = __write_integer(buffer+strlen(buffer), ios_base::hex, __STATIC_CAST(unsigned long,_M_exception_mask));
*ptr = 0;
arg = buffer;
# else
arg = "ios failure";
# endif
# ifndef _STLP_USE_EXCEPTIONS
fputs(arg, stderr);
# else
throw failure(arg);
# endif
}
// Copy x's state to *this. This member function is used in the
// implementation of basic_ios::copyfmt. Does not copy _M_exception_mask
// or _M_iostate.
void ios_base::_M_copy_state(const ios_base& x) {
_M_fmtflags = x._M_fmtflags; // Copy the flags, except for _M_iostate
_M_openmode = x._M_openmode; // and _M_exception_mask.
_M_seekdir = x._M_seekdir;
_M_precision = x._M_precision;
_M_width = x._M_width;
_M_locale = x._M_locale;
if (x._M_callbacks) {
pair<event_callback, int>* tmp = _Stl_copy_array(x._M_callbacks, x._M_callback_index);
if (tmp) {
free(_M_callbacks);
_M_callbacks = tmp;
_M_num_callbacks = _M_callback_index = x._M_callback_index;
}
else {
_M_setstate_nothrow(badbit);
_M_check_exception_mask();
}
}
if (x._M_iwords) {
long* tmp = _Stl_copy_array(x._M_iwords, x._M_num_iwords);
if (tmp) {
free(_M_iwords);
_M_iwords = tmp;
_M_num_iwords = x._M_num_iwords;
}
else {
_M_setstate_nothrow(badbit);
_M_check_exception_mask();
}
}
if (x._M_pwords) {
void** tmp = _Stl_copy_array(x._M_pwords, x._M_num_pwords);
if (tmp) {
free(_M_pwords);
_M_pwords = tmp;
_M_num_pwords = x._M_num_pwords;
}
else {
_M_setstate_nothrow(badbit);
_M_check_exception_mask();
}
}
}
// ios's (protected) default constructor. The standard says that all
// fields have indeterminate values; we initialize them to zero for
// simplicity. The only thing that really matters is that the arrays
// are all initially null pointers, and the array element counts are all
// initially zero.
ios_base::ios_base()
: _M_fmtflags(0), _M_iostate(0), _M_openmode(0), _M_seekdir(0),
_M_exception_mask(0),
_M_precision(0), _M_width(0),
_M_locale(),
_M_callbacks(0), _M_num_callbacks(0), _M_callback_index(0),
_M_iwords(0), _M_num_iwords(0),
_M_pwords(0),
_M_num_pwords(0)
{}
// ios's destructor.
ios_base::~ios_base() {
_M_invoke_callbacks(erase_event);
free(_M_callbacks);
free(_M_iwords);
free(_M_pwords);
}
//----------------------------------------------------------------------
// Force instantiation of basic_ios
// For DLL exports, they are already instantiated.
#if !defined(_STLP_NO_FORCE_INSTANTIATE)
template class _STLP_CLASS_DECLSPEC basic_ios<char, char_traits<char> >;
# if !defined (_STLP_NO_WCHAR_T)
template class _STLP_CLASS_DECLSPEC basic_ios<wchar_t, char_traits<wchar_t> >;
# endif /* _STLP_NO_WCHAR_T */
#endif
_STLP_END_NAMESPACE
// Local Variables:
// mode:C++
// End:

Просмотреть файл

@ -1,354 +0,0 @@
/*
* Copyright (c) 1999
* Silicon Graphics Computer Systems, Inc.
*
* Copyright (c) 1999
* Boris Fomitchev
*
* This material is provided "as is", with absolutely no warranty expressed
* or implied. Any use is at your own risk.
*
* Permission to use or copy this software for any purpose is hereby granted
* without fee, provided the above notices are retained on all copies.
* Permission to modify the code and to distribute modified code is granted,
* provided the above notices are retained, and a notice that the code was
* modified is included with the above copyright notice.
*
*/
#include "stlport_prefix.h"
#include <memory>
#include <istream>
#include <fstream>
#if defined (_STLP_MSVC) || defined (__MWERKS__) || defined (__ICL) || defined (__ISCPP__)
# define _STLP_USE_NOT_INIT_SEGMENT
# include <iostream>
#endif
#include "stdio_streambuf.h"
#include "aligned_buffer.h"
#include "_stdio_file.h"
#include "c_locale.h"
// boris : note this is repeated in <iostream>
#ifndef _STLP_USE_NAMESPACES
// in case of SGI iostreams, we have to rename our streams not to clash with those
// provided in native lib
# define cin _STLP_cin
# define cout _STLP_cout
# define cerr _STLP_cerr
# define clog _STLP_clog
#endif
_STLP_BEGIN_NAMESPACE
// This file handles iostream initialization. It is inherently
// nonportable, since the C++ language definition provides no mechanism
// for controlling order of initialization of nonlocal objects.
// Initialization has three parts, which must be performed in the following
// order:
// (1) Initialize the locale system
// (2) Call the constructors for the eight global stream objects.
// (3) Create streambufs for the global stream objects, and initialize
// the stream objects by calling the init() member function.
#if defined (_STLP_USE_NOT_INIT_SEGMENT)
// Definitions of the eight global I/O objects that are declared in
// <iostream>. For some compilers we use pragmas to put the global I/O
// objects into an initialization segment that will not
// be executed. We then explicitly invoke the constructors
// with placement new in ios_base::_S_initialize()
# if defined (__MWERKS__)
# pragma suppress_init_code on
# else
# pragma init_seg("STLPORT_NO_INIT")
# endif
_STLP_DECLSPEC istream cin(0);
_STLP_DECLSPEC ostream cout(0);
_STLP_DECLSPEC ostream cerr(0);
_STLP_DECLSPEC ostream clog(0);
# ifndef _STLP_NO_WCHAR_T
_STLP_DECLSPEC wistream wcin(0);
_STLP_DECLSPEC wostream wcout(0);
_STLP_DECLSPEC wostream wcerr(0);
_STLP_DECLSPEC wostream wclog(0);
# endif
# if defined (__MWERKS__)
# pragma suppress_init_code off
# endif
#else
// Definitions of the eight global I/O objects that are declared in
// <iostream>. Disgusting hack: we deliberately define them with the
// wrong types so that the constructors don't get run automatically.
// We need special tricks to make sure that these objects are struct-
// aligned rather than byte-aligned.
// This is not portable. Declaring a variable with different types in
// two translations units is "undefined", according to the C++ standard.
// Most compilers, however, silently accept this instead of diagnosing
// it as an error.
# ifndef __DMC__
_STLP_DECLSPEC _Stl_aligned_buffer<istream> cin;
_STLP_DECLSPEC _Stl_aligned_buffer<ostream> cout;
_STLP_DECLSPEC _Stl_aligned_buffer<ostream> cerr;
_STLP_DECLSPEC _Stl_aligned_buffer<ostream> clog;
# else
_Stl_aligned_buffer<istream> cin;
_Stl_aligned_buffer<ostream> cout;
_Stl_aligned_buffer<ostream> cerr;
_Stl_aligned_buffer<ostream> clog;
# pragma alias("?cin@std@@3V?$basic_istream@std@DV?$char_traits@std@D@1@@1@A", "?cin@std@@3T?$_Stl_aligned_buffer@std@V?$basic_istream@std@DV?$char_traits@std@D@1@@1@@1@A")
# pragma alias("?cout@std@@3V?$basic_ostream@std@DV?$char_traits@std@D@1@@1@A", "?cout@std@@3T?$_Stl_aligned_buffer@std@V?$basic_ostream@std@DV?$char_traits@std@D@1@@1@@1@A")
# pragma alias("?cerr@std@@3V?$basic_ostream@std@DV?$char_traits@std@D@1@@1@A", "?cerr@std@@3T?$_Stl_aligned_buffer@std@V?$basic_ostream@std@DV?$char_traits@std@D@1@@1@@1@A")
# pragma alias("?clog@std@@3V?$basic_ostream@std@DV?$char_traits@std@D@1@@1@A", "?clog@std@@3T?$_Stl_aligned_buffer@std@V?$basic_ostream@std@DV?$char_traits@std@D@1@@1@@1@A")
# endif
# ifndef _STLP_NO_WCHAR_T
# ifndef __DMC__
_STLP_DECLSPEC _Stl_aligned_buffer<wistream> wcin;
_STLP_DECLSPEC _Stl_aligned_buffer<wostream> wcout;
_STLP_DECLSPEC _Stl_aligned_buffer<wostream> wcerr;
_STLP_DECLSPEC _Stl_aligned_buffer<wostream> wclog;
# else
_Stl_aligned_buffer<wistream> wcin;
_Stl_aligned_buffer<wostream> wcout;
_Stl_aligned_buffer<wostream> wcerr;
_Stl_aligned_buffer<wostream> wclog;
# pragma alias("?wcin@std@@3V?$basic_istream@std@_YV?$char_traits@std@_Y@1@@1@A", "?wcin@std@@3T?$_Stl_aligned_buffer@std@V?$basic_istream@std@_YV?$char_traits@std@_Y@1@@1@@1@A")
# pragma alias("?wcout@std@@3V?$basic_ostream@std@_YV?$char_traits@std@_Y@1@@1@A", "?wcout@std@@3T?$_Stl_aligned_buffer@std@V?$basic_ostream@std@_YV?$char_traits@std@_Y@1@@1@@1@A")
# pragma alias("?wcerr@std@@3V?$basic_ostream@std@_YV?$char_traits@std@_Y@1@@1@A", "?wcerr@std@@3T?$_Stl_aligned_buffer@std@V?$basic_ostream@std@_YV?$char_traits@std@_Y@1@@1@@1@A")
# pragma alias("?wclog@std@@3V?$basic_ostream@std@_YV?$char_traits@std@_Y@1@@1@A", "?wclog@std@@3T?$_Stl_aligned_buffer@std@V?$basic_ostream@std@_YV?$char_traits@std@_Y@1@@1@@1@A")
# endif
# endif
#endif /* STL_MSVC || __MWERKS__ */
// Member functions from class ios_base and ios_base::Init
long ios_base::Init::_S_count = 0;
// by default, those are synced
bool ios_base::_S_is_synced = true;
ios_base::Init::Init() {
if (_S_count++ == 0) {
_Locale_init();
ios_base::_S_initialize();
_Filebuf_base::_S_initialize();
}
}
ios_base::Init::~Init() {
if (--_S_count == 0) {
ios_base::_S_uninitialize();
_Locale_final();
}
}
static int _Stl_extract_open_param(FILE* f)
{ return _FILE_fd(f); }
#ifdef _STLP_REDIRECT_STDSTREAMS
static const char* _Stl_extract_open_param(const char* name)
{ return name; }
#endif
template <class _Tp>
static filebuf*
_Stl_create_filebuf(_Tp x, ios_base::openmode mode ) {
auto_ptr<filebuf> result(new basic_filebuf<char, char_traits<char> >());
result->open(_Stl_extract_open_param(x), mode);
if (result->is_open())
return result.release();
return 0;
}
#if !defined (_STLP_NO_WCHAR_T)
static wfilebuf*
_Stl_create_wfilebuf(FILE* f, ios_base::openmode mode) {
auto_ptr<wfilebuf> result(new basic_filebuf<wchar_t, char_traits<wchar_t> >());
result->_M_open(_FILE_fd(f), mode);
if (result->is_open())
return result.release();
return 0;
}
#endif
void _STLP_CALL ios_base::_S_initialize() {
#if !defined (_STLP_HAS_NO_NAMESPACES) && !defined (_STLP_DONT_USE_PRIV_NAMESPACE)
using _STLP_PRIV stdio_istreambuf;
using _STLP_PRIV stdio_ostreambuf;
#endif
auto_ptr<streambuf> cin_buf;
auto_ptr<streambuf> cout_buf;
auto_ptr<streambuf> cerr_buf;
auto_ptr<streambuf> clog_buf;
if (_S_is_synced)
cin_buf.reset(new stdio_istreambuf(stdin));
else
cin_buf.reset(_Stl_create_filebuf(stdin, ios_base::in));
if (_S_is_synced) {
#ifdef _STLP_REDIRECT_STDSTREAMS
cout_buf.reset(_Stl_create_filebuf("/stdout.txt", ios::out));
cerr_buf.reset(_Stl_create_filebuf("/stderr.txt", ios::out));
clog_buf.reset(_Stl_create_filebuf("/stdlog.txt", ios::out));
#else
cout_buf.reset(new stdio_ostreambuf(stdout));
cerr_buf.reset(new stdio_ostreambuf(stderr));
clog_buf.reset(new stdio_ostreambuf(stderr));
#endif
}
else {
cout_buf.reset(_Stl_create_filebuf(stdout, ios_base::out));
cerr_buf.reset(_Stl_create_filebuf(stderr, ios_base::out));
clog_buf.reset(_Stl_create_filebuf(stderr, ios_base::out));
}
istream* ptr_cin = new(&cin) istream(cin_buf.get()); cin_buf.release();
ostream* ptr_cout = new(&cout) ostream(cout_buf.get()); cout_buf.release();
ostream* ptr_cerr = new(&cerr) ostream(cerr_buf.get()); cerr_buf.release();
/*ostream* ptr_clog = */ new(&clog) ostream(clog_buf.get()); clog_buf.release();
ptr_cin->tie(ptr_cout);
ptr_cerr->setf(ios_base::unitbuf);
#ifndef _STLP_NO_WCHAR_T
auto_ptr<wfilebuf> win(_Stl_create_wfilebuf(stdin, ios_base::in));
auto_ptr<wfilebuf> wout(_Stl_create_wfilebuf(stdout, ios_base::out));
auto_ptr<wfilebuf> werr(_Stl_create_wfilebuf(stderr, ios_base::out));
auto_ptr<wfilebuf> wlog(_Stl_create_wfilebuf(stderr, ios_base::out));
// Run constructors for the four wide stream objects.
wistream* ptr_wcin = new(&wcin) wistream(win.get()); win.release();
wostream* ptr_wcout = new(&wcout) wostream(wout.get()); wout.release();
wostream* ptr_wcerr = new(&wcerr) wostream(werr.get()); werr.release();
/*wostream* ptr_wclog = */ new(&wclog) wostream(wlog.get()); wlog.release();
ptr_wcin->tie(ptr_wcout);
ptr_wcerr->setf(ios_base::unitbuf);
#endif
}
void _STLP_CALL ios_base::_S_uninitialize() {
// Note that destroying output streambufs flushes the buffers.
istream* ptr_cin = &cin;
ostream* ptr_cout = &cout;
ostream* ptr_cerr = &cerr;
ostream* ptr_clog = &clog;
// We don't want any exceptions being thrown here
ptr_cin->exceptions(0);
ptr_cout->exceptions(0);
ptr_cerr->exceptions(0);
ptr_clog->exceptions(0);
delete ptr_cin->rdbuf(0);
delete ptr_cout->rdbuf(0);
delete ptr_cerr->rdbuf(0);
delete ptr_clog->rdbuf(0);
_Destroy(ptr_cin);
_Destroy(ptr_cout);
_Destroy(ptr_cerr);
_Destroy(ptr_clog);
#ifndef _STLP_NO_WCHAR_T
wistream* ptr_wcin = &wcin;
wostream* ptr_wcout = &wcout;
wostream* ptr_wcerr = &wcerr;
wostream* ptr_wclog = &wclog;
// We don't want any exceptions being thrown here
ptr_wcin->exceptions(0);
ptr_wcout->exceptions(0);
ptr_wcerr->exceptions(0);
ptr_wclog->exceptions(0);
delete ptr_wcin->rdbuf(0);
delete ptr_wcout->rdbuf(0);
delete ptr_wcerr->rdbuf(0);
delete ptr_wclog->rdbuf(0);
_Destroy(ptr_wcin);
_Destroy(ptr_wcout);
_Destroy(ptr_wcerr);
_Destroy(ptr_wclog);
#endif
}
bool _STLP_CALL ios_base::sync_with_stdio(bool sync) {
# if !defined (_STLP_HAS_NO_NAMESPACES) && !defined (_STLP_DONT_USE_PRIV_NAMESPACE)
using _STLP_PRIV stdio_istreambuf;
using _STLP_PRIV stdio_ostreambuf;
# endif
if (sync == _S_is_synced) return sync;
// if by any chance we got there before std streams initialization,
// just set the sync flag and exit
if (Init::_S_count == 0) {
_S_is_synced = sync;
return sync;
}
auto_ptr<streambuf> cin_buf;
auto_ptr<streambuf> cout_buf;
auto_ptr<streambuf> cerr_buf;
auto_ptr<streambuf> clog_buf;
if (sync)
cin_buf.reset(new stdio_istreambuf(stdin));
else
cin_buf.reset(_Stl_create_filebuf(stdin, ios_base::in));
if (sync) {
#ifdef _STLP_REDIRECT_STDSTREAMS
cout_buf.reset(_Stl_create_filebuf("/stdout.txt", ios::out));
cerr_buf.reset(_Stl_create_filebuf("/stderr.txt", ios::out));
clog_buf.reset(_Stl_create_filebuf("/stdlog.txt", ios::out));
#else
cout_buf.reset(new stdio_ostreambuf(stdout));
cerr_buf.reset(new stdio_ostreambuf(stderr));
clog_buf.reset(new stdio_ostreambuf(stderr));
#endif
}
else {
cout_buf.reset(_Stl_create_filebuf(stdout, ios_base::out));
cerr_buf.reset(_Stl_create_filebuf(stderr, ios_base::out));
clog_buf.reset(_Stl_create_filebuf(stderr, ios_base::out));
}
if (cin_buf.get() != 0 && cout_buf.get() != 0 && cerr_buf.get() != 0 && clog_buf.get() != 0) {
// When streambuf passed to rdbuf is not null, rdbuf is exception safe:
delete (&cin)->rdbuf(cin_buf.release());
delete (&cout)->rdbuf(cout_buf.release());
delete (&cerr)->rdbuf(cerr_buf.release());
delete (&clog)->rdbuf(clog_buf.release());
_S_is_synced = sync;
}
return _S_is_synced;
}
_STLP_END_NAMESPACE
// Local Variables:
// mode:C++
// End:

Просмотреть файл

@ -1,48 +0,0 @@
/*
* Copyright (c) 1999
* Silicon Graphics Computer Systems, Inc.
*
* Copyright (c) 1999
* Boris Fomitchev
*
* This material is provided "as is", with absolutely no warranty expressed
* or implied. Any use is at your own risk.
*
* Permission to use or copy this software for any purpose is hereby granted
* without fee, provided the above notices are retained on all copies.
* Permission to modify the code and to distribute modified code is granted,
* provided the above notices are retained, and a notice that the code was
* modified is included with the above copyright notice.
*
*/
# include "stlport_prefix.h"
#include <istream>
_STLP_BEGIN_NAMESPACE
#if !defined(_STLP_NO_FORCE_INSTANTIATE)
// instantiations
# if defined (_STLP_USE_TEMPLATE_EXPORT)
template class _STLP_CLASS_DECLSPEC _Isentry<char, char_traits<char> >;
# endif
template class _STLP_CLASS_DECLSPEC basic_iostream<char, char_traits<char> >;
template class _STLP_CLASS_DECLSPEC basic_istream<char, char_traits<char> >;
# if !defined (_STLP_NO_WCHAR_T)
# if defined (_STLP_USE_TEMPLATE_EXPORT)
template class _STLP_CLASS_DECLSPEC _Isentry<wchar_t, char_traits<wchar_t> >;
# endif
template class _STLP_CLASS_DECLSPEC basic_istream<wchar_t, char_traits<wchar_t> >;
template class _STLP_CLASS_DECLSPEC basic_iostream<wchar_t, char_traits<wchar_t> >;
# endif /* !_STLP_NO_WCHAR_T */
#endif /* _STLP_NO_FORCE_INSTANTIATE */
_STLP_END_NAMESPACE
// Local Variables:
// mode:C++
// End:

Просмотреть файл

@ -1,446 +0,0 @@
/*
* Copyright (c) 1999
* Silicon Graphics Computer Systems, Inc.
*
* Copyright (c) 1999
* Boris Fomitchev
*
* This material is provided "as is", with absolutely no warranty expressed
* or implied. Any use is at your own risk.
*
* Permission to use or copy this software for any purpose is hereby granted
* without fee, provided the above notices are retained on all copies.
* Permission to modify the code and to distribute modified code is granted,
* provided the above notices are retained, and a notice that the code was
* modified is included with the above copyright notice.
*
*/
#include "stlport_prefix.h"
#include <locale>
#include <stdexcept>
#include "c_locale.h"
#include "locale_impl.h"
_STLP_BEGIN_NAMESPACE
#define _NAMELESS "*"
static const char _Nameless[] = _NAMELESS;
static inline bool is_C_locale_name (const char* name)
{ return ((name[0] == 'C') && (name[1] == 0)); }
locale* _Stl_get_classic_locale();
locale* _Stl_get_global_locale();
#if defined (_STLP_USE_MSVC6_MEM_T_BUG_WORKAROUND) || \
defined (_STLP_SIGNAL_RUNTIME_COMPATIBILITY) || defined (_STLP_CHECK_RUNTIME_COMPATIBILITY)
# define locale _STLP_NO_MEM_T_NAME(loc)
#endif
locale::facet::~facet() {}
#if !defined (_STLP_MEMBER_TEMPLATES) || defined (_STLP_INLINE_MEMBER_TEMPLATES)
// members that fail to be templates
bool locale::operator()(const string& __x,
const string& __y) const
{ return __locale_do_operator_call(*this, __x, __y); }
# if !defined (_STLP_NO_WCHAR_T)
bool locale::operator()(const wstring& __x,
const wstring& __y) const
{ return __locale_do_operator_call(*this, __x, __y); }
# endif
#endif
void _STLP_CALL locale::_M_throw_on_null_name()
{ _STLP_THROW(runtime_error("Invalid null locale name")); }
void _STLP_CALL locale::_M_throw_on_combine_error(const string& name) {
string what = "Unable to find facet";
what += " in ";
what += name.empty() ? "system" : name.c_str();
what += " locale";
_STLP_THROW(runtime_error(what.c_str()));
}
void _STLP_CALL locale::_M_throw_on_creation_failure(int __err_code,
const char* name, const char* facet) {
string what;
switch (__err_code) {
case _STLP_LOC_UNSUPPORTED_FACET_CATEGORY:
what = "No platform localization support for ";
what += facet;
what += " facet category, unable to create facet for ";
what += name[0] == 0 ? "system" : name;
what += " locale";
break;
case _STLP_LOC_NO_PLATFORM_SUPPORT:
what = "No platform localization support, unable to create ";
what += name[0] == 0 ? "system" : name;
what += " locale";
break;
default:
case _STLP_LOC_UNKNOWN_NAME:
what = "Unable to create facet ";
what += facet;
what += " from name '";
what += name;
what += "'";
break;
case _STLP_LOC_NO_MEMORY:
_STLP_THROW_BAD_ALLOC;
break;
}
_STLP_THROW(runtime_error(what.c_str()));
}
// Takes a reference to a locale::id, assign a numeric index if not already
// affected and returns it. The returned index is always positive.
static const locale::id& _Stl_loc_get_index(locale::id& id) {
if (id._M_index == 0) {
#if defined (_STLP_ATOMIC_INCREMENT) && !defined (_STLP_WIN95_LIKE)
static _STLP_VOLATILE __stl_atomic_t _S_index = __STATIC_CAST(__stl_atomic_t, locale::id::_S_max);
id._M_index = _STLP_ATOMIC_INCREMENT(&_S_index);
#else
static _STLP_STATIC_MUTEX _Index_lock _STLP_MUTEX_INITIALIZER;
_STLP_auto_lock sentry(_Index_lock);
size_t new_index = locale::id::_S_max++;
id._M_index = new_index;
#endif
}
return id;
}
// Default constructor: create a copy of the global locale.
locale::locale() _STLP_NOTHROW
: _M_impl(_get_Locale_impl(_Stl_get_global_locale()->_M_impl))
{}
// Copy constructor
locale::locale(const locale& L) _STLP_NOTHROW
: _M_impl( _get_Locale_impl( L._M_impl ) )
{}
void locale::_M_insert(facet* f, locale::id& n) {
if (f)
_M_impl->insert(f, _Stl_loc_get_index(n));
}
locale::locale( _Locale_impl* impl ) :
_M_impl( _get_Locale_impl( impl ) )
{}
// Create a locale from a name.
locale::locale(const char* name)
: _M_impl(0) {
if (!name)
_M_throw_on_null_name();
if (is_C_locale_name(name)) {
_M_impl = _get_Locale_impl( locale::classic()._M_impl );
return;
}
_Locale_impl* impl = 0;
_STLP_TRY {
impl = new _Locale_impl(locale::id::_S_max, name);
// Insert categories one at a time.
_Locale_name_hint *hint = 0;
const char* ctype_name = name;
char ctype_buf[_Locale_MAX_SIMPLE_NAME];
const char* numeric_name = name;
char numeric_buf[_Locale_MAX_SIMPLE_NAME];
const char* time_name = name;
char time_buf[_Locale_MAX_SIMPLE_NAME];
const char* collate_name = name;
char collate_buf[_Locale_MAX_SIMPLE_NAME];
const char* monetary_name = name;
char monetary_buf[_Locale_MAX_SIMPLE_NAME];
const char* messages_name = name;
char messages_buf[_Locale_MAX_SIMPLE_NAME];
hint = impl->insert_ctype_facets(ctype_name, ctype_buf, hint);
hint = impl->insert_numeric_facets(numeric_name, numeric_buf, hint);
hint = impl->insert_time_facets(time_name, time_buf, hint);
hint = impl->insert_collate_facets(collate_name, collate_buf, hint);
hint = impl->insert_monetary_facets(monetary_name, monetary_buf, hint);
impl->insert_messages_facets(messages_name, messages_buf, hint);
// Try to use a normalize locale name in order to have the == operator
// to behave correctly:
if (strcmp(ctype_name, numeric_name) == 0 &&
strcmp(ctype_name, time_name) == 0 &&
strcmp(ctype_name, collate_name) == 0 &&
strcmp(ctype_name, monetary_name) == 0 &&
strcmp(ctype_name, messages_name) == 0) {
impl->name = ctype_name;
}
// else we keep current name.
// reassign impl
_M_impl = _get_Locale_impl( impl );
}
_STLP_UNWIND(delete impl);
}
static void _Stl_loc_combine_names_aux(_Locale_impl* L,
const char* name,
const char* ctype_name, const char* time_name, const char* numeric_name,
const char* collate_name, const char* monetary_name, const char* messages_name,
locale::category c) {
// This function is only called when names has been validated so using _Locale_extract_*_name
// can't fail.
int __err_code;
char buf[_Locale_MAX_SIMPLE_NAME];
L->name = string("LC_CTYPE=") + _Locale_extract_ctype_name((c & locale::ctype) ? ctype_name : name, buf, 0, &__err_code) + ";";
L->name += string("LC_TIME=") + _Locale_extract_time_name((c & locale::time) ? time_name : name, buf, 0, &__err_code) + ";";
L->name += string("LC_NUMERIC=") + _Locale_extract_numeric_name((c & locale::numeric) ? numeric_name : name, buf, 0, &__err_code) + ";";
L->name += string("LC_COLLATE=") + _Locale_extract_collate_name((c & locale::collate) ? collate_name : name, buf, 0, &__err_code) + ";";
L->name += string("LC_MONETARY=") + _Locale_extract_monetary_name((c & locale::monetary) ? monetary_name : name, buf, 0, &__err_code) + ";";
L->name += string("LC_MESSAGES=") + _Locale_extract_messages_name((c & locale::messages) ? messages_name : name, buf, 0, &__err_code);
}
// Give L a name where all facets except those in category c
// are taken from name1, and those in category c are taken from name2.
static void _Stl_loc_combine_names(_Locale_impl* L,
const char* name1, const char* name2,
locale::category c) {
if ((c & locale::all) == 0 || strcmp(name1, name1) == 0)
L->name = name1;
else if ((c & locale::all) == locale::all)
L->name = name2;
else {
_Stl_loc_combine_names_aux(L, name1, name2, name2, name2, name2, name2, name2, c);
}
}
static void _Stl_loc_combine_names(_Locale_impl* L,
const char* name,
const char* ctype_name, const char* time_name, const char* numeric_name,
const char* collate_name, const char* monetary_name, const char* messages_name,
locale::category c) {
if ((c & locale::all) == 0 || (strcmp(name, ctype_name) == 0 &&
strcmp(name, time_name) == 0 &&
strcmp(name, numeric_name) == 0 &&
strcmp(name, collate_name) == 0 &&
strcmp(name, monetary_name) == 0 &&
strcmp(name, messages_name) == 0))
L->name = name;
else if ((c & locale::all) == locale::all && strcmp(ctype_name, time_name) == 0 &&
strcmp(ctype_name, numeric_name) == 0 &&
strcmp(ctype_name, collate_name) == 0 &&
strcmp(ctype_name, monetary_name) == 0 &&
strcmp(ctype_name, messages_name) == 0)
L->name = ctype_name;
else {
_Stl_loc_combine_names_aux(L, name, ctype_name, time_name, numeric_name, collate_name, monetary_name, messages_name, c);
}
}
// Create a locale that's a copy of L, except that all of the facets
// in category c are instead constructed by name.
locale::locale(const locale& L, const char* name, locale::category c)
: _M_impl(0) {
if (!name)
_M_throw_on_null_name();
if (!::strcmp(_Nameless, name))
_STLP_THROW(runtime_error("Invalid locale name '" _NAMELESS "'"));
_Locale_impl* impl = 0;
_STLP_TRY {
impl = new _Locale_impl(*L._M_impl);
_Locale_name_hint *hint = 0;
const char* ctype_name = name;
char ctype_buf[_Locale_MAX_SIMPLE_NAME];
const char* numeric_name = name;
char numeric_buf[_Locale_MAX_SIMPLE_NAME];
const char* time_name = name;
char time_buf[_Locale_MAX_SIMPLE_NAME];
const char* collate_name = name;
char collate_buf[_Locale_MAX_SIMPLE_NAME];
const char* monetary_name = name;
char monetary_buf[_Locale_MAX_SIMPLE_NAME];
const char* messages_name = name;
char messages_buf[_Locale_MAX_SIMPLE_NAME];
if (c & locale::ctype)
hint = impl->insert_ctype_facets(ctype_name, ctype_buf, hint);
if (c & locale::numeric)
hint = impl->insert_numeric_facets(numeric_name, numeric_buf, hint);
if (c & locale::time)
hint = impl->insert_time_facets(time_name, time_buf, hint);
if (c & locale::collate)
hint = impl->insert_collate_facets(collate_name, collate_buf, hint);
if (c & locale::monetary)
hint = impl->insert_monetary_facets(monetary_name, monetary_buf,hint);
if (c & locale::messages)
impl->insert_messages_facets(messages_name, messages_buf, hint);
_Stl_loc_combine_names(impl, L._M_impl->name.c_str(),
ctype_name, time_name, numeric_name,
collate_name, monetary_name, messages_name, c);
_M_impl = _get_Locale_impl( impl );
}
_STLP_UNWIND(delete impl)
}
// Contruct a new locale where all facets that aren't in category c
// come from L1, and all those that are in category c come from L2.
locale::locale(const locale& L1, const locale& L2, category c)
: _M_impl(0) {
_Locale_impl* impl = new _Locale_impl(*L1._M_impl);
_Locale_impl* i2 = L2._M_impl;
if (L1.name() != _Nameless && L2.name() != _Nameless)
_Stl_loc_combine_names(impl, L1._M_impl->name.c_str(), L2._M_impl->name.c_str(), c);
else {
impl->name = _Nameless;
}
if (c & collate) {
impl->insert( i2, _STLP_STD::collate<char>::id);
# ifndef _STLP_NO_WCHAR_T
impl->insert( i2, _STLP_STD::collate<wchar_t>::id);
# endif
}
if (c & ctype) {
impl->insert( i2, _STLP_STD::ctype<char>::id);
impl->insert( i2, _STLP_STD::codecvt<char, char, mbstate_t>::id);
# ifndef _STLP_NO_WCHAR_T
impl->insert( i2, _STLP_STD::ctype<wchar_t>::id);
impl->insert( i2, _STLP_STD::codecvt<wchar_t, char, mbstate_t>::id);
# endif
}
if (c & monetary) {
impl->insert( i2, _STLP_STD::moneypunct<char, true>::id);
impl->insert( i2, _STLP_STD::moneypunct<char, false>::id);
impl->insert( i2, _STLP_STD::money_get<char, istreambuf_iterator<char, char_traits<char> > >::id);
impl->insert( i2, _STLP_STD::money_put<char, ostreambuf_iterator<char, char_traits<char> > >::id);
# ifndef _STLP_NO_WCHAR_T
impl->insert( i2, _STLP_STD::moneypunct<wchar_t, true>::id);
impl->insert( i2, _STLP_STD::moneypunct<wchar_t, false>::id);
impl->insert( i2, _STLP_STD::money_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id);
impl->insert( i2, _STLP_STD::money_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id);
# endif
}
if (c & numeric) {
impl->insert( i2, _STLP_STD::numpunct<char>::id);
impl->insert( i2, _STLP_STD::num_get<char, istreambuf_iterator<char, char_traits<char> > >::id);
impl->insert( i2, _STLP_STD::num_put<char, ostreambuf_iterator<char, char_traits<char> > >::id);
# ifndef _STLP_NO_WCHAR_T
impl->insert( i2, _STLP_STD::numpunct<wchar_t>::id);
impl->insert( i2, _STLP_STD::num_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id);
impl->insert( i2, _STLP_STD::num_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id);
# endif
}
if (c & time) {
impl->insert( i2, _STLP_STD::time_get<char, istreambuf_iterator<char, char_traits<char> > >::id);
impl->insert( i2, _STLP_STD::time_put<char, ostreambuf_iterator<char, char_traits<char> > >::id);
# ifndef _STLP_NO_WCHAR_T
impl->insert( i2, _STLP_STD::time_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id);
impl->insert( i2, _STLP_STD::time_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id);
# endif
}
if (c & messages) {
impl->insert( i2, _STLP_STD::messages<char>::id);
# ifndef _STLP_NO_WCHAR_T
impl->insert( i2, _STLP_STD::messages<wchar_t>::id);
# endif
}
_M_impl = _get_Locale_impl( impl );
}
// Destructor.
locale::~locale() _STLP_NOTHROW {
if (_M_impl)
_release_Locale_impl(_M_impl);
}
// Assignment operator. Much like the copy constructor: just a bit of
// pointer twiddling.
const locale& locale::operator=(const locale& L) _STLP_NOTHROW {
if (this->_M_impl != L._M_impl) {
if (this->_M_impl)
_release_Locale_impl(this->_M_impl);
this->_M_impl = _get_Locale_impl(L._M_impl);
}
return *this;
}
locale::facet* locale::_M_get_facet(const locale::id& n) const {
return n._M_index < _M_impl->size() ? _M_impl->facets_vec[n._M_index] : 0;
}
locale::facet* locale::_M_use_facet(const locale::id& n) const {
locale::facet* f = (n._M_index < _M_impl->size() ? _M_impl->facets_vec[n._M_index] : 0);
if (!f)
_M_impl->_M_throw_bad_cast();
return f;
}
string locale::name() const {
return _M_impl->name;
}
// Compare two locales for equality.
bool locale::operator==(const locale& L) const {
return this->_M_impl == L._M_impl ||
(this->name() == L.name() && this->name() != _Nameless);
}
bool locale::operator!=(const locale& L) const {
return !(*this == L);
}
// static data members.
const locale& _STLP_CALL locale::classic() {
return *_Stl_get_classic_locale();
}
#if !defined (_STLP_USE_MSVC6_MEM_T_BUG_WORKAROUND)
locale _STLP_CALL locale::global(const locale& L) {
#else
_Locale_impl* _STLP_CALL locale::global(const locale& L) {
#endif
locale old(_Stl_get_global_locale()->_M_impl);
if (_Stl_get_global_locale()->_M_impl != L._M_impl) {
_release_Locale_impl(_Stl_get_global_locale()->_M_impl);
// this assign should be atomic, should be fixed here:
_Stl_get_global_locale()->_M_impl = _get_Locale_impl(L._M_impl);
// Set the global C locale, if appropriate.
#if !defined(_STLP_NO_LOCALE_SUPPORT)
if (L.name() != _Nameless)
setlocale(LC_ALL, L.name().c_str());
#endif
}
#if !defined (_STLP_USE_MSVC6_MEM_T_BUG_WORKAROUND)
return old;
#else
return old._M_impl;
#endif
}
#if !defined (_STLP_STATIC_CONST_INIT_BUG) && !defined (_STLP_NO_STATIC_CONST_DEFINITION)
const locale::category locale::none;
const locale::category locale::collate;
const locale::category locale::ctype;
const locale::category locale::monetary;
const locale::category locale::numeric;
const locale::category locale::time;
const locale::category locale::messages;
const locale::category locale::all;
#endif
_STLP_END_NAMESPACE

Просмотреть файл

@ -1,288 +0,0 @@
/*
* Copyright (c) 1999
* Silicon Graphics Computer Systems, Inc.
*
* Copyright (c) 1999
* Boris Fomitchev
*
* This material is provided "as is", with absolutely no warranty expressed
* or implied. Any use is at your own risk.
*
* Permission to use or copy this software for any purpose is hereby granted
* without fee, provided the above notices are retained on all copies.
* Permission to modify the code and to distribute modified code is granted,
* provided the above notices are retained, and a notice that the code was
* modified is included with the above copyright notice.
*
*/
#include "stlport_prefix.h"
#include <hash_map>
#include <string>
#include <locale>
#include <istream>
#include "c_locale.h"
#include "locale_impl.h"
#include "acquire_release.h"
_STLP_BEGIN_NAMESPACE
_STLP_MOVE_TO_PRIV_NAMESPACE
// Those wrappers are needed to use locale functions in __acquire_category,
// all functions have to present the same prototype.
static void* _Loc_ctype_create(const char * s, _Locale_name_hint* hint, int *__err_code)
{ return _Locale_ctype_create(s, hint, __err_code); }
static void* _Loc_codecvt_create(const char * s, _Locale_name_hint* hint, int *__err_code)
{ return _Locale_codecvt_create(s, hint, __err_code); }
static void* _Loc_numeric_create(const char * s, _Locale_name_hint* hint, int *__err_code)
{ return _Locale_numeric_create(s, hint, __err_code); }
static void* _Loc_time_create(const char * s, _Locale_name_hint* hint, int *__err_code)
{ return _Locale_time_create(s, hint, __err_code); }
static void* _Loc_collate_create(const char * s, _Locale_name_hint* hint, int *__err_code)
{ return _Locale_collate_create(s, hint, __err_code); }
static void* _Loc_monetary_create(const char * s, _Locale_name_hint* hint, int *__err_code)
{ return _Locale_monetary_create(s, hint, __err_code); }
static void* _Loc_messages_create(const char * s, _Locale_name_hint* hint, int *__err_code)
{ return _Locale_messages_create(s, hint, __err_code); }
static char const* _Loc_ctype_name(void* l, char* s)
{ return _Locale_ctype_name((_Locale_ctype*)l, s); }
static char const* _Loc_codecvt_name(void* l, char* s)
{ return _Locale_codecvt_name((_Locale_codecvt*)l, s); }
static char const* _Loc_numeric_name(void* l, char* s)
{ return _Locale_numeric_name((_Locale_numeric*)l, s); }
static char const* _Loc_time_name(void* l, char* s)
{ return _Locale_time_name((_Locale_time*)l, s); }
static char const* _Loc_collate_name(void* l, char* s)
{ return _Locale_collate_name((_Locale_collate*)l, s); }
static char const* _Loc_monetary_name(void* l, char* s)
{ return _Locale_monetary_name((_Locale_monetary*)l, s); }
static char const* _Loc_messages_name(void* l, char* s)
{ return _Locale_messages_name((_Locale_messages*)l, s); }
static const char* _Loc_ctype_default(char* p)
{ return _Locale_ctype_default(p); }
static const char* _Loc_numeric_default(char * p)
{ return _Locale_numeric_default(p); }
static const char* _Loc_time_default(char* p)
{ return _Locale_time_default(p); }
static const char* _Loc_collate_default(char* p)
{ return _Locale_collate_default(p); }
static const char* _Loc_monetary_default(char* p)
{ return _Locale_monetary_default(p); }
static const char* _Loc_messages_default(char* p)
{ return _Locale_messages_default(p); }
static void _Loc_ctype_destroy(void* p) {_Locale_ctype_destroy((_Locale_ctype*)p); }
static void _Loc_codecvt_destroy(void* p) {_Locale_codecvt_destroy((_Locale_codecvt*)p); }
static void _Loc_numeric_destroy(void* p) {_Locale_numeric_destroy((_Locale_numeric*)p); }
static void _Loc_time_destroy(void* p) {_Locale_time_destroy((_Locale_time*)p);}
static void _Loc_collate_destroy(void* p) {_Locale_collate_destroy((_Locale_collate*)p);}
static void _Loc_monetary_destroy(void* p) {_Locale_monetary_destroy((_Locale_monetary*)p);}
static void _Loc_messages_destroy(void* p) {_Locale_messages_destroy((_Locale_messages*)p);}
typedef void* (*loc_create_func_t)(const char *, _Locale_name_hint*, int *__err_code);
typedef char const* (*loc_name_func_t)(void* l, char* s);
typedef void (*loc_destroy_func_t)(void* l);
typedef const char* (*loc_default_name_func_t)(char* s);
typedef char const* (*loc_extract_name_func_t)(const char*, char*, _Locale_name_hint*, int *__err_code);
//----------------------------------------------------------------------
// Acquire and release low-level category objects. The whole point of
// this is so that we don't allocate (say) four different _Locale_ctype
// objects for a single locale.
// Global hash tables for category objects.
typedef hash_map<string, pair<void*, size_t>, hash<string>, equal_to<string> > Category_Map;
// Look up a category by name
static Category_Map** ctype_hash() {
static Category_Map *_S_ctype_hash = 0;
return &_S_ctype_hash;
}
static Category_Map** codecvt_hash() {
static Category_Map *_S_codecvt_hash = 0;
return &_S_codecvt_hash;
}
static Category_Map** numeric_hash() {
static Category_Map *_S_numeric_hash = 0;
return &_S_numeric_hash;
}
static Category_Map** time_hash() {
static Category_Map *_S_time_hash = 0;
return &_S_time_hash;
}
static Category_Map** collate_hash() {
static Category_Map *_S_collate_hash = 0;
return &_S_collate_hash;
}
static Category_Map** monetary_hash() {
static Category_Map *_S_monetary_hash = 0;
return &_S_monetary_hash;
}
static Category_Map** messages_hash() {
static Category_Map *_S_messages_hash;
return &_S_messages_hash;
}
// We have a single lock for all of the hash tables. We may wish to
// replace it with six different locks.
/* REFERENCED */
static _STLP_STATIC_MUTEX& category_hash_mutex() {
static _STLP_STATIC_MUTEX lock _STLP_MUTEX_INITIALIZER;
return lock;
}
static void*
__acquire_category(const char* &name, char *buf, _Locale_name_hint* hint,
loc_extract_name_func_t extract_name,
loc_create_func_t create_obj, loc_default_name_func_t default_name,
Category_Map ** M, int *__err_code) {
#if !defined (__BORLANDC__) || (__BORLANDC__ >= 0x564)
typedef Category_Map::iterator Category_iterator;
pair<Category_iterator, bool> result;
#else
# if !defined(_STLP_DEBUG)
pair<_Ht_iterator<_Slist_iterator<pair<const string,pair<void *,unsigned int> >,_Nonconst_traits<pair<const string,pair<void *,unsigned int> > > >,_NonLocalHashMapTraitsT<pair<const string,pair<void *,unsigned int> > > >, bool> result;
# else
pair<_DBG_iter<_NonDbg_hashtable<pair<const string,pair<void *,unsigned int> >,string,hash<string>,_HashMapTraitsT<pair<const string,pair<void *,unsigned int> > >,_Select1st<pair<const string,pair<void *,unsigned int> > >,_DbgEqual<string,equal_to<string> >,allocator<pair<const string,pair<void *,unsigned int> > > >,_DbgTraits<_NonLocalHashMapTraitsT<pair<const string,pair<void *,unsigned int> > > > >, bool> result;
# endif
#endif
*__err_code = _STLP_LOC_UNDEFINED;
// Find what name to look for. Be careful if user requests the default.
if (name[0] == 0) {
name = default_name(buf);
if (name == 0 || name[0] == 0)
name = "C";
}
else {
const char* cname = extract_name(name, buf, hint, __err_code);
if (cname == 0) {
return 0;
}
name = cname;
}
Category_Map::value_type __e(name, pair<void*,size_t>((void*)0,size_t(0)));
_STLP_auto_lock sentry(category_hash_mutex());
if (!*M)
*M = new Category_Map();
// Look for an existing entry with that name.
result = (*M)->insert_noresize(__e);
if (result.second) {
// There was no entry in the map already. Create the category.
(*result.first).second.first = create_obj(name, hint, __err_code);
if (!(*result.first).second.first) {
(*M)->erase(result.first);
#if defined (_STLP_LEAKS_PEDANTIC)
if ((*M)->empty()) {
delete *M;
*M = 0;
}
#endif
return 0;
}
}
// Increment the reference count.
++((*result.first).second.second);
return (*result.first).second.first;
}
static void
__release_category(void* cat,
loc_destroy_func_t destroy_fun,
loc_name_func_t get_name,
Category_Map** M) {
Category_Map *pM = *M;
if (cat && pM) {
// Find the name of the category object.
char buf[_Locale_MAX_SIMPLE_NAME + 1];
char const* name = get_name(cat, buf);
if (name != 0) {
_STLP_auto_lock sentry(category_hash_mutex());
Category_Map::iterator it = pM->find(name);
if (it != pM->end()) {
// Decrement the ref count. If it goes to zero, delete this category
// from the map.
if (--((*it).second.second) == 0) {
void* cat1 = (*it).second.first;
destroy_fun(cat1);
pM->erase(it);
#if defined (_STLP_LEAKS_PEDANTIC)
if (pM->empty()) {
delete pM;
*M = 0;
}
#endif
}
}
}
}
}
_Locale_ctype* _STLP_CALL __acquire_ctype(const char* &name, char *buf, _Locale_name_hint* hint, int *__err_code) {
return __REINTERPRET_CAST(_Locale_ctype*, __acquire_category(name, buf, hint,
_Locale_extract_ctype_name, _Loc_ctype_create, _Loc_ctype_default,
ctype_hash(), __err_code));
}
_Locale_codecvt* _STLP_CALL __acquire_codecvt(const char* &name, char *buf, _Locale_name_hint* hint, int *__err_code) {
return __REINTERPRET_CAST(_Locale_codecvt*, __acquire_category(name, buf, hint,
_Locale_extract_ctype_name, _Loc_codecvt_create, _Loc_ctype_default,
codecvt_hash(), __err_code));
}
_Locale_numeric* _STLP_CALL __acquire_numeric(const char* &name, char *buf, _Locale_name_hint* hint, int *__err_code) {
return __REINTERPRET_CAST(_Locale_numeric*, __acquire_category(name, buf, hint,
_Locale_extract_numeric_name, _Loc_numeric_create, _Loc_numeric_default,
numeric_hash(), __err_code));
}
_Locale_time* _STLP_CALL __acquire_time(const char* &name, char *buf, _Locale_name_hint* hint, int *__err_code) {
return __REINTERPRET_CAST(_Locale_time*, __acquire_category(name, buf, hint,
_Locale_extract_time_name, _Loc_time_create, _Loc_time_default,
time_hash(), __err_code));
}
_Locale_collate* _STLP_CALL __acquire_collate(const char* &name, char *buf, _Locale_name_hint* hint, int *__err_code) {
return __REINTERPRET_CAST(_Locale_collate*, __acquire_category(name, buf, hint,
_Locale_extract_collate_name, _Loc_collate_create, _Loc_collate_default,
collate_hash(), __err_code));
}
_Locale_monetary* _STLP_CALL __acquire_monetary(const char* &name, char *buf, _Locale_name_hint* hint, int *__err_code) {
return __REINTERPRET_CAST(_Locale_monetary*, __acquire_category(name, buf, hint,
_Locale_extract_monetary_name, _Loc_monetary_create, _Loc_monetary_default,
monetary_hash(), __err_code));
}
_Locale_messages* _STLP_CALL __acquire_messages(const char* &name, char *buf, _Locale_name_hint* hint, int *__err_code) {
return __REINTERPRET_CAST(_Locale_messages*, __acquire_category(name, buf, hint,
_Locale_extract_messages_name, _Loc_messages_create, _Loc_messages_default,
messages_hash(), __err_code));
}
void _STLP_CALL __release_ctype(_Locale_ctype* cat)
{ __release_category(cat, _Loc_ctype_destroy, _Loc_ctype_name, ctype_hash()); }
void _STLP_CALL __release_codecvt(_Locale_codecvt* cat)
{ __release_category(cat, _Loc_codecvt_destroy, _Loc_codecvt_name, codecvt_hash()); }
void _STLP_CALL __release_numeric(_Locale_numeric* cat)
{ __release_category(cat, _Loc_numeric_destroy, _Loc_numeric_name, numeric_hash()); }
void _STLP_CALL __release_time(_Locale_time* cat)
{ __release_category(cat, _Loc_time_destroy, _Loc_time_name, time_hash()); }
void _STLP_CALL __release_collate(_Locale_collate* cat)
{ __release_category(cat, _Loc_collate_destroy, _Loc_collate_name, collate_hash()); }
void _STLP_CALL __release_monetary(_Locale_monetary* cat)
{ __release_category(cat, _Loc_monetary_destroy, _Loc_monetary_name, monetary_hash()); }
void _STLP_CALL __release_messages(_Locale_messages* cat)
{ __release_category(cat, _Loc_messages_destroy, _Loc_messages_name, messages_hash()); }
_STLP_MOVE_TO_STD_NAMESPACE
_STLP_END_NAMESPACE

Просмотреть файл

@ -1,765 +0,0 @@
/*
* Copyright (c) 1999
* Silicon Graphics Computer Systems, Inc.
*
* Copyright (c) 1999
* Boris Fomitchev
*
* This material is provided "as is", with absolutely no warranty expressed
* or implied. Any use is at your own risk.
*
* Permission to use or copy this software for any purpose is hereby granted
* without fee, provided the above notices are retained on all copies.
* Permission to modify the code and to distribute modified code is granted,
* provided the above notices are retained, and a notice that the code was
* modified is included with the above copyright notice.
*
*/
#include "stlport_prefix.h"
#include <locale>
#include <algorithm>
#include <typeinfo>
#include "c_locale.h"
#include "aligned_buffer.h"
#include "acquire_release.h"
#include "locale_impl.h"
_STLP_BEGIN_NAMESPACE
static const char _Nameless[] = "*";
static inline bool is_C_locale_name (const char* name)
{ return ((name[0] == 'C') && (name[1] == 0)); }
locale::facet * _STLP_CALL _get_facet(locale::facet *f)
{
if (f != 0)
f->_M_incr();
return f;
}
void _STLP_CALL _release_facet(locale::facet *&f)
{
if ((f != 0) && (f->_M_decr() == 0)) {
delete f;
f = 0;
}
}
size_t locale::id::_S_max = 27;
static void _Stl_loc_assign_ids();
static _Stl_aligned_buffer<_Locale_impl::Init> __Loc_init_buf;
_Locale_impl::Init::Init() {
if (_M_count()._M_incr() == 1) {
_Locale_impl::_S_initialize();
}
}
_Locale_impl::Init::~Init() {
if (_M_count()._M_decr() == 0) {
_Locale_impl::_S_uninitialize();
}
}
_Refcount_Base& _Locale_impl::Init::_M_count() const {
static _Refcount_Base _S_count(0);
return _S_count;
}
_Locale_impl::_Locale_impl(const char* s)
: _Refcount_Base(0), name(s), facets_vec() {
facets_vec.reserve( locale::id::_S_max );
new (&__Loc_init_buf) Init();
}
_Locale_impl::_Locale_impl( _Locale_impl const& locimpl )
: _Refcount_Base(0), name(locimpl.name), facets_vec() {
for_each( locimpl.facets_vec.begin(), locimpl.facets_vec.end(), _get_facet);
facets_vec = locimpl.facets_vec;
new (&__Loc_init_buf) Init();
}
_Locale_impl::_Locale_impl( size_t n, const char* s)
: _Refcount_Base(0), name(s), facets_vec(n, 0) {
new (&__Loc_init_buf) Init();
}
_Locale_impl::~_Locale_impl() {
(&__Loc_init_buf)->~Init();
for_each( facets_vec.begin(), facets_vec.end(), _release_facet);
}
// Initialization of the locale system. This must be called before
// any locales are constructed. (Meaning that it must be called when
// the I/O library itself is initialized.)
void _STLP_CALL _Locale_impl::_S_initialize() {
_Stl_loc_assign_ids();
make_classic_locale();
}
// Release of the classic locale ressources. Has to be called after the last
// locale destruction and not only after the classic locale destruction as
// the facets can be shared between different facets.
void _STLP_CALL _Locale_impl::_S_uninitialize() {
//Not necessary anymore as classic facets are now 'normal' dynamically allocated
//facets with a reference counter telling to _release_facet when the facet can be
//deleted.
//free_classic_locale();
}
// _Locale_impl non-inline member functions.
void _STLP_CALL _Locale_impl::_M_throw_bad_cast() {
_STLP_THROW(bad_cast());
}
void _Locale_impl::insert(_Locale_impl *from, const locale::id& n) {
if (n._M_index > 0 && n._M_index < from->size()) {
this->insert(from->facets_vec[n._M_index], n);
}
}
locale::facet* _Locale_impl::insert(locale::facet *f, const locale::id& n) {
if (f == 0 || n._M_index == 0)
return 0;
if (n._M_index >= facets_vec.size()) {
facets_vec.resize(n._M_index + 1);
}
if (f != facets_vec[n._M_index])
{
_release_facet(facets_vec[n._M_index]);
facets_vec[n._M_index] = _get_facet(f);
}
return f;
}
//
// <locale> content which is dependent on the name
//
/* Six functions, one for each category. Each of them takes a
* a name, constructs that appropriate category facets by name,
* and inserts them into the locale. */
_Locale_name_hint* _Locale_impl::insert_ctype_facets(const char* &name, char *buf, _Locale_name_hint* hint) {
if (name[0] == 0)
name = _Locale_ctype_default(buf);
if (name == 0 || name[0] == 0 || is_C_locale_name(name)) {
_Locale_impl* i2 = locale::classic()._M_impl;
this->insert(i2, ctype<char>::id);
this->insert(i2, codecvt<char, char, mbstate_t>::id);
#ifndef _STLP_NO_WCHAR_T
this->insert(i2, ctype<wchar_t>::id);
this->insert(i2, codecvt<wchar_t, char, mbstate_t>::id);
#endif
} else {
locale::facet* ct = 0;
locale::facet* cvt = 0;
#ifndef _STLP_NO_WCHAR_T
locale::facet* wct = 0;
locale::facet* wcvt = 0;
#endif
int __err_code;
_Locale_ctype *__lct = _STLP_PRIV __acquire_ctype(name, buf, hint, &__err_code);
if (!__lct) {
locale::_M_throw_on_creation_failure(__err_code, name, "ctype");
return hint;
}
if (hint == 0) hint = _Locale_get_ctype_hint(__lct);
_STLP_TRY {
ct = new ctype_byname<char>(__lct);
}
_STLP_UNWIND(_STLP_PRIV __release_ctype(__lct));
_STLP_TRY {
cvt = new codecvt_byname<char, char, mbstate_t>(name);
}
_STLP_UNWIND(delete ct);
#ifndef _STLP_NO_WCHAR_T
_STLP_TRY {
_Locale_ctype *__lwct = _STLP_PRIV __acquire_ctype(name, buf, hint, &__err_code);
if (!__lwct) {
locale::_M_throw_on_creation_failure(__err_code, name, "ctype");
return hint;
}
_STLP_TRY {
wct = new ctype_byname<wchar_t>(__lwct);
}
_STLP_UNWIND(_STLP_PRIV __release_ctype(__lwct));
_Locale_codecvt *__lwcvt = _STLP_PRIV __acquire_codecvt(name, buf, hint, &__err_code);
if (__lwcvt) {
_STLP_TRY {
wcvt = new codecvt_byname<wchar_t, char, mbstate_t>(__lwcvt);
}
_STLP_UNWIND(_STLP_PRIV __release_codecvt(__lwcvt); delete wct);
}
}
_STLP_UNWIND(delete cvt; delete ct);
#endif
this->insert(ct, ctype<char>::id);
this->insert(cvt, codecvt<char, char, mbstate_t>::id);
#ifndef _STLP_NO_WCHAR_T
this->insert(wct, ctype<wchar_t>::id);
if (wcvt) this->insert(wcvt, codecvt<wchar_t, char, mbstate_t>::id);
#endif
}
return hint;
}
_Locale_name_hint* _Locale_impl::insert_numeric_facets(const char* &name, char *buf, _Locale_name_hint* hint) {
if (name[0] == 0)
name = _Locale_numeric_default(buf);
_Locale_impl* i2 = locale::classic()._M_impl;
// We first insert name independant facets taken from the classic locale instance:
this->insert(i2,
num_put<char, ostreambuf_iterator<char, char_traits<char> > >::id);
this->insert(i2,
num_get<char, istreambuf_iterator<char, char_traits<char> > >::id);
#ifndef _STLP_NO_WCHAR_T
this->insert(i2,
num_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id);
this->insert(i2,
num_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id);
#endif
if (name == 0 || name[0] == 0 || is_C_locale_name(name)) {
this->insert(i2, numpunct<char>::id);
#ifndef _STLP_NO_WCHAR_T
this->insert(i2, numpunct<wchar_t>::id);
#endif
}
else {
locale::facet* punct = 0;
#ifndef _STLP_NO_WCHAR_T
locale::facet* wpunct = 0;
#endif
int __err_code;
_Locale_numeric *__lpunct = _STLP_PRIV __acquire_numeric(name, buf, hint, &__err_code);
if (!__lpunct) {
locale::_M_throw_on_creation_failure(__err_code, name, "numpunct");
return hint;
}
if (hint == 0) hint = _Locale_get_numeric_hint(__lpunct);
_STLP_TRY {
punct = new numpunct_byname<char>(__lpunct);
}
_STLP_UNWIND(_STLP_PRIV __release_numeric(__lpunct));
#ifndef _STLP_NO_WCHAR_T
_Locale_numeric *__lwpunct = _STLP_PRIV __acquire_numeric(name, buf, hint, &__err_code);
if (!__lwpunct) {
delete punct;
locale::_M_throw_on_creation_failure(__err_code, name, "numpunct");
return hint;
}
if (__lwpunct) {
_STLP_TRY {
wpunct = new numpunct_byname<wchar_t>(__lwpunct);
}
_STLP_UNWIND(_STLP_PRIV __release_numeric(__lwpunct); delete punct);
}
#endif
this->insert(punct, numpunct<char>::id);
#ifndef _STLP_NO_WCHAR_T
this->insert(wpunct, numpunct<wchar_t>::id);
#endif
}
return hint;
}
_Locale_name_hint* _Locale_impl::insert_time_facets(const char* &name, char *buf, _Locale_name_hint* hint) {
if (name[0] == 0)
name = _Locale_time_default(buf);
if (name == 0 || name[0] == 0 || is_C_locale_name(name)) {
_Locale_impl* i2 = locale::classic()._M_impl;
this->insert(i2,
time_get<char, istreambuf_iterator<char, char_traits<char> > >::id);
this->insert(i2,
time_put<char, ostreambuf_iterator<char, char_traits<char> > >::id);
#ifndef _STLP_NO_WCHAR_T
this->insert(i2,
time_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id);
this->insert(i2,
time_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id);
#endif
} else {
locale::facet *get = 0;
locale::facet *put = 0;
#ifndef _STLP_NO_WCHAR_T
locale::facet *wget = 0;
locale::facet *wput = 0;
#endif
int __err_code;
_Locale_time *__time = _STLP_PRIV __acquire_time(name, buf, hint, &__err_code);
if (!__time) {
// time facets category is not mandatory for correct stream behavior so if platform
// do not support it we do not generate a runtime_error exception.
if (__err_code == _STLP_LOC_NO_MEMORY) {
_STLP_THROW_BAD_ALLOC;
}
return hint;
}
if (!hint) hint = _Locale_get_time_hint(__time);
_STLP_TRY {
get = new time_get_byname<char, istreambuf_iterator<char, char_traits<char> > >(__time);
put = new time_put_byname<char, ostreambuf_iterator<char, char_traits<char> > >(__time);
#ifndef _STLP_NO_WCHAR_T
wget = new time_get_byname<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >(__time);
wput = new time_put_byname<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >(__time);
#endif
}
#ifndef _STLP_NO_WCHAR_T
_STLP_UNWIND(delete wget; delete put; delete get; _STLP_PRIV __release_time(__time));
#else
_STLP_UNWIND(delete get; _STLP_PRIV __release_time(__time));
#endif
_STLP_PRIV __release_time(__time);
this->insert(get, time_get<char, istreambuf_iterator<char, char_traits<char> > >::id);
this->insert(put, time_put<char, ostreambuf_iterator<char, char_traits<char> > >::id);
#ifndef _STLP_NO_WCHAR_T
this->insert(wget, time_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id);
this->insert(wput, time_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id);
#endif
}
return hint;
}
_Locale_name_hint* _Locale_impl::insert_collate_facets(const char* &name, char *buf, _Locale_name_hint* hint) {
if (name[0] == 0)
name = _Locale_collate_default(buf);
if (name == 0 || name[0] == 0 || is_C_locale_name(name)) {
_Locale_impl* i2 = locale::classic()._M_impl;
this->insert(i2, collate<char>::id);
#ifndef _STLP_NO_WCHAR_T
this->insert(i2, collate<wchar_t>::id);
#endif
}
else {
locale::facet *col = 0;
#ifndef _STLP_NO_WCHAR_T
locale::facet *wcol = 0;
#endif
int __err_code;
_Locale_collate *__coll = _STLP_PRIV __acquire_collate(name, buf, hint, &__err_code);
if (!__coll) {
if (__err_code == _STLP_LOC_NO_MEMORY) {
_STLP_THROW_BAD_ALLOC;
}
return hint;
}
if (hint == 0) hint = _Locale_get_collate_hint(__coll);
_STLP_TRY {
col = new collate_byname<char>(__coll);
}
_STLP_UNWIND(_STLP_PRIV __release_collate(__coll));
#ifndef _STLP_NO_WCHAR_T
_Locale_collate *__wcoll = _STLP_PRIV __acquire_collate(name, buf, hint, &__err_code);
if (!__wcoll) {
if (__err_code == _STLP_LOC_NO_MEMORY) {
delete col;
_STLP_THROW_BAD_ALLOC;
}
}
if (__wcoll) {
_STLP_TRY {
wcol = new collate_byname<wchar_t>(__wcoll);
}
_STLP_UNWIND(_STLP_PRIV __release_collate(__wcoll); delete col);
}
#endif
this->insert(col, collate<char>::id);
#ifndef _STLP_NO_WCHAR_T
if (wcol) this->insert(wcol, collate<wchar_t>::id);
#endif
}
return hint;
}
_Locale_name_hint* _Locale_impl::insert_monetary_facets(const char* &name, char *buf, _Locale_name_hint* hint) {
if (name[0] == 0)
name = _Locale_monetary_default(buf);
_Locale_impl* i2 = locale::classic()._M_impl;
// We first insert name independant facets taken from the classic locale instance:
this->insert(i2, money_get<char, istreambuf_iterator<char, char_traits<char> > >::id);
this->insert(i2, money_put<char, ostreambuf_iterator<char, char_traits<char> > >::id);
#ifndef _STLP_NO_WCHAR_T
this->insert(i2, money_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id);
this->insert(i2, money_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id);
#endif
if (name == 0 || name[0] == 0 || is_C_locale_name(name)) {
this->insert(i2, moneypunct<char, false>::id);
this->insert(i2, moneypunct<char, true>::id);
#ifndef _STLP_NO_WCHAR_T
this->insert(i2, moneypunct<wchar_t, false>::id);
this->insert(i2, moneypunct<wchar_t, true>::id);
#endif
}
else {
locale::facet *punct = 0;
locale::facet *ipunct = 0;
#ifndef _STLP_NO_WCHAR_T
locale::facet* wpunct = 0;
locale::facet* wipunct = 0;
#endif
int __err_code;
_Locale_monetary *__mon = _STLP_PRIV __acquire_monetary(name, buf, hint, &__err_code);
if (!__mon) {
if (__err_code == _STLP_LOC_NO_MEMORY) {
_STLP_THROW_BAD_ALLOC;
}
return hint;
}
if (hint == 0) hint = _Locale_get_monetary_hint(__mon);
_STLP_TRY {
punct = new moneypunct_byname<char, false>(__mon);
}
_STLP_UNWIND(_STLP_PRIV __release_monetary(__mon));
_Locale_monetary *__imon = _STLP_PRIV __acquire_monetary(name, buf, hint, &__err_code);
if (!__imon) {
delete punct;
if (__err_code == _STLP_LOC_NO_MEMORY) {
_STLP_THROW_BAD_ALLOC;
}
return hint;
}
_STLP_TRY {
ipunct = new moneypunct_byname<char, true>(__imon);
}
_STLP_UNWIND(_STLP_PRIV __release_monetary(__imon); delete punct);
#ifndef _STLP_NO_WCHAR_T
_STLP_TRY {
_Locale_monetary *__wmon = _STLP_PRIV __acquire_monetary(name, buf, hint, &__err_code);
if (!__wmon) {
if (__err_code == _STLP_LOC_NO_MEMORY) {
_STLP_THROW_BAD_ALLOC;
}
}
if (__wmon) {
_STLP_TRY {
wpunct = new moneypunct_byname<wchar_t, false>(__wmon);
}
_STLP_UNWIND(_STLP_PRIV __release_monetary(__wmon));
_Locale_monetary *__wimon = _STLP_PRIV __acquire_monetary(name, buf, hint, &__err_code);
if (!__wimon) {
delete wpunct;
if (__err_code == _STLP_LOC_NO_MEMORY) {
_STLP_THROW_BAD_ALLOC;
}
wpunct = 0;
}
else {
_STLP_TRY {
wipunct = new moneypunct_byname<wchar_t, true>(__wimon);
}
_STLP_UNWIND(_STLP_PRIV __release_monetary(__wimon); delete wpunct);
}
}
}
_STLP_UNWIND(delete ipunct; delete punct);
#endif
this->insert(punct, moneypunct<char, false>::id);
this->insert(ipunct, moneypunct<char, true>::id);
#ifndef _STLP_NO_WCHAR_T
if (wpunct) this->insert(wpunct, moneypunct<wchar_t, false>::id);
if (wipunct) this->insert(wipunct, moneypunct<wchar_t, true>::id);
#endif
}
return hint;
}
_Locale_name_hint* _Locale_impl::insert_messages_facets(const char* &name, char *buf, _Locale_name_hint* hint) {
if (name[0] == 0)
name = _Locale_messages_default(buf);
if (name == 0 || name[0] == 0 || is_C_locale_name(name)) {
_Locale_impl* i2 = locale::classic()._M_impl;
this->insert(i2, messages<char>::id);
#ifndef _STLP_NO_WCHAR_T
this->insert(i2, messages<wchar_t>::id);
#endif
}
else {
locale::facet *msg = 0;
#ifndef _STLP_NO_WCHAR_T
locale::facet *wmsg = 0;
#endif
int __err_code;
_Locale_messages *__msg = _STLP_PRIV __acquire_messages(name, buf, hint, &__err_code);
if (!__msg) {
if (__err_code == _STLP_LOC_NO_MEMORY) {
_STLP_THROW_BAD_ALLOC;
}
return hint;
}
_STLP_TRY {
msg = new messages_byname<char>(__msg);
}
_STLP_UNWIND(_STLP_PRIV __release_messages(__msg));
#ifndef _STLP_NO_WCHAR_T
_STLP_TRY {
_Locale_messages *__wmsg = _STLP_PRIV __acquire_messages(name, buf, hint, &__err_code);
if (!__wmsg) {
if (__err_code == _STLP_LOC_NO_MEMORY) {
_STLP_THROW_BAD_ALLOC;
}
}
if (__wmsg) {
_STLP_TRY {
wmsg = new messages_byname<wchar_t>(__wmsg);
}
_STLP_UNWIND(_STLP_PRIV __release_messages(__wmsg));
}
}
_STLP_UNWIND(delete msg);
#endif
this->insert(msg, messages<char>::id);
#ifndef _STLP_NO_WCHAR_T
if (wmsg) this->insert(wmsg, messages<wchar_t>::id);
#endif
}
return hint;
}
static void _Stl_loc_assign_ids() {
// This assigns ids to every facet that is a member of a category,
// and also to money_get/put, num_get/put, and time_get/put
// instantiated using ordinary pointers as the input/output
// iterators. (The default is [io]streambuf_iterator.)
money_get<char, istreambuf_iterator<char, char_traits<char> > >::id._M_index = 8;
money_put<char, ostreambuf_iterator<char, char_traits<char> > >::id._M_index = 9;
num_get<char, istreambuf_iterator<char, char_traits<char> > >::id._M_index = 10;
num_put<char, ostreambuf_iterator<char, char_traits<char> > >::id._M_index = 11;
time_get<char, istreambuf_iterator<char, char_traits<char> > >::id._M_index = 12;
time_put<char, ostreambuf_iterator<char, char_traits<char> > >::id._M_index = 13;
#ifndef _STLP_NO_WCHAR_T
money_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id._M_index = 21;
money_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id._M_index = 22;
num_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id._M_index = 23;
num_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > > ::id._M_index = 24;
time_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id._M_index = 25;
time_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id._M_index = 26;
#endif
// locale::id::_S_max = 27;
}
// To access those static instance use the getter below, they guaranty
// a correct initialization.
static locale *_Stl_classic_locale = 0;
static locale *_Stl_global_locale = 0;
locale* _Stl_get_classic_locale() {
static _Locale_impl::Init init;
return _Stl_classic_locale;
}
locale* _Stl_get_global_locale() {
static _Locale_impl::Init init;
return _Stl_global_locale;
}
#if defined (_STLP_MSVC) || defined (__ICL) || defined (__ISCPP__) || defined (__DMC__)
/*
* The following static variable needs to be initialized before STLport
* users static variable in order for him to be able to use Standard
* streams in its variable initialization.
* This variable is here because MSVC do not allow to change the initialization
* segment in a given translation unit, iostream.cpp already contains an
* initialization segment specification.
*/
# pragma warning (disable : 4073)
# pragma init_seg(lib)
#endif
static ios_base::Init _IosInit;
void _Locale_impl::make_classic_locale() {
// This funcion will be called once: during build classic _Locale_impl
// The classic locale contains every facet that belongs to a category.
static _Stl_aligned_buffer<_Locale_impl> _Locale_classic_impl_buf;
_Locale_impl *classic = new(&_Locale_classic_impl_buf) _Locale_impl("C");
locale::facet* classic_facets[] = {
0,
new collate<char>(1),
new ctype<char>(0, false, 1),
new codecvt<char, char, mbstate_t>(1),
new moneypunct<char, true>(1),
new moneypunct<char, false>(1),
new numpunct<char>(1),
new messages<char>(1),
new money_get<char, istreambuf_iterator<char, char_traits<char> > >(1),
new money_put<char, ostreambuf_iterator<char, char_traits<char> > >(1),
new num_get<char, istreambuf_iterator<char, char_traits<char> > >(1),
new num_put<char, ostreambuf_iterator<char, char_traits<char> > >(1),
new time_get<char, istreambuf_iterator<char, char_traits<char> > >(1),
new time_put<char, ostreambuf_iterator<char, char_traits<char> > >(1),
#ifndef _STLP_NO_WCHAR_T
new collate<wchar_t>(1),
new ctype<wchar_t>(1),
new codecvt<wchar_t, char, mbstate_t>(1),
new moneypunct<wchar_t, true>(1),
new moneypunct<wchar_t, false>(1),
new numpunct<wchar_t>(1),
new messages<wchar_t>(1),
new money_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >(1),
new money_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >(1),
new num_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >(1),
new num_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >(1),
new time_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >(1),
new time_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >(1),
#endif
0
};
const size_t nb_classic_facets = sizeof(classic_facets) / sizeof(locale::facet *);
classic->facets_vec.reserve(nb_classic_facets);
classic->facets_vec.assign(&classic_facets[0], &classic_facets[0] + nb_classic_facets);
static locale _Locale_classic(classic);
_Stl_classic_locale = &_Locale_classic;
static locale _Locale_global(classic);
_Stl_global_locale = &_Locale_global;
}
// Declarations of (non-template) facets' static data members
// size_t locale::id::_S_max = 27; // made before
locale::id collate<char>::id = { 1 };
locale::id ctype<char>::id = { 2 };
locale::id codecvt<char, char, mbstate_t>::id = { 3 };
locale::id moneypunct<char, true>::id = { 4 };
locale::id moneypunct<char, false>::id = { 5 };
locale::id numpunct<char>::id = { 6 } ;
locale::id messages<char>::id = { 7 };
#ifndef _STLP_NO_WCHAR_T
locale::id collate<wchar_t>::id = { 14 };
locale::id ctype<wchar_t>::id = { 15 };
locale::id codecvt<wchar_t, char, mbstate_t>::id = { 16 };
locale::id moneypunct<wchar_t, true>::id = { 17 } ;
locale::id moneypunct<wchar_t, false>::id = { 18 } ;
locale::id numpunct<wchar_t>::id = { 19 };
locale::id messages<wchar_t>::id = { 20 };
#endif
_STLP_DECLSPEC _Locale_impl* _STLP_CALL _get_Locale_impl(_Locale_impl *loc)
{
_STLP_ASSERT( loc != 0 );
loc->_M_incr();
return loc;
}
void _STLP_CALL _release_Locale_impl(_Locale_impl *& loc)
{
_STLP_ASSERT( loc != 0 );
if (loc->_M_decr() == 0) {
if (*loc != *_Stl_classic_locale)
delete loc;
else
loc->~_Locale_impl();
loc = 0;
}
}
_STLP_DECLSPEC _Locale_impl* _STLP_CALL _copy_Nameless_Locale_impl(_Locale_impl *loc)
{
_STLP_ASSERT( loc != 0 );
_Locale_impl *loc_new = new _Locale_impl(*loc);
loc_new->name = _Nameless;
return loc_new;
}
/* _GetFacetId implementation have to be here in order to be in the same translation unit
* as where id are initialize (in _Stl_loc_assign_ids) */
_STLP_MOVE_TO_PRIV_NAMESPACE
_STLP_DECLSPEC locale::id& _STLP_CALL _GetFacetId(const money_get<char, istreambuf_iterator<char, char_traits<char> > >*)
{ return money_get<char, istreambuf_iterator<char, char_traits<char> > >::id; }
_STLP_DECLSPEC locale::id& _STLP_CALL _GetFacetId(const money_put<char, ostreambuf_iterator<char, char_traits<char> > >*)
{ return money_put<char, ostreambuf_iterator<char, char_traits<char> > >::id; }
#ifndef _STLP_NO_WCHAR_T
_STLP_DECLSPEC locale::id& _STLP_CALL _GetFacetId(const money_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >*)
{ return money_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id; }
_STLP_DECLSPEC locale::id& _STLP_CALL _GetFacetId(const money_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >*)
{ return money_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id; }
#endif
_STLP_DECLSPEC locale::id& _STLP_CALL _GetFacetId(const num_get<char, istreambuf_iterator<char, char_traits<char> > >*)
{ return num_get<char, istreambuf_iterator<char, char_traits<char> > >::id; }
#ifndef _STLP_NO_WCHAR_T
_STLP_DECLSPEC locale::id& _STLP_CALL _GetFacetId(const num_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >*)
{ return num_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id; }
#endif
_STLP_DECLSPEC locale::id& _STLP_CALL _GetFacetId(const num_put<char, ostreambuf_iterator<char, char_traits<char> > >*)
{ return num_put<char, ostreambuf_iterator<char, char_traits<char> > >::id; }
#ifndef _STLP_NO_WCHAR_T
_STLP_DECLSPEC locale::id& _STLP_CALL _GetFacetId(const num_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >*)
{ return num_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id; }
#endif
_STLP_DECLSPEC locale::id& _STLP_CALL _GetFacetId(const time_get<char, istreambuf_iterator<char, char_traits<char> > >*)
{ return time_get<char, istreambuf_iterator<char, char_traits<char> > >::id; }
_STLP_DECLSPEC locale::id& _STLP_CALL _GetFacetId(const time_put<char, ostreambuf_iterator<char, char_traits<char> > >*)
{ return time_put<char, ostreambuf_iterator<char, char_traits<char> > >::id; }
#ifndef _STLP_NO_WCHAR_T
_STLP_DECLSPEC locale::id& _STLP_CALL _GetFacetId(const time_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >*)
{ return time_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id; }
_STLP_DECLSPEC locale::id& _STLP_CALL _GetFacetId(const time_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >*)
{ return time_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id; }
#endif
_STLP_MOVE_TO_STD_NAMESPACE
_STLP_END_NAMESPACE

Просмотреть файл

@ -1,133 +0,0 @@
/*
* Copyright (c) 1999
* Silicon Graphics Computer Systems, Inc.
*
* Copyright (c) 1999
* Boris Fomitchev
*
* This material is provided "as is", with absolutely no warranty expressed
* or implied. Any use is at your own risk.
*
* Permission to use or copy this software for any purpose is hereby granted
* without fee, provided the above notices are retained on all copies.
* Permission to modify the code and to distribute modified code is granted,
* provided the above notices are retained, and a notice that the code was
* modified is included with the above copyright notice.
*
*/
#ifndef LOCALE_IMPL_H
#define LOCALE_IMPL_H
#include <clocale> // C locale header file.
#include <vector>
#include <string>
#include <locale>
#include "c_locale.h"
_STLP_BEGIN_NAMESPACE
#if defined (_STLP_USE_TEMPLATE_EXPORT)
//Export of _Locale_impl facets container:
# if !defined (_STLP_USE_PTR_SPECIALIZATIONS)
//If we are using pointer specialization, vector<locale::facet*> will use
//the already exported vector<void*> implementation.
_STLP_EXPORT_TEMPLATE_CLASS allocator<locale::facet*>;
_STLP_MOVE_TO_PRIV_NAMESPACE
_STLP_EXPORT_TEMPLATE_CLASS _STLP_alloc_proxy<locale::facet**, locale::facet*, allocator<locale::facet*> >;
_STLP_EXPORT_TEMPLATE_CLASS _Vector_base<locale::facet*, allocator<locale::facet*> >;
_STLP_MOVE_TO_STD_NAMESPACE
# endif
# if defined (_STLP_DEBUG)
_STLP_MOVE_TO_PRIV_NAMESPACE
# define _STLP_NON_DBG_VECTOR _STLP_NON_DBG_NAME(vector)
_STLP_EXPORT_TEMPLATE_CLASS __construct_checker<_STLP_NON_DBG_VECTOR<locale::facet*, allocator<locale::facet*> > >;
_STLP_EXPORT_TEMPLATE_CLASS _STLP_NON_DBG_VECTOR<locale::facet*, allocator<locale::facet*> >;
# undef _STLP_NON_DBG_VECTOR
_STLP_MOVE_TO_STD_NAMESPACE
# endif
_STLP_EXPORT_TEMPLATE_CLASS vector<locale::facet*, allocator<locale::facet*> >;
#endif
//----------------------------------------------------------------------
// Class _Locale_impl
// This is the base class which implements access only and is supposed to
// be used for classic locale only
class _STLP_CLASS_DECLSPEC _Locale_impl : public _Refcount_Base {
public:
_Locale_impl(const char* s);
_Locale_impl(const _Locale_impl&);
_Locale_impl(size_t n, const char* s);
private:
~_Locale_impl();
public:
size_t size() const { return facets_vec.size(); }
basic_string<char, char_traits<char>, allocator<char> > name;
static void _STLP_FUNCTION_THROWS _STLP_CALL _M_throw_bad_cast();
private:
void operator=(const _Locale_impl&);
public:
class _STLP_CLASS_DECLSPEC Init {
public:
Init();
~Init();
private:
_Refcount_Base& _M_count() const;
};
static void _STLP_CALL _S_initialize();
static void _STLP_CALL _S_uninitialize();
static void make_classic_locale();
static void free_classic_locale();
friend class Init;
public:
// void remove(size_t index);
locale::facet* insert(locale::facet*, const locale::id& n);
void insert(_Locale_impl* from, const locale::id& n);
// Helper functions for byname construction of locales.
_Locale_name_hint* insert_ctype_facets(const char* &name, char *buf, _Locale_name_hint* hint);
_Locale_name_hint* insert_numeric_facets(const char* &name, char *buf, _Locale_name_hint* hint);
_Locale_name_hint* insert_time_facets(const char* &name, char *buf, _Locale_name_hint* hint);
_Locale_name_hint* insert_collate_facets(const char* &name, char *buf, _Locale_name_hint* hint);
_Locale_name_hint* insert_monetary_facets(const char* &name, char *buf, _Locale_name_hint* hint);
_Locale_name_hint* insert_messages_facets(const char* &name, char *buf, _Locale_name_hint* hint);
bool operator != (const locale& __loc) const { return __loc._M_impl != this; }
private:
vector<locale::facet*> facets_vec;
private:
friend _Locale_impl * _STLP_CALL _copy_Nameless_Locale_impl( _Locale_impl * );
friend void _STLP_CALL _release_Locale_impl( _Locale_impl *& loc );
#if defined (_STLP_USE_MSVC6_MEM_T_BUG_WORKAROUND) || \
defined (_STLP_SIGNAL_RUNTIME_COMPATIBILITY) || defined (_STLP_CHECK_RUNTIME_COMPATIBILITY)
friend class _STLP_NO_MEM_T_NAME(loc);
#else
friend class locale;
#endif
};
void _STLP_CALL _release_Locale_impl( _Locale_impl *& loc );
_STLP_END_NAMESPACE
#endif
// Local Variables:
// mode:C++
// End:

Просмотреть файл

@ -1,307 +0,0 @@
/*
* Copyright (c) 1997-1999
* Silicon Graphics Computer Systems, Inc.
*
* Copyright (c) 1999
* Boris Fomitchev
*
* This material is provided "as is", with absolutely no warranty expressed
* or implied. Any use is at your own risk.
*
* Permission to use or copy this software for any purpose is hereby granted
* without fee, provided the above notices are retained on all copies.
* Permission to modify the code and to distribute modified code is granted,
* provided the above notices are retained, and a notice that the code was
* modified is included with the above copyright notice.
*
*/
#ifndef _STLP_LOCK_FREE_SLIST_H
#define _STLP_LOCK_FREE_SLIST_H
#if defined(_STLP_PTHREADS)
# include <pthread.h>
# if defined (__GNUC__) && defined (__i386__)
# define _STLP_HAS_ATOMIC_FREELIST
/**
* Class that implements a non-blocking and thread-safe freelist.
* It is used for the lock-free node allocation engine.
*
* @author felixw@inin.com
*/
class _STLP_atomic_freelist {
public:
/**
* Type representing items of the freelist
*/
struct item {
item* _M_next;
};
_STLP_atomic_freelist() {
// Statically assert layout of member is as expected by assembly code
_STLP_STATIC_ASSERT(sizeof(_M) == 8)
_M._M_data._M_top = 0;
_M._M_data._M_sequence = 0;
}
/**
* Atomically pushes the specified item onto the freelist.
*
* @param __item [in] Item to add to the front of the list
*/
void push(item* __item) {
// NOTE: GCC uses ebx as the PIC register for globals in shared libraries.
// The GCC version I'm using (3.4.1) won't temporarily spill it if it's
// used as input, output, or clobber. Instead, it complains with a
// "can't find a register in class `BREG' while reloading `asm'" error.
// This is probably a compiler bug, but as the cmpxchg8b instruction
// requires ebx, I work around this here by using ecx for the '__item'
// input and spilling ebx into edi. This also precludes us from using
// a "m" operand for the cmpxchg8b argument (GCC might think it can make
// it relative to ebx). Instead, we're using esi for the address of _M_data.
//
int __tmp1; // These dummy variables are used to tell GCC that the eax, ecx,
int __tmp2; // and edx registers will not have the same value as their input.
int __tmp3; // The optimizer will remove them as their values are not used.
__asm__ __volatile__
(" movl %%ebx, %%edi\n\t"
" movl %%ecx, %%ebx\n\t"
"L1_%=: movl %%eax, (%%ebx)\n\t" // __item._M_next = _M._M_data._M_top
" leal 1(%%edx),%%ecx\n\t" // new sequence = _M._M_data._M_sequence + 1
"lock; cmpxchg8b (%%esi)\n\t"
" jne L1_%=\n\t" // Failed, retry! (edx:eax now contain most recent _M_sequence:_M_top)
" movl %%edi, %%ebx"
:"=a" (__tmp1), "=d" (__tmp2), "=c" (__tmp3)
:"a" (_M._M_data._M_top), "d" (_M._M_data._M_sequence), "c" (__item), "S" (&_M._M_data)
:"edi", "memory", "cc");
}
/**
* Atomically removes the topmost item from the freelist and returns a
* pointer to it. Returns NULL if the list is empty.
*
* @return Item that was removed from front of list; NULL if list empty
*/
item* pop() {
item* __result;
int __tmp;
__asm__ __volatile__
(" movl %%ebx, %%edi\n\t"
"L1_%=: testl %%eax, %%eax\n\t" // _M_top == NULL?
" je L2_%=\n\t" // If yes, we're done
" movl (%%eax), %%ebx\n\t" // new top = _M._M_data._M_top->_M_next
" leal 1(%%edx),%%ecx\n\t" // new sequence = _M._M_data._M_sequence + 1
"lock; cmpxchg8b (%%esi)\n\t"
" jne L1_%=\n\t" // We failed, retry! (edx:eax now contain most recent _M_sequence:_M_top)
"L2_%=: movl %%edi, %%ebx"
:"=a" (__result), "=d" (__tmp)
:"a" (_M._M_data._M_top), "d" (_M._M_data._M_sequence), "S" (&_M._M_data)
:"edi", "ecx", "memory", "cc");
return __result;
}
/**
* Atomically detaches all items from the list and returns a pointer to the
* topmost item. The items are still chained and may be traversed safely as
* they're now "owned" by the calling thread.
*
* @return Pointer to topmost item in the list; NULL if list empty
*/
item* clear() {
item* __result;
int __tmp;
__asm__ __volatile__
(" movl %%ebx, %%edi\n\t"
"L1_%=: testl %%eax, %%eax\n\t" // _M_top == NULL?
" je L2_%=\n\t" // If yes, we're done
" xorl %%ebx, %%ebx\n\t" // We're attempting to set _M_top to NULL
" leal 1(%%edx),%%ecx\n\t" // new sequence = _M._M_data._M_sequence + 1
"lock; cmpxchg8b (%%esi)\n\t"
" jne L1_%=\n\t" // Failed, retry! (edx:eax now contain most recent _M_sequence:_M_top)
"L2_%=: movl %%edi, %%ebx"
:"=a" (__result), "=d" (__tmp)
:"a" (_M._M_data._M_top), "d" (_M._M_data._M_sequence), "S" (&_M._M_data)
:"edi", "ecx", "memory", "cc");
return __result;
}
private:
union {
long long _M_align;
struct {
item* _M_top; // Topmost element in the freelist
unsigned int _M_sequence; // Sequence counter to prevent "ABA problem"
} _M_data;
} _M;
_STLP_atomic_freelist(const _STLP_atomic_freelist&);
_STLP_atomic_freelist& operator=(const _STLP_atomic_freelist&);
};
# endif /* if defined(__GNUC__) && defined(__i386__) */
#elif defined (_STLP_WIN32THREADS)
# if !defined (_WIN64)
# define _STLP_USE_ASM_IMPLEMENTATION
# endif
// Here are the compiler/platform requirements for the thread safe and
// lock free singly linked list implementation:
# if defined (_STLP_USE_ASM_IMPLEMENTATION)
// For the asm version:
# if defined (_STLP_MSVC) && defined (_M_IX86) && (_M_IX86 >= 500)
# define _STLP_HAS_ATOMIC_FREELIST
# endif
# else
// For the API based version:
# if defined (_STLP_NEW_PLATFORM_SDK) && (!defined (WINVER) || (WINVER >= 0x0501)) && \
(!defined (_WIN32_WINNT) || (_WIN32_WINNT >= 0x0501))
# define _STLP_HAS_ATOMIC_FREELIST
# endif
# endif
# if defined (_STLP_HAS_ATOMIC_FREELIST)
# if defined (_STLP_USE_ASM_IMPLEMENTATION)
# if defined (_STLP_MSVC) && (_STLP_MSVC < 1300) || defined (__ICL)
# pragma warning (push)
# pragma warning (disable : 4035) //function has no return value
# endif
# endif
/**
* Class that implements a non-blocking and thread-safe freelist.
* It is used for the lock-free node allocation engine.
*
* @author felixw@inin.com
*/
class _STLP_atomic_freelist {
public:
/**
* Type representing items of the freelist
*/
# if defined (_STLP_USE_ASM_IMPLEMENTATION)
struct item {
item* _M_next;
};
# else
typedef SLIST_ENTRY item;
# endif
_STLP_atomic_freelist() {
// Statically assert layout of member is as expected by assembly code
# if defined (_STLP_USE_ASM_IMPLEMENTATION)
_STLP_STATIC_ASSERT((sizeof(item) == sizeof(item*)) && (sizeof(_M) == 8))
_M._M_data._M_top = 0;
_M._M_data._M_sequence = 0;
# else
InitializeSListHead(&_M_head);
# endif
}
/**
* Atomically pushes the specified item onto the freelist.
*
* @param __item [in] Item to add to the front of the list
*/
void push(item* __item) {
# if defined (_STLP_USE_ASM_IMPLEMENTATION)
__asm
{
mov esi, this
mov ebx, __item
mov eax, [esi] // _M._M_data._M_top
mov edx, [esi+4] // _M._M_data._M_sequence
L1: mov [ebx], eax // __item._M_next = _M._M_data._M_top
lea ecx, [edx+1] // new sequence = _M._M_data._M_sequence + 1
lock cmpxchg8b qword ptr [esi]
jne L1 // Failed, retry! (edx:eax now contain most recent _M_sequence:_M_top)
}
# else
InterlockedPushEntrySList(&_M_head, __item);
# endif
}
/**
* Atomically removes the topmost item from the freelist and returns a
* pointer to it. Returns NULL if the list is empty.
*
* @return Item that was removed from front of list; NULL if list empty
*/
item* pop() {
# if defined (_STLP_USE_ASM_IMPLEMENTATION)
__asm
{
mov esi, this
mov eax, [esi] // _M._M_data._M_top
mov edx, [esi+4] // _M._M_data._M_sequence
L1: test eax, eax // _M_top == NULL?
je L2 // Yes, we're done
mov ebx, [eax] // new top = _M._M_data._M_top->_M_next
lea ecx, [edx+1] // new sequence = _M._M_data._M_sequence + 1
lock cmpxchg8b qword ptr [esi]
jne L1 // Failed, retry! (edx:eax now contain most recent _M_sequence:_M_top)
L2:
}
# else
return InterlockedPopEntrySList(&_M_head);
# endif
}
/**
* Atomically detaches all items from the list and returns pointer to the
* topmost. The items are still chained and may be traversed safely as
* they're now "owned" by the calling thread.
*
* @return Pointer to topmost item in the list; NULL if list empty
*/
item* clear() {
# if defined (_STLP_USE_ASM_IMPLEMENTATION)
__asm
{
mov esi, this
mov eax, [esi] // _M._M_data._M_top
mov edx, [esi+4] // _M._M_data._M_sequence
L1: test eax, eax // _M_top == NULL?
je L2 // Yes, we're done
xor ebx,ebx // We're attempting to set _M._M_data._M_top to NULL
lea ecx, [edx+1] // new sequence = _M._M_data._M_sequence + 1
lock cmpxchg8b qword ptr [esi]
jne L1 // Failed, retry! (edx:eax now contain most recent _M_sequence:_M_top)
L2:
}
# else
return InterlockedFlushSList(&_M_head);
# endif
}
private:
# if defined (_STLP_USE_ASM_IMPLEMENTATION)
union {
__int64 _M_align;
struct {
item* _M_top; // Topmost element in the freelist
unsigned int _M_sequence; // Sequence counter to prevent "ABA problem"
} _M_data;
} _M;
# else
SLIST_HEADER _M_head;
# endif
_STLP_atomic_freelist(const _STLP_atomic_freelist&);
_STLP_atomic_freelist& operator = (const _STLP_atomic_freelist&);
};
# if defined (_STLP_USE_ASM_IMPLEMENTATION)
# if defined (_STLP_MSVC) && (_STLP_MSVC < 1300) || defined (__ICL)
# pragma warning (pop)
# endif
# endif
# endif /* _STLP_HAS_ATOMIC_FREELIST */
#endif
#endif /* _STLP_LOCK_FREE_SLIST_H */

Просмотреть файл

@ -1,152 +0,0 @@
/*
* Copyright (c) 1999
* Silicon Graphics Computer Systems, Inc.
*
* Copyright (c) 1999
* Boris Fomitchev
*
* This material is provided "as is", with absolutely no warranty expressed
* or implied. Any use is at your own risk.
*
* Permission to use or copy this software for any purpose is hereby granted
* without fee, provided the above notices are retained on all copies.
* Permission to modify the code and to distribute modified code is granted,
* provided the above notices are retained, and a notice that the code was
* modified is included with the above copyright notice.
*
*/
#ifndef MESSAGE_FACETS_H
#define MESSAGE_FACETS_H
#include <string>
#include <locale>
#include <hash_map>
#include "c_locale.h"
_STLP_BEGIN_NAMESPACE
_STLP_MOVE_TO_PRIV_NAMESPACE
// Class _Catalog_locale_map. The reason for this is that, internally,
// a message string is always a char*. We need a ctype facet to convert
// a string to and from wchar_t, and the user is permitted to provide such
// a facet when calling open().
struct _Catalog_locale_map {
_Catalog_locale_map() : M(0) {}
~_Catalog_locale_map() { if (M) delete M; }
void insert(nl_catd_type key, const locale& L);
locale lookup(nl_catd_type key) const;
void erase(nl_catd_type key);
typedef hash_map<nl_catd_type, locale, hash<nl_catd_type>, equal_to<nl_catd_type>,
allocator<pair<_STLP_CONST nl_catd_type, locale> > > map_type;
map_type *M;
private: // Invalidate copy constructor and assignment
_Catalog_locale_map(const _Catalog_locale_map&);
void operator=(const _Catalog_locale_map&);
};
/*
* In glibc nl_catd type is void *, but messages_base::catalog is defined as int
* by ISO/IEC 14882; The int may be too short to store pointer on 64-bit platforms;
* Another problem, is that do_open() may return negative value to indicate that no
* catalog open---this case can't be represented with pointers.
* The class _Catalog_nl_catd_map intended to make relation between
* messages_base::catalog and nl_catd handler.
*
*/
#if defined (_STLP_USE_GLIBC2_LOCALIZATION)
# define _STLP_USE_NL_CATD_MAPPING
#else
/* If no mapping a message_base::catalog entry, int typedef according C++ Standard 22.2.7.1,
* has to be large enough to contain a nl_catd_type value.
*/
_STLP_STATIC_ASSERT(sizeof(nl_catd_type) <= sizeof(int))
#endif
class _STLP_CLASS_DECLSPEC _Catalog_nl_catd_map {
public:
_Catalog_nl_catd_map()
{}
~_Catalog_nl_catd_map()
{}
typedef hash_map<messages_base::catalog, nl_catd_type, hash<messages_base::catalog>, equal_to<messages_base::catalog>,
allocator<pair<_STLP_CONST messages_base::catalog, nl_catd_type> > > map_type;
typedef hash_map<nl_catd_type, messages_base::catalog, hash<nl_catd_type>, equal_to<nl_catd_type>,
allocator<pair<_STLP_CONST nl_catd_type, messages_base::catalog> > > rmap_type;
// typedef map<messages_base::catalog,nl_catd_type> map_type;
// typedef map<nl_catd_type,messages_base::catalog> rmap_type;
messages_base::catalog insert(nl_catd_type cat)
#if !defined (_STLP_USE_NL_CATD_MAPPING)
{ return (messages_base::catalog)cat; }
#else
;
#endif
void erase(messages_base::catalog)
#if !defined (_STLP_USE_NL_CATD_MAPPING)
{}
#else
;
#endif
nl_catd_type operator [] ( messages_base::catalog cat )
#if !defined (_STLP_USE_NL_CATD_MAPPING)
{ return cat; }
#else
{ return cat < 0 ? 0 : M[cat]; }
#endif
private:
_Catalog_nl_catd_map(const _Catalog_nl_catd_map&);
_Catalog_nl_catd_map& operator =(const _Catalog_nl_catd_map&);
#if defined (_STLP_USE_NL_CATD_MAPPING)
map_type M;
rmap_type Mr;
static _STLP_VOLATILE __stl_atomic_t _count;
#endif
};
class _Messages {
public:
typedef messages_base::catalog catalog;
_Messages(bool, const char *name);
_Messages(bool, _Locale_messages*);
catalog do_open(const string& __fn, const locale& __loc) const;
string do_get(catalog __c, int __set, int __msgid,
const string& __dfault) const;
#if !defined (_STLP_NO_WCHAR_T)
wstring do_get(catalog __c, int __set, int __msgid,
const wstring& __dfault) const;
#endif
void do_close(catalog __c) const;
~_Messages();
private:
_Locale_messages* _M_message_obj;
_Catalog_locale_map* _M_map;
mutable _Catalog_nl_catd_map _M_cat;
//private definition to avoid warning (with ICL)
_Messages(const _Messages&);
_Messages& operator=(const _Messages&);
};
_STLP_MOVE_TO_STD_NAMESPACE
_STLP_END_NAMESPACE
#endif
// Local Variables:
// mode:C++
// End:

Просмотреть файл

@ -1,247 +0,0 @@
/*
* Copyright (c) 1999
* Silicon Graphics Computer Systems, Inc.
*
* Copyright (c) 1999
* Boris Fomitchev
*
* This material is provided "as is", with absolutely no warranty expressed
* or implied. Any use is at your own risk.
*
* Permission to use or copy this software for any purpose is hereby granted
* without fee, provided the above notices are retained on all copies.
* Permission to modify the code and to distribute modified code is granted,
* provided the above notices are retained, and a notice that the code was
* modified is included with the above copyright notice.
*
*/
#include "stlport_prefix.h"
#include <typeinfo>
#include "message_facets.h"
#include "acquire_release.h"
_STLP_BEGIN_NAMESPACE
_STLP_MOVE_TO_PRIV_NAMESPACE
void _Catalog_locale_map::insert(nl_catd_type key, const locale& L) {
_STLP_TRY {
#if !defined (_STLP_NO_TYPEINFO) && !defined (_STLP_NO_RTTI)
// Don't bother to do anything unless we're using a non-default ctype facet
# ifdef _STLP_NO_WCHAR_T
typedef char _Char;
# else
typedef wchar_t _Char;
# endif
typedef ctype<_Char> wctype;
wctype const& wct = use_facet<wctype>(L);
if (typeid(wct) != typeid(wctype)) {
#endif
if (!M)
M = new map_type;
M->insert(map_type::value_type(key, L));
#if !defined (_STLP_NO_TYPEINFO) && !defined (_STLP_NO_RTTI)
}
#endif
}
_STLP_CATCH_ALL {}
}
void _Catalog_locale_map::erase(nl_catd_type key) {
if (M)
M->erase(key);
}
locale _Catalog_locale_map::lookup(nl_catd_type key) const {
if (M) {
map_type::const_iterator i = M->find(key);
return i != M->end() ? (*i).second : locale::classic();
}
else
return locale::classic();
}
#if defined (_STLP_USE_NL_CATD_MAPPING)
_STLP_VOLATILE __stl_atomic_t _Catalog_nl_catd_map::_count = 0;
messages_base::catalog _Catalog_nl_catd_map::insert(nl_catd_type cat) {
messages_base::catalog &res = Mr[cat];
if ( res == 0 ) {
#if defined (_STLP_ATOMIC_INCREMENT)
res = __STATIC_CAST(int, _STLP_ATOMIC_INCREMENT(&_count));
#else
static _STLP_STATIC_MUTEX _Count_lock _STLP_MUTEX_INITIALIZER;
{
_STLP_auto_lock sentry(_Count_lock);
res = __STATIC_CAST(int, ++_count);
}
#endif
M[res] = cat;
}
return res;
}
void _Catalog_nl_catd_map::erase(messages_base::catalog cat) {
map_type::iterator mit(M.find(cat));
if (mit != M.end()) {
Mr.erase((*mit).second);
M.erase(mit);
}
}
#endif
//----------------------------------------------------------------------
//
_Messages::_Messages(bool is_wide, const char *name) :
_M_message_obj(0), _M_map(0) {
if (!name)
locale::_M_throw_on_null_name();
int __err_code;
char buf[_Locale_MAX_SIMPLE_NAME];
_M_message_obj = _STLP_PRIV __acquire_messages(name, buf, 0, &__err_code);
if (!_M_message_obj)
locale::_M_throw_on_creation_failure(__err_code, name, "messages");
if (is_wide)
_M_map = new _Catalog_locale_map;
}
_Messages::_Messages(bool is_wide, _Locale_messages* msg) :
_M_message_obj(msg), _M_map(is_wide ? new _Catalog_locale_map() : 0)
{}
_Messages::~_Messages() {
__release_messages(_M_message_obj);
delete _M_map;
}
_Messages::catalog _Messages::do_open(const string& filename, const locale& L) const {
nl_catd_type result = _M_message_obj ? _Locale_catopen(_M_message_obj, filename.c_str())
: (nl_catd_type)(-1);
if ( result != (nl_catd_type)(-1) ) {
if ( _M_map != 0 ) {
_M_map->insert(result, L);
}
return _STLP_MUTABLE(_Messages_impl, _M_cat).insert( result );
}
return -1;
}
string _Messages::do_get(catalog cat,
int set, int p_id, const string& dfault) const {
return _M_message_obj != 0 && cat >= 0
? string(_Locale_catgets(_M_message_obj, _STLP_MUTABLE(_Messages_impl, _M_cat)[cat],
set, p_id, dfault.c_str()))
: dfault;
}
#if !defined (_STLP_NO_WCHAR_T)
wstring
_Messages::do_get(catalog thecat,
int set, int p_id, const wstring& dfault) const {
typedef ctype<wchar_t> wctype;
const wctype& ct = use_facet<wctype>(_M_map->lookup(_STLP_MUTABLE(_Messages_impl, _M_cat)[thecat]));
const char* str = _Locale_catgets(_M_message_obj, _STLP_MUTABLE(_Messages_impl, _M_cat)[thecat], set, p_id, "");
// Verify that the lookup failed; an empty string might represent success.
if (!str)
return dfault;
else if (str[0] == '\0') {
const char* str2 = _Locale_catgets(_M_message_obj, _STLP_MUTABLE(_Messages_impl, _M_cat)[thecat], set, p_id, "*");
if (!str2 || ((str2[0] == '*') && (str2[1] == '\0')))
return dfault;
}
// str is correct. Now we must widen it to get a wstring.
size_t n = strlen(str);
// NOT PORTABLE. What we're doing relies on internal details of the
// string implementation. (Contiguity of string elements.)
wstring result(n, wchar_t(0));
ct.widen(str, str + n, &*result.begin());
return result;
}
#endif
void _Messages::do_close(catalog thecat) const {
if (_M_message_obj)
_Locale_catclose(_M_message_obj, _STLP_MUTABLE(_Messages_impl, _M_cat)[thecat]);
if (_M_map) _M_map->erase(_STLP_MUTABLE(_Messages_impl, _M_cat)[thecat]);
_STLP_MUTABLE(_Messages_impl, _M_cat).erase( thecat );
}
_STLP_MOVE_TO_STD_NAMESPACE
//----------------------------------------------------------------------
// messages<char>
messages<char>::messages(size_t refs)
: locale::facet(refs) {}
messages_byname<char>::messages_byname(const char *name, size_t refs)
: messages<char>(refs), _M_impl(new _STLP_PRIV _Messages(false, name)) {}
messages_byname<char>::messages_byname(_Locale_messages* msg)
: messages<char>(0), _M_impl(new _STLP_PRIV _Messages(false, msg)) {}
messages_byname<char>::~messages_byname()
{ delete _M_impl; }
messages_byname<char>::catalog
messages_byname<char>::do_open(const string& filename, const locale& l) const
{ return _M_impl->do_open(filename, l); }
string
messages_byname<char>::do_get(catalog cat, int set, int p_id,
const string& dfault) const
{ return _M_impl->do_get(cat, set, p_id, dfault); }
void messages_byname<char>::do_close(catalog cat) const
{ _M_impl->do_close(cat); }
#if !defined (_STLP_NO_WCHAR_T)
//----------------------------------------------------------------------
// messages<wchar_t>
messages<wchar_t>::messages(size_t refs)
: locale::facet(refs) {}
messages_byname<wchar_t>::messages_byname(const char *name, size_t refs)
: messages<wchar_t>(refs), _M_impl(new _STLP_PRIV _Messages(true, name)) {}
messages_byname<wchar_t>::messages_byname(_Locale_messages* msg)
: messages<wchar_t>(0), _M_impl(new _STLP_PRIV _Messages(true, msg)) {}
messages_byname<wchar_t>::~messages_byname()
{ delete _M_impl; }
messages_byname<wchar_t>::catalog
messages_byname<wchar_t>::do_open(const string& filename, const locale& L) const
{ return _M_impl->do_open(filename, L); }
wstring
messages_byname<wchar_t>::do_get(catalog thecat,
int set, int p_id, const wstring& dfault) const
{ return _M_impl->do_get(thecat, set, p_id, dfault); }
void messages_byname<wchar_t>::do_close(catalog cat) const
{ _M_impl->do_close(cat); }
#endif
_STLP_END_NAMESPACE
// Local Variables:
// mode:C++
// End:

Просмотреть файл

@ -1,152 +0,0 @@
/*
* Copyright (c) 1999
* Silicon Graphics Computer Systems, Inc.
*
* Copyright (c) 1999
* Boris Fomitchev
*
* This material is provided "as is", with absolutely no warranty expressed
* or implied. Any use is at your own risk.
*
* Permission to use or copy this software for any purpose is hereby granted
* without fee, provided the above notices are retained on all copies.
* Permission to modify the code and to distribute modified code is granted,
* provided the above notices are retained, and a notice that the code was
* modified is included with the above copyright notice.
*
*/
#include "stlport_prefix.h"
#include <locale>
#include <istream>
_STLP_BEGIN_NAMESPACE
static void _Init_monetary_formats(money_base::pattern& pos_format,
money_base::pattern& neg_format) {
pos_format.field[0] = (char) money_base::symbol;
pos_format.field[1] = (char) money_base::sign;
pos_format.field[2] = (char) money_base::none;
pos_format.field[3] = (char) money_base::value;
neg_format.field[0] = (char) money_base::symbol;
neg_format.field[1] = (char) money_base::sign;
neg_format.field[2] = (char) money_base::none;
neg_format.field[3] = (char) money_base::value;
}
// This is being used throughout the library
static const char _S_empty_string[] = "";
#ifndef _STLP_NO_WCHAR_T
static const wchar_t _S_empty_wstring[] = L"";
#endif
//
// moneypunct<>
//
moneypunct<char, true>::moneypunct(size_t __refs) : locale::facet(__refs)
{ _Init_monetary_formats(_M_pos_format, _M_neg_format); }
moneypunct<char, true>::~moneypunct() {}
char moneypunct<char, true>::do_decimal_point() const {return ' ';}
char moneypunct<char, true>::do_thousands_sep() const {return ' ';}
string moneypunct<char, true>::do_grouping() const { return _S_empty_string; }
string moneypunct<char, true>::do_curr_symbol() const { return _S_empty_string; }
string moneypunct<char, true>::do_positive_sign() const { return _S_empty_string; }
string moneypunct<char, true>::do_negative_sign() const { return _S_empty_string; }
money_base::pattern moneypunct<char, true>::do_pos_format() const {return _M_pos_format;}
money_base::pattern moneypunct<char, true>::do_neg_format() const {return _M_neg_format;}
int moneypunct<char, true>::do_frac_digits() const {return 0;}
moneypunct<char, false>::moneypunct(size_t __refs) : locale::facet(__refs)
{ _Init_monetary_formats(_M_pos_format, _M_neg_format); }
moneypunct<char, false>::~moneypunct() {}
char moneypunct<char, false>::do_decimal_point() const {return ' ';}
char moneypunct<char, false>::do_thousands_sep() const {return ' ';}
string moneypunct<char, false>::do_grouping() const { return _S_empty_string; }
string moneypunct<char, false>::do_curr_symbol() const { return _S_empty_string; }
string moneypunct<char, false>::do_positive_sign() const { return _S_empty_string; }
string moneypunct<char, false>::do_negative_sign() const { return _S_empty_string; }
money_base::pattern moneypunct<char, false>::do_pos_format() const {return _M_pos_format;}
money_base::pattern moneypunct<char, false>::do_neg_format() const {return _M_neg_format;}
int moneypunct<char, false>::do_frac_digits() const {return 0;}
#ifndef _STLP_NO_WCHAR_T
moneypunct<wchar_t, true>::moneypunct(size_t __refs) : locale::facet(__refs)
{ _Init_monetary_formats(_M_pos_format, _M_neg_format); }
moneypunct<wchar_t, true>::~moneypunct() {}
wchar_t moneypunct<wchar_t, true>::do_decimal_point() const {return L' ';}
wchar_t moneypunct<wchar_t, true>::do_thousands_sep() const {return L' ';}
string moneypunct<wchar_t, true>::do_grouping() const {return _S_empty_string;}
wstring moneypunct<wchar_t, true>::do_curr_symbol() const
{return _S_empty_wstring;}
wstring moneypunct<wchar_t, true>::do_positive_sign() const
{return _S_empty_wstring;}
wstring moneypunct<wchar_t, true>::do_negative_sign() const
{return _S_empty_wstring;}
int moneypunct<wchar_t, true>::do_frac_digits() const {return 0;}
money_base::pattern moneypunct<wchar_t, true>::do_pos_format() const
{return _M_pos_format;}
money_base::pattern moneypunct<wchar_t, true>::do_neg_format() const
{return _M_neg_format;}
moneypunct<wchar_t, false>::moneypunct(size_t __refs) : locale::facet(__refs)
{ _Init_monetary_formats(_M_pos_format, _M_neg_format); }
moneypunct<wchar_t, false>::~moneypunct() {}
wchar_t moneypunct<wchar_t, false>::do_decimal_point() const {return L' ';}
wchar_t moneypunct<wchar_t, false>::do_thousands_sep() const {return L' ';}
string moneypunct<wchar_t, false>::do_grouping() const { return _S_empty_string;}
wstring moneypunct<wchar_t, false>::do_curr_symbol() const
{return _S_empty_wstring;}
wstring moneypunct<wchar_t, false>::do_positive_sign() const
{return _S_empty_wstring;}
wstring moneypunct<wchar_t, false>::do_negative_sign() const
{return _S_empty_wstring;}
int moneypunct<wchar_t, false>::do_frac_digits() const {return 0;}
money_base::pattern moneypunct<wchar_t, false>::do_pos_format() const
{return _M_pos_format;}
money_base::pattern moneypunct<wchar_t, false>::do_neg_format() const
{return _M_neg_format;}
#endif /* WCHAR_T */
//
// Instantiations
//
#if !defined (_STLP_NO_FORCE_INSTANTIATE)
template class _STLP_CLASS_DECLSPEC money_get<char, istreambuf_iterator<char, char_traits<char> > >;
template class _STLP_CLASS_DECLSPEC money_put<char, ostreambuf_iterator<char, char_traits<char> > >;
// template class money_put<char, char*>;
# ifndef _STLP_NO_WCHAR_T
template class _STLP_CLASS_DECLSPEC money_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >;
template class _STLP_CLASS_DECLSPEC money_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >;
// template class money_put<wchar_t, wchar_t*>;
// template class money_get<wchar_t, const wchar_t*>;
# endif
#endif
#if !defined (_STLP_STATIC_CONST_INIT_BUG) && !defined (_STLP_NO_STATIC_CONST_DEFINITION)
const bool moneypunct<char, true>::intl;
const bool moneypunct<char, false>::intl;
# ifndef _STLP_NO_WCHAR_T
const bool moneypunct<wchar_t, true>::intl;
const bool moneypunct<wchar_t, false>::intl;
# endif
#endif
_STLP_END_NAMESPACE
// Local Variables:
// mode:C++
// End:

Просмотреть файл

@ -1,120 +0,0 @@
/*
* Copyright (c) 1999
* Silicon Graphics Computer Systems, Inc.
*
* Copyright (c) 1999
* Boris Fomitchev
*
* This material is provided "as is", with absolutely no warranty expressed
* or implied. Any use is at your own risk.
*
* Permission to use or copy this software for any purpose is hereby granted
* without fee, provided the above notices are retained on all copies.
* Permission to modify the code and to distribute modified code is granted,
* provided the above notices are retained, and a notice that the code was
* modified is included with the above copyright notice.
*
*/
#include "stlport_prefix.h"
#include <locale>
#include <istream>
#include <algorithm>
_STLP_BEGIN_NAMESPACE
_STLP_MOVE_TO_PRIV_NAMESPACE
// __valid_grouping compares two strings, one representing the
// group sizes encountered when reading an integer, and the other
// representing the valid group sizes as returned by the numpunct
// grouping() member function. Both are interpreted right-to-left.
// The grouping string is treated as if it were extended indefinitely
// with its last value. For a grouping to be valid, each term in
// the first string must be equal to the corresponding term in the
// second, except for the last, which must be less than or equal.
// boris : this takes reversed first string !
bool _STLP_CALL
__valid_grouping(const char * first1, const char * last1,
const char * first2, const char * last2) {
if (first1 == last1 || first2 == last2) return true;
--last1; --last2;
while (first1 != last1) {
if (*last1 != *first2)
return false;
--last1;
if (first2 != last2) ++first2;
}
return *last1 <= *first2;
}
_STLP_DECLSPEC unsigned char _STLP_CALL __digit_val_table(unsigned __index) {
static const unsigned char __val_table[128] = {
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0, 1, 2, 3, 4, 5, 6, 7, 8, 9,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0xFF,10,11,12,13,14,15,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0xFF,10,11,12,13,14,15,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF
};
return __val_table[__index];
}
_STLP_DECLSPEC const char* _STLP_CALL __narrow_atoms()
{ return "+-0xX"; }
// index is actually a char
#if !defined (_STLP_NO_WCHAR_T)
// Similar, except return the character itself instead of the numeric
// value. Used for floating-point input.
bool _STLP_CALL __get_fdigit(wchar_t& c, const wchar_t* digits) {
const wchar_t* p = find(digits, digits + 10, c);
if (p != digits + 10) {
c = (char)('0' + (p - digits));
return true;
}
else
return false;
}
bool _STLP_CALL __get_fdigit_or_sep(wchar_t& c, wchar_t sep,
const wchar_t * digits) {
if (c == sep) {
c = (char)',';
return true;
}
else
return __get_fdigit(c, digits);
}
#endif
_STLP_MOVE_TO_STD_NAMESPACE
#if !defined(_STLP_NO_FORCE_INSTANTIATE)
//----------------------------------------------------------------------
// Force instantiation of num_get<>
template class _STLP_CLASS_DECLSPEC istreambuf_iterator<char, char_traits<char> >;
// template class num_get<char, const char*>;
template class num_get<char, istreambuf_iterator<char, char_traits<char> > >;
# if !defined (_STLP_NO_WCHAR_T)
template class _STLP_CLASS_DECLSPEC istreambuf_iterator<wchar_t, char_traits<wchar_t> >;
template class num_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >;
// template class num_get<wchar_t, const wchar_t*>;
# endif
#endif
_STLP_END_NAMESPACE
// Local Variables:
// mode:C++
// End:

Просмотреть файл

@ -1,884 +0,0 @@
/*
* Copyright (c) 1999
* Silicon Graphics Computer Systems, Inc.
*
* Copyright (c) 1999
* Boris Fomitchev
*
* This material is provided "as is", with absolutely no warranty expressed
* or implied. Any use is at your own risk.
*
* Permission to use or copy this software for any purpose is hereby granted
* without fee, provided the above notices are retained on all copies.
* Permission to modify the code and to distribute modified code is granted,
* provided the above notices are retained, and a notice that the code was
* modified is included with the above copyright notice.
*
*/
#include "stlport_prefix.h"
#include <limits>
#include <locale>
#include <istream>
#if (defined (__GNUC__) && !defined (__sun) && !defined (__hpux)) || \
defined (__DMC__)
# include <stdint.h>
#endif
#if defined (__linux__) || defined (__MINGW32__) || defined (__CYGWIN__) || \
defined (__BORLANDC__) || defined (__DMC__) || defined (__HP_aCC)
# if defined (__BORLANDC__)
typedef unsigned int uint32_t;
typedef unsigned __int64 uint64_t;
# endif
union _ll {
uint64_t i64;
struct {
# if defined (_STLP_BIG_ENDIAN)
uint32_t hi;
uint32_t lo;
# elif defined (_STLP_LITTLE_ENDIAN)
uint32_t lo;
uint32_t hi;
# else
# error Unknown endianess
# endif
} i32;
};
# if defined (__linux__) && !defined (__ANDROID__)
# include <ieee754.h>
# else
union ieee854_long_double {
long double d;
/* This is the IEEE 854 double-extended-precision format. */
struct {
unsigned int mantissa1:32;
unsigned int mantissa0:32;
unsigned int exponent:15;
unsigned int negative:1;
unsigned int empty:16;
} ieee;
};
# define IEEE854_LONG_DOUBLE_BIAS 0x3fff
# endif
#endif
_STLP_BEGIN_NAMESPACE
_STLP_MOVE_TO_PRIV_NAMESPACE
//----------------------------------------------------------------------
// num_get
// Helper functions for _M_do_get_float.
#if !defined (_STLP_NO_WCHAR_T)
void _STLP_CALL
_Initialize_get_float( const ctype<wchar_t>& ct,
wchar_t& Plus, wchar_t& Minus,
wchar_t& pow_e, wchar_t& pow_E,
wchar_t* digits) {
char ndigits[11] = "0123456789";
Plus = ct.widen('+');
Minus = ct.widen('-');
pow_e = ct.widen('e');
pow_E = ct.widen('E');
ct.widen(ndigits + 0, ndigits + 10, digits);
}
#endif /* WCHAR_T */
/*
* __string_to_double is just lifted from atof, the difference being
* that we just use '.' for the decimal point, rather than let it
* be taken from the current C locale, which of course is not accessible
* to us.
*/
#if defined (_STLP_MSVC) || defined (__BORLANDC__) || defined (__ICL)
typedef unsigned long uint32;
typedef unsigned __int64 uint64;
# define ULL(x) x##Ui64
#elif defined (__unix) || defined (__MINGW32__) || \
(defined (__DMC__) && (__LONGLONG)) || defined (__WATCOMC__) || \
defined (__ANDROID__)
typedef uint32_t uint32;
typedef uint64_t uint64;
# define ULL(x) x##ULL
#else
# error There should be some unsigned 64-bit integer on the system!
#endif
// Multiplication of two 64-bit integers, giving a 128-bit result.
// Taken from Algorithm M in Knuth section 4.3.1, with the loop
// hand-unrolled.
static void _Stl_mult64(const uint64 u, const uint64 v,
uint64& high, uint64& low) {
const uint64 low_mask = ULL(0xffffffff);
const uint64 u0 = u & low_mask;
const uint64 u1 = u >> 32;
const uint64 v0 = v & low_mask;
const uint64 v1 = v >> 32;
uint64 t = u0 * v0;
low = t & low_mask;
t = u1 * v0 + (t >> 32);
uint64 w1 = t & low_mask;
uint64 w2 = t >> 32;
uint64 x = u0 * v1 + w1;
low += (x & low_mask) << 32;
high = u1 * v1 + w2 + (x >> 32);
}
#if !defined (__linux__) || defined (__ANDROID__)
# define bit11 ULL(0x7ff)
# define exponent_mask (bit11 << 52)
# if !defined (__GNUC__) || (__GNUC__ != 3) || (__GNUC_MINOR__ != 4) || \
(!defined (__CYGWIN__) && !defined (__MINGW32__))
//Generate bad code when compiled with -O2 option.
inline
# endif
void _Stl_set_exponent(uint64 &val, uint64 exp)
{ val = (val & ~exponent_mask) | ((exp & bit11) << 52); }
#endif // __linux__
/* Power of ten fractions for tenscale*/
/* The constants are factored so that at most two constants
* and two multiplies are needed. Furthermore, one of the constants
* is represented exactly - 10**n where 1<= n <= 27.
*/
static const uint64 _Stl_tenpow[80] = {
ULL(0xa000000000000000), /* _Stl_tenpow[0]=(10**1)/(2**4) */
ULL(0xc800000000000000), /* _Stl_tenpow[1]=(10**2)/(2**7) */
ULL(0xfa00000000000000), /* _Stl_tenpow[2]=(10**3)/(2**10) */
ULL(0x9c40000000000000), /* _Stl_tenpow[3]=(10**4)/(2**14) */
ULL(0xc350000000000000), /* _Stl_tenpow[4]=(10**5)/(2**17) */
ULL(0xf424000000000000), /* _Stl_tenpow[5]=(10**6)/(2**20) */
ULL(0x9896800000000000), /* _Stl_tenpow[6]=(10**7)/(2**24) */
ULL(0xbebc200000000000), /* _Stl_tenpow[7]=(10**8)/(2**27) */
ULL(0xee6b280000000000), /* _Stl_tenpow[8]=(10**9)/(2**30) */
ULL(0x9502f90000000000), /* _Stl_tenpow[9]=(10**10)/(2**34) */
ULL(0xba43b74000000000), /* _Stl_tenpow[10]=(10**11)/(2**37) */
ULL(0xe8d4a51000000000), /* _Stl_tenpow[11]=(10**12)/(2**40) */
ULL(0x9184e72a00000000), /* _Stl_tenpow[12]=(10**13)/(2**44) */
ULL(0xb5e620f480000000), /* _Stl_tenpow[13]=(10**14)/(2**47) */
ULL(0xe35fa931a0000000), /* _Stl_tenpow[14]=(10**15)/(2**50) */
ULL(0x8e1bc9bf04000000), /* _Stl_tenpow[15]=(10**16)/(2**54) */
ULL(0xb1a2bc2ec5000000), /* _Stl_tenpow[16]=(10**17)/(2**57) */
ULL(0xde0b6b3a76400000), /* _Stl_tenpow[17]=(10**18)/(2**60) */
ULL(0x8ac7230489e80000), /* _Stl_tenpow[18]=(10**19)/(2**64) */
ULL(0xad78ebc5ac620000), /* _Stl_tenpow[19]=(10**20)/(2**67) */
ULL(0xd8d726b7177a8000), /* _Stl_tenpow[20]=(10**21)/(2**70) */
ULL(0x878678326eac9000), /* _Stl_tenpow[21]=(10**22)/(2**74) */
ULL(0xa968163f0a57b400), /* _Stl_tenpow[22]=(10**23)/(2**77) */
ULL(0xd3c21bcecceda100), /* _Stl_tenpow[23]=(10**24)/(2**80) */
ULL(0x84595161401484a0), /* _Stl_tenpow[24]=(10**25)/(2**84) */
ULL(0xa56fa5b99019a5c8), /* _Stl_tenpow[25]=(10**26)/(2**87) */
ULL(0xcecb8f27f4200f3a), /* _Stl_tenpow[26]=(10**27)/(2**90) */
ULL(0xd0cf4b50cfe20766), /* _Stl_tenpow[27]=(10**55)/(2**183) */
ULL(0xd2d80db02aabd62c), /* _Stl_tenpow[28]=(10**83)/(2**276) */
ULL(0xd4e5e2cdc1d1ea96), /* _Stl_tenpow[29]=(10**111)/(2**369) */
ULL(0xd6f8d7509292d603), /* _Stl_tenpow[30]=(10**139)/(2**462) */
ULL(0xd910f7ff28069da4), /* _Stl_tenpow[31]=(10**167)/(2**555) */
ULL(0xdb2e51bfe9d0696a), /* _Stl_tenpow[32]=(10**195)/(2**648) */
ULL(0xdd50f1996b947519), /* _Stl_tenpow[33]=(10**223)/(2**741) */
ULL(0xdf78e4b2bd342cf7), /* _Stl_tenpow[34]=(10**251)/(2**834) */
ULL(0xe1a63853bbd26451), /* _Stl_tenpow[35]=(10**279)/(2**927) */
ULL(0xe3d8f9e563a198e5), /* _Stl_tenpow[36]=(10**307)/(2**1020) */
// /* _Stl_tenpow[36]=(10**335)/(2**) */
// /* _Stl_tenpow[36]=(10**335)/(2**) */
ULL(0xfd87b5f28300ca0e), /* _Stl_tenpow[37]=(10**-28)/(2**-93) */
ULL(0xfb158592be068d2f), /* _Stl_tenpow[38]=(10**-56)/(2**-186) */
ULL(0xf8a95fcf88747d94), /* _Stl_tenpow[39]=(10**-84)/(2**-279) */
ULL(0xf64335bcf065d37d), /* _Stl_tenpow[40]=(10**-112)/(2**-372) */
ULL(0xf3e2f893dec3f126), /* _Stl_tenpow[41]=(10**-140)/(2**-465) */
ULL(0xf18899b1bc3f8ca2), /* _Stl_tenpow[42]=(10**-168)/(2**-558) */
ULL(0xef340a98172aace5), /* _Stl_tenpow[43]=(10**-196)/(2**-651) */
ULL(0xece53cec4a314ebe), /* _Stl_tenpow[44]=(10**-224)/(2**-744) */
ULL(0xea9c227723ee8bcb), /* _Stl_tenpow[45]=(10**-252)/(2**-837) */
ULL(0xe858ad248f5c22ca), /* _Stl_tenpow[46]=(10**-280)/(2**-930) */
ULL(0xe61acf033d1a45df), /* _Stl_tenpow[47]=(10**-308)/(2**-1023) */
ULL(0xe3e27a444d8d98b8), /* _Stl_tenpow[48]=(10**-336)/(2**-1116) */
ULL(0xe1afa13afbd14d6e) /* _Stl_tenpow[49]=(10**-364)/(2**-1209) */
};
static const short _Stl_twoexp[80] = {
4,7,10,14,17,20,24,27,30,34,37,40,44,47,50,54,57,60,64,67,70,74,77,80,84,87,90,
183,276,369,462,555,648,741,834,927,1020,
-93,-186,-279,-372,-465,-558,-651,-744,-837,-930,-1023,-1116,-1209
};
#define TEN_1 0 /* offset to 10 ** 1 */
#define TEN_27 26 /* offset to 10 ** 27 */
#define TEN_M28 37 /* offset to 10 ** -28 */
#define NUM_HI_P 11
#define NUM_HI_N 13
#define _Stl_HIBITULL (ULL(1) << 63)
static void _Stl_norm_and_round(uint64& p, int& norm, uint64 prodhi, uint64 prodlo) {
norm = 0;
if ((prodhi & _Stl_HIBITULL) == 0) {
/* leading bit is a zero
* may have to normalize
*/
if ((prodhi == ~_Stl_HIBITULL) &&
((prodlo >> 62) == 0x3)) { /* normalization followed by round
* would cause carry to create
* extra bit, so don't normalize
*/
p = _Stl_HIBITULL;
return;
}
p = (prodhi << 1) | (prodlo >> 63); /* normalize */
norm = 1;
prodlo <<= 1;
}
else {
p = prodhi;
}
if ((prodlo & _Stl_HIBITULL) != 0) { /* first guard bit a one */
if (((p & 0x1) != 0) ||
prodlo != _Stl_HIBITULL ) { /* not borderline for round to even */
/* round */
++p;
if (p == 0)
++p;
}
}
}
// Convert a 64-bitb fraction * 10^exp to a 64-bit fraction * 2^bexp.
// p: 64-bit fraction
// exp: base-10 exponent
// bexp: base-2 exponent (output parameter)
static void _Stl_tenscale(uint64& p, int exp, int& bexp) {
bexp = 0;
if ( exp == 0 ) { /* no scaling needed */
return;
}
int exp_hi = 0, exp_lo = exp; /* exp = exp_hi*32 + exp_lo */
int tlo = TEN_1, thi; /* offsets in power of ten table */
int num_hi; /* number of high exponent powers */
if (exp > 0) { /* split exponent */
if (exp_lo > 27) {
exp_lo++;
while (exp_lo > 27) {
exp_hi++;
exp_lo -= 28;
}
}
thi = TEN_27;
num_hi = NUM_HI_P;
} else { // exp < 0
while (exp_lo < 0) {
exp_hi++;
exp_lo += 28;
}
thi = TEN_M28;
num_hi = NUM_HI_N;
}
uint64 prodhi, prodlo; /* 128b product */
int norm; /* number of bits of normalization */
int hi, lo; /* offsets in power of ten table */
while (exp_hi) { /* scale */
hi = (min) (exp_hi, num_hi); /* only a few large powers of 10 */
exp_hi -= hi; /* could iterate in extreme case */
hi += thi-1;
_Stl_mult64(p, _Stl_tenpow[hi], prodhi, prodlo);
_Stl_norm_and_round(p, norm, prodhi, prodlo);
bexp += _Stl_twoexp[hi] - norm;
}
if (exp_lo) {
lo = tlo + exp_lo -1;
_Stl_mult64(p, _Stl_tenpow[lo], prodhi, prodlo);
_Stl_norm_and_round(p, norm, prodhi, prodlo);
bexp += _Stl_twoexp[lo] - norm;
}
return;
}
// First argument is a buffer of values from 0 to 9, NOT ascii.
// Second argument is number of digits in buffer, 1 <= digits <= 17.
// Third argument is base-10 exponent.
/* IEEE representation */
#if !defined (__linux__) || defined (__ANDROID__)
union _Double_rep {
uint64 ival;
double val;
};
static double _Stl_atod(char *buffer, ptrdiff_t ndigit, int dexp) {
typedef numeric_limits<double> limits;
_Double_rep drep;
uint64 &value = drep.ival; /* Value develops as follows:
* 1) decimal digits as an integer
* 2) left adjusted fraction
* 3) right adjusted fraction
* 4) exponent and fraction
*/
uint32 guard; /* First guard bit */
uint64 rest; /* Remaining guard bits */
int bexp; /* binary exponent */
int nzero; /* number of non-zero bits */
int sexp; /* scaling exponent */
char *bufferend; /* pointer to char after last digit */
/* Convert the decimal digits to a binary integer. */
bufferend = buffer + ndigit;
value = 0;
while (buffer < bufferend) {
value *= 10;
value += *buffer++;
}
/* Check for zero and treat it as a special case */
if (value == 0) {
return 0.0;
}
/* Normalize value */
bexp = 64; /* convert from 64b int to fraction */
/* Count number of non-zeroes in value */
nzero = 0;
if ((value >> 32) != 0) { nzero = 32; } //*TY 03/25/2000 - added explicit comparison to zero to avoid uint64 to bool conversion operator
if ((value >> (16 + nzero)) != 0) { nzero += 16; }
if ((value >> ( 8 + nzero)) != 0) { nzero += 8; }
if ((value >> ( 4 + nzero)) != 0) { nzero += 4; }
if ((value >> ( 2 + nzero)) != 0) { nzero += 2; }
if ((value >> ( 1 + nzero)) != 0) { nzero += 1; }
if ((value >> ( nzero)) != 0) { nzero += 1; }
/* Normalize */
value <<= /*(uint64)*/ (64 - nzero); //*TY 03/25/2000 - removed extraneous cast to uint64
bexp -= 64 - nzero;
/* At this point we have a 64b fraction and a binary exponent
* but have yet to incorporate the decimal exponent.
*/
/* multiply by 10^dexp */
_Stl_tenscale(value, dexp, sexp);
bexp += sexp;
if (bexp <= -1022) { /* HI denorm or underflow */
bexp += 1022;
if (bexp < -53) { /* guaranteed underflow */
value = 0;
}
else { /* denorm or possible underflow */
int lead0 = 12 - bexp; /* 12 sign and exponent bits */
/* we must special case right shifts of more than 63 */
if (lead0 > 64) {
rest = value;
guard = 0;
value = 0;
}
else if (lead0 == 64) {
rest = value & ((ULL(1)<< 63)-1);
guard = (uint32) ((value>> 63) & 1 );
value = 0;
}
else {
rest = value & (((ULL(1) << lead0)-1)-1);
guard = (uint32) (((value>> lead0)-1) & 1);
value >>= /*(uint64)*/ lead0; /* exponent is zero */
}
/* Round */
if (guard && ((value & 1) || rest) ) {
++value;
if (value == (ULL(1) << (limits::digits - 1))) { /* carry created normal number */
value = 0;
_Stl_set_exponent(value, 1);
}
}
}
}
else { /* not zero or denorm */
/* Round to 53 bits */
rest = value & ((1 << 10) - 1);
value >>= 10;
guard = (uint32) value & 1;
value >>= 1;
/* value&1 guard rest Action
*
* dc 0 dc none
* 1 1 dc round
* 0 1 0 none
* 0 1 !=0 round
*/
if (guard) {
if (((value&1)!=0) || (rest!=0)) {
++value; /* round */
if ((value >> 53) != 0) { /* carry all the way across */
value >>= 1; /* renormalize */
++bexp;
}
}
}
/*
* Check for overflow
* IEEE Double Precision Format
* (From Table 7-8 of Kane and Heinrich)
*
* Fraction bits 52
* Emax +1023
* Emin -1022
* Exponent bias +1023
* Exponent bits 11
* Integer bit hidden
* Total width in bits 64
*/
if (bexp > limits::max_exponent) { /* overflow */
return limits::infinity();
}
else { /* value is normal */
value &= ~(ULL(1) << (limits::digits - 1)); /* hide hidden bit */
_Stl_set_exponent(value, bexp + 1022); /* add bias */
}
}
_STLP_STATIC_ASSERT(sizeof(uint64) >= sizeof(double))
return drep.val;
}
#endif
#if defined (__linux__) || defined (__MINGW32__) || defined (__CYGWIN__) || \
defined (__BORLANDC__) || defined (__DMC__) || defined (__HP_aCC)
template <class D, class IEEE, int M, int BIAS>
D _Stl_atodT(char *buffer, ptrdiff_t ndigit, int dexp)
{
typedef numeric_limits<D> limits;
/* Convert the decimal digits to a binary integer. */
char *bufferend = buffer + ndigit; /* pointer to char after last digit */
_ll vv;
vv.i64 = 0L;
while ( buffer < bufferend ) {
vv.i64 *= 10;
vv.i64 += *buffer++;
}
if ( vv.i64 == ULL(0) ) { /* Check for zero and treat it as a special case */
return D(0.0);
}
/* Normalize value */
int bexp = 64; /* convert from 64b int to fraction */
/* Count number of non-zeroes in value */
int nzero = 0;
if ((vv.i64 >> 32) != 0) { nzero = 32; }
if ((vv.i64 >> (16 + nzero)) != 0) { nzero += 16; }
if ((vv.i64 >> ( 8 + nzero)) != 0) { nzero += 8; }
if ((vv.i64 >> ( 4 + nzero)) != 0) { nzero += 4; }
if ((vv.i64 >> ( 2 + nzero)) != 0) { nzero += 2; }
if ((vv.i64 >> ( 1 + nzero)) != 0) { nzero += 1; }
if ((vv.i64 >> ( nzero)) != 0) { nzero += 1; }
/* Normalize */
nzero = 64 - nzero;
vv.i64 <<= nzero; // * TY 03/25/2000 - removed extraneous cast to uint64
bexp -= nzero;
/* At this point we have a 64b fraction and a binary exponent
* but have yet to incorporate the decimal exponent.
*/
/* multiply by 10^dexp */
int sexp;
_Stl_tenscale(vv.i64, dexp, sexp);
bexp += sexp;
if ( bexp >= limits::min_exponent ) { /* not zero or denorm */
if ( limits::digits < 64 ) {
/* Round to (64 - M + 1) bits */
uint64_t rest = vv.i64 & ((~ULL(0) / ULL(2)) >> (limits::digits - 1));
vv.i64 >>= M - 2;
uint32_t guard = (uint32) vv.i64 & 1;
vv.i64 >>= 1;
/* value&1 guard rest Action
*
* dc 0 dc none
* 1 1 dc round
* 0 1 0 none
* 0 1 !=0 round
*/
if (guard) {
if ( ((vv.i64 & 1) != 0) || (rest != 0) ) {
vv.i64++; /* round */
if ( (vv.i64 >> (limits::digits < 64 ? limits::digits : 0)) != 0 ) { /* carry all the way across */
vv.i64 >>= 1; /* renormalize */
++bexp;
}
}
}
vv.i64 &= ~(ULL(1) << (limits::digits - 1)); /* hide hidden bit */
}
/*
* Check for overflow
* IEEE Double Precision Format
* (From Table 7-8 of Kane and Heinrich)
*
* Fraction bits 52
* Emax +1023
* Emin -1022
* Exponent bias +1023
* Exponent bits 11
* Integer bit hidden
* Total width in bits 64
*/
if (bexp > limits::max_exponent) { /* overflow */
return limits::infinity();
}
/* value is normal */
IEEE v;
v.ieee.mantissa0 = vv.i32.hi;
v.ieee.mantissa1 = vv.i32.lo;
v.ieee.negative = 0;
v.ieee.exponent = bexp + BIAS - 1;
return v.d;
}
/* HI denorm or underflow */
bexp += BIAS - 1;
if (bexp < -limits::digits) { /* guaranteed underflow */
vv.i64 = 0;
} else { /* denorm or possible underflow */
/*
* Problem point for long double: looks like this code reflect shareing of mantissa
* and exponent in 64b int; not so for long double
*/
int lead0 = M - bexp; /* M = 12 sign and exponent bits */
uint64_t rest;
uint32_t guard;
/* we must special case right shifts of more than 63 */
if (lead0 > 64) {
rest = vv.i64;
guard = 0;
vv.i64 = 0;
} else if (lead0 == 64) {
rest = vv.i64 & ((ULL(1) << 63)-1);
guard = (uint32) ((vv.i64 >> 63) & 1 );
vv.i64 = 0;
} else {
rest = vv.i64 & (((ULL(1) << lead0)-1)-1);
guard = (uint32) (((vv.i64 >> lead0)-1) & 1);
vv.i64 >>= /*(uint64)*/ lead0; /* exponent is zero */
}
/* Round */
if (guard && ( (vv.i64 & 1) || rest)) {
vv.i64++;
if (vv.i64 == (ULL(1) << (limits::digits - 1))) { /* carry created normal number */
IEEE v;
v.ieee.mantissa0 = 0;
v.ieee.mantissa1 = 0;
v.ieee.negative = 0;
v.ieee.exponent = 1;
return v.d;
}
}
}
IEEE v;
v.ieee.mantissa0 = vv.i32.hi;
v.ieee.mantissa1 = vv.i32.lo;
v.ieee.negative = 0;
v.ieee.exponent = 0;
return v.d;
}
#endif // __linux__
#if !defined (__linux__) || defined (__ANDROID__)
static double _Stl_string_to_double(const char *s) {
typedef numeric_limits<double> limits;
const int max_digits = limits::digits10 + 2;
unsigned c;
unsigned Negate, decimal_point;
char *d;
int exp;
int dpchar;
char digits[max_digits];
c = *s++;
/* process sign */
Negate = 0;
if (c == '+') {
c = *s++;
} else if (c == '-') {
Negate = 1;
c = *s++;
}
d = digits;
dpchar = '.' - '0';
decimal_point = 0;
exp = 0;
for (;;) {
c -= '0';
if (c < 10) {
if (d == digits + max_digits) {
/* ignore more than max_digits digits, but adjust exponent */
exp += (decimal_point ^ 1);
} else {
if (c == 0 && d == digits) {
/* ignore leading zeros */
} else {
*d++ = (char) c;
}
exp -= decimal_point;
}
} else if (c == (unsigned int) dpchar && !decimal_point) { /* INTERNATIONAL */
decimal_point = 1;
} else {
break;
}
c = *s++;
}
/* strtod cant return until it finds the end of the exponent */
if (d == digits) {
return 0.0;
}
if (c == 'e' - '0' || c == 'E' - '0') {
register unsigned negate_exp = 0;
register int e = 0;
c = *s++;
if (c == '+' || c == ' ') {
c = *s++;
} else if (c == '-') {
negate_exp = 1;
c = *s++;
}
if (c -= '0', c < 10) {
do {
e = e * 10 + (int)c;
c = *s++;
} while (c -= '0', c < 10);
if (negate_exp) {
e = -e;
}
exp += e;
}
}
double x;
ptrdiff_t n = d - digits;
if ((exp + n - 1) < limits::min_exponent10) {
x = 0;
}
else if ((exp + n - 1) > limits::max_exponent10) {
x = limits::infinity();
}
else {
/* Let _Stl_atod diagnose under- and over-flows.
* If the input was == 0.0, we have already returned,
* so retval of +-Inf signals OVERFLOW, 0.0 UNDERFLOW */
x = _Stl_atod(digits, n, exp);
}
if (Negate) {
x = -x;
}
return x;
}
#endif
#if defined (__linux__) || defined (__MINGW32__) || defined (__CYGWIN__) || \
defined (__BORLANDC__) || defined (__DMC__) || defined (__HP_aCC)
template <class D, class IEEE, int M, int BIAS>
D _Stl_string_to_doubleT(const char *s)
{
typedef numeric_limits<D> limits;
const int max_digits = limits::digits10; /* + 2 17 */;
unsigned c;
unsigned decimal_point;
char *d;
int exp;
D x;
int dpchar;
char digits[max_digits];
c = *s++;
/* process sign */
bool Negate = false;
if (c == '+') {
c = *s++;
} else if (c == '-') {
Negate = true;
c = *s++;
}
d = digits;
dpchar = '.' - '0';
decimal_point = 0;
exp = 0;
for (;;) {
c -= '0';
if (c < 10) {
if (d == digits + max_digits) {
/* ignore more than max_digits digits, but adjust exponent */
exp += (decimal_point ^ 1);
} else {
if (c == 0 && d == digits) {
/* ignore leading zeros */
} else {
*d++ = (char) c;
}
exp -= decimal_point;
}
} else if (c == (unsigned int) dpchar && !decimal_point) { /* INTERNATIONAL */
decimal_point = 1;
} else {
break;
}
c = *s++;
}
/* strtod cant return until it finds the end of the exponent */
if (d == digits) {
return D(0.0);
}
if (c == 'e'-'0' || c == 'E'-'0') {
bool negate_exp = false;
register int e = 0;
c = *s++;
if (c == '+' || c == ' ') {
c = *s++;
} else if (c == '-') {
negate_exp = true;
c = *s++;
}
if (c -= '0', c < 10) {
do {
e = e * 10 + (int)c;
c = *s++;
} while (c -= '0', c < 10);
if (negate_exp) {
e = -e;
}
exp += e;
}
}
ptrdiff_t n = d - digits;
if ((exp + n - 1) < limits::min_exponent10) {
return D(0.0); // +0.0 is the same as -0.0
} else if ((exp + n - 1) > limits::max_exponent10 ) {
// not good, because of x = -x below; this may lead to portability problems
x = limits::infinity();
} else {
/* let _Stl_atod diagnose under- and over-flows */
/* if the input was == 0.0, we have already returned,
so retval of +-Inf signals OVERFLOW, 0.0 UNDERFLOW
*/
x = _Stl_atodT<D,IEEE,M,BIAS>(digits, n, exp);
}
return Negate ? -x : x;
}
#endif // __linux__
void _STLP_CALL
__string_to_float(const __iostring& v, float& val)
{
#if !defined (__linux__) || defined (__ANDROID__)
val = (float)_Stl_string_to_double(v.c_str());
#else
val = (float)_Stl_string_to_doubleT<double,ieee754_double,12,IEEE754_DOUBLE_BIAS>(v.c_str());
#endif
}
void _STLP_CALL
__string_to_float(const __iostring& v, double& val)
{
#if !defined (__linux__) || defined (__ANDROID__)
val = _Stl_string_to_double(v.c_str());
#else
val = _Stl_string_to_doubleT<double,ieee754_double,12,IEEE754_DOUBLE_BIAS>(v.c_str());
#endif
}
#if !defined (_STLP_NO_LONG_DOUBLE)
void _STLP_CALL
__string_to_float(const __iostring& v, long double& val) {
#if !defined (__linux__) && !defined (__MINGW32__) && !defined (__CYGWIN__) && \
!defined (__BORLANDC__) && !defined (__DMC__) && !defined (__HP_aCC)
//The following function is valid only if long double is an alias for double.
_STLP_STATIC_ASSERT( sizeof(long double) <= sizeof(double) )
val = _Stl_string_to_double(v.c_str());
#else
val = _Stl_string_to_doubleT<long double,ieee854_long_double,16,IEEE854_LONG_DOUBLE_BIAS>(v.c_str());
#endif
}
#endif
_STLP_MOVE_TO_STD_NAMESPACE
_STLP_END_NAMESPACE
// Local Variables:
// mode:C++
// End:

Просмотреть файл

@ -1,183 +0,0 @@
/*
* Copyright (c) 1999
* Silicon Graphics Computer Systems, Inc.
*
* Copyright (c) 1999
* Boris Fomitchev
*
* This material is provided "as is", with absolutely no warranty expressed
* or implied. Any use is at your own risk.
*
* Permission to use or copy this software for any purpose is hereby granted
* without fee, provided the above notices are retained on all copies.
* Permission to modify the code and to distribute modified code is granted,
* provided the above notices are retained, and a notice that the code was
* modified is included with the above copyright notice.
*
*/
#include "stlport_prefix.h"
#include <locale>
#include <ostream>
_STLP_BEGIN_NAMESPACE
// Note that grouping[0] is the number of digits in the *rightmost* group.
// We assume, without checking, that *last is null and that there is enough
// space in the buffer to extend the number past [first, last).
template <class Char>
static ptrdiff_t
__insert_grouping_aux(Char* first, Char* last, const string& grouping,
Char separator, Char Plus, Char Minus,
int basechars) {
typedef string::size_type str_size;
if (first == last)
return 0;
int sign = 0;
if (*first == Plus || *first == Minus) {
sign = 1;
++first;
}
first += basechars;
Char* cur_group = last; // Points immediately beyond the rightmost
// digit of the current group.
int groupsize = 0; // Size of the current group (if grouping.size() == 0, size
// of group unlimited: we force condition (groupsize <= 0))
for ( str_size n = 0; ; ) { // Index of the current group
if ( n < grouping.size() ) {
groupsize = __STATIC_CAST(int, grouping[n++] );
}
if ((groupsize <= 0) || (groupsize >= cur_group - first) || (groupsize == CHAR_MAX)) {
break;
}
// Insert a separator character just before position cur_group - groupsize
cur_group -= groupsize;
++last;
copy_backward(cur_group, last, last + 1);
*cur_group = separator;
}
return (last - first) + sign + basechars;
}
//Dynamic output buffer version.
template <class Char, class Str>
static void
__insert_grouping_aux( /* __basic_iostring<Char> */ Str& iostr, size_t __group_pos,
const string& grouping,
Char separator, Char Plus, Char Minus,
int basechars) {
typedef string::size_type str_size;
if (iostr.size() < __group_pos)
return;
int __first_pos = 0;
Char __first = *iostr.begin();
if (__first == Plus || __first == Minus) {
++__first_pos;
}
__first_pos += basechars;
typename Str::iterator cur_group(iostr.begin() + __group_pos); // Points immediately beyond the rightmost
// digit of the current group.
int groupsize = 0; // Size of the current group (if grouping.size() == 0, size
// of group unlimited: we force condition (groupsize <= 0))
for ( str_size n = 0; ; ) { // Index of the current group
if ( n < grouping.size() ) {
groupsize = __STATIC_CAST( int, grouping[n++] );
}
if ( (groupsize <= 0) || (groupsize >= ((cur_group - iostr.begin()) - __first_pos)) ||
(groupsize == CHAR_MAX)) {
break;
}
// Insert a separator character just before position cur_group - groupsize
cur_group -= groupsize;
cur_group = iostr.insert(cur_group, separator);
}
}
//----------------------------------------------------------------------
// num_put
_STLP_MOVE_TO_PRIV_NAMESPACE
_STLP_DECLSPEC const char* _STLP_CALL __hex_char_table_lo()
{ return "0123456789abcdefx"; }
_STLP_DECLSPEC const char* _STLP_CALL __hex_char_table_hi()
{ return "0123456789ABCDEFX"; }
char* _STLP_CALL
__write_integer(char* buf, ios_base::fmtflags flags, long x) {
char tmp[64];
char* bufend = tmp+64;
char* beg = __write_integer_backward(bufend, flags, x);
return copy(beg, bufend, buf);
}
///-------------------------------------
ptrdiff_t _STLP_CALL
__insert_grouping(char * first, char * last, const string& grouping,
char separator, char Plus, char Minus, int basechars) {
return __insert_grouping_aux(first, last, grouping,
separator, Plus, Minus, basechars);
}
void _STLP_CALL
__insert_grouping(__iostring &str, size_t group_pos, const string& grouping,
char separator, char Plus, char Minus, int basechars) {
__insert_grouping_aux(str, group_pos, grouping, separator, Plus, Minus, basechars);
}
#if !defined (_STLP_NO_WCHAR_T)
ptrdiff_t _STLP_CALL
__insert_grouping(wchar_t* first, wchar_t* last, const string& grouping,
wchar_t separator, wchar_t Plus, wchar_t Minus,
int basechars) {
return __insert_grouping_aux(first, last, grouping, separator,
Plus, Minus, basechars);
}
void _STLP_CALL
__insert_grouping(__iowstring &str, size_t group_pos, const string& grouping,
wchar_t separator, wchar_t Plus, wchar_t Minus,
int basechars) {
__insert_grouping_aux(str, group_pos, grouping, separator, Plus, Minus, basechars);
}
#endif
_STLP_MOVE_TO_STD_NAMESPACE
//----------------------------------------------------------------------
// Force instantiation of num_put<>
#if !defined(_STLP_NO_FORCE_INSTANTIATE)
template class _STLP_CLASS_DECLSPEC ostreambuf_iterator<char, char_traits<char> >;
// template class num_put<char, char*>;
template class num_put<char, ostreambuf_iterator<char, char_traits<char> > >;
# ifndef _STLP_NO_WCHAR_T
template class ostreambuf_iterator<wchar_t, char_traits<wchar_t> >;
template class num_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >;
// template class num_put<wchar_t, wchar_t*>;
# endif /* INSTANTIATE_WIDE_STREAMS */
#endif
_STLP_END_NAMESPACE
// Local Variables:
// mode:C++
// End:

Просмотреть файл

@ -1,919 +0,0 @@
/*
* Copyright (c) 1999
* Silicon Graphics Computer Systems, Inc.
*
* Copyright (c) 1999
* Boris Fomitchev
*
* This material is provided "as is", with absolutely no warranty expressed
* or implied. Any use is at your own risk.
*
* Permission to use or copy this software for any purpose is hereby granted
* without fee, provided the above notices are retained on all copies.
* Permission to modify the code and to distribute modified code is granted,
* provided the above notices are retained, and a notice that the code was
* modified is included with the above copyright notice.
*
*/
#include "stlport_prefix.h"
#include <cmath>
#include <ios>
#include <locale>
#if defined (__DECCXX)
# define NDIG 400
#else
# define NDIG 82
#endif
#define todigit(x) ((x)+'0')
#if defined (_STLP_UNIX)
# if defined (__sun)
# include <floatingpoint.h>
# endif
# if defined (__sun) || defined (__digital__) || defined (__sgi) || defined (_STLP_SCO_OPENSERVER) || defined (__NCR_SVR)
// DEC, SGI & Solaris need this
# include <values.h>
# include <nan.h>
# endif
# if defined (__QNXNTO__) || ( defined(__GNUC__) && defined(__APPLE__) ) || defined(_STLP_USE_UCLIBC) /* 0.9.26 */ || \
defined(__FreeBSD__)
# define USE_SPRINTF_INSTEAD
# endif
# if defined (_AIX) // JFA 3-Aug-2000
# include <math.h>
# include <float.h>
# endif
# include <math.h>
#endif
#include <cstdio>
#include <cstdlib>
#if defined (_STLP_MSVC_LIB) || defined (__MINGW32__) || defined (__BORLANDC__) || defined (__DJGPP) || \
defined (_STLP_SCO_OPENSERVER) || defined (__NCR_SVR)
# include <float.h>
#endif
#if defined (__MRC__) || defined (__SC__) || defined (_CRAY) //*TY 02/24/2000 - added support for MPW
# include <fp.h>
#endif
#if defined (__CYGWIN__)
# include <ieeefp.h>
#endif
#if defined (__MSL__)
# include <cstdlib> // for atoi
# include <cstdio> // for snprintf
# include <algorithm>
# include <cassert>
#endif
#if defined (__ISCPP__)
# include <cfloat>
#endif
#include <algorithm>
#if defined (__DMC__)
# define snprintf _snprintf
#endif
_STLP_BEGIN_NAMESPACE
_STLP_MOVE_TO_PRIV_NAMESPACE
#if defined (__MWERKS__) || defined(__BEOS__)
# define USE_SPRINTF_INSTEAD
#endif
template <int N>
struct _Dig
{
enum { dig = _Dig<N/10>::dig + 1 };
};
_STLP_TEMPLATE_NULL
struct _Dig<0>
{
enum { dig = 0 };
};
#ifdef _STLP_NO_LONG_DOUBLE
# define MAXEDIGITS int(_Dig<DBL_MAX_10_EXP>::dig)
# define MAXFSIG DBL_DIG
# define MAXFCVT (DBL_DIG + 1)
#else
# define MAXEDIGITS int(_Dig<LDBL_MAX_10_EXP>::dig)
# define MAXFSIG LDBL_DIG
# define MAXFCVT (LDBL_DIG + 1)
#endif
// Tests for infinity and NaN differ on different OSs. We encapsulate
// these differences here.
#if !defined (USE_SPRINTF_INSTEAD)
# if defined (__hpux) && defined (__GNUC__)
# define _STLP_USE_SIGN_HELPER
# elif defined (__DJGPP) || (defined (_STLP_USE_GLIBC) && ! defined (__MSL__)) || \
defined (__CYGWIN__) || \
defined (__FreeBSD__) || defined (__NetBSD__) || defined (__OpenBSD__) || \
defined (__HP_aCC)
static inline bool _Stl_is_nan_or_inf(double x)
# if defined (isfinite)
{ return !isfinite(x); }
# else
{ return !finite(x); }
# endif
static inline bool _Stl_is_neg_nan(double x) { return isnan(x) && ( copysign(1., x) < 0 ); }
static inline bool _Stl_is_inf(double x) { return isinf(x); }
// inline bool _Stl_is_neg_inf(double x) { return isinf(x) < 0; }
static inline bool _Stl_is_neg_inf(double x) { return isinf(x) && x < 0; }
# elif (defined (__unix) || defined (__unix__)) && \
!defined (__APPLE__) && !defined (__DJGPP) && !defined(__osf__) && \
!defined (_CRAY) && !defined (__ANDROID__)
static inline bool _Stl_is_nan_or_inf(double x) { return IsNANorINF(x); }
static inline bool _Stl_is_inf(double x) { return IsNANorINF(x) && IsINF(x); }
static inline bool _Stl_is_neg_inf(double x) { return (IsINF(x)) && (x < 0.0); }
static inline bool _Stl_is_neg_nan(double x) { return IsNegNAN(x); }
# elif defined (_STLP_MSVC_LIB) || defined (__MINGW32__) || defined (__BORLANDC__)
static inline bool _Stl_is_nan_or_inf(double x) { return !_finite(x); }
# if !defined (__BORLANDC__)
static inline bool _Stl_is_inf(double x) {
int fclass = _fpclass(x);
return fclass == _FPCLASS_NINF || fclass == _FPCLASS_PINF;
}
static inline bool _Stl_is_neg_inf(double x) { return _fpclass(x) == _FPCLASS_NINF; }
# else
static inline bool _Stl_is_inf(double x) { return _Stl_is_nan_or_inf(x) && !_isnan(x);}
static inline bool _Stl_is_neg_inf(double x) { return _Stl_is_inf(x) && x < 0 ; }
# endif
static inline bool _Stl_is_neg_nan(double x) { return _isnan(x) && _copysign(1., x) < 0 ; }
# if defined (__BORLANDC__)
static inline bool _Stl_is_nan_or_inf(long double x) { return !_finitel(x); }
static inline bool _Stl_is_inf(long double x) { return _Stl_is_nan_or_inf(x) && !_isnanl(x);}
static inline bool _Stl_is_neg_inf(long double x) { return _Stl_is_inf(x) && x < 0 ; }
static inline bool _Stl_is_neg_nan(long double x) { return _isnanl(x) && _copysignl(1.l, x) < 0 ; }
# elif !defined (_STLP_NO_LONG_DOUBLE)
// Simply there to avoid warning long double -> double implicit conversion:
static inline bool _Stl_is_nan_or_inf(long double x) { return _Stl_is_nan_or_inf(__STATIC_CAST(double, x)); }
static inline bool _Stl_is_inf(long double x) { return _Stl_is_inf(__STATIC_CAST(double, x));}
static inline bool _Stl_is_neg_inf(long double x) { return _Stl_is_neg_inf(__STATIC_CAST(double, x)); }
static inline bool _Stl_is_neg_nan(long double x) { return _Stl_is_neg_nan(__STATIC_CAST(double, x)); }
# endif
# elif defined (__MRC__) || defined (__SC__) || defined (__DMC__)
static bool _Stl_is_nan_or_inf(double x) { return isnan(x) || !isfinite(x); }
static bool _Stl_is_inf(double x) { return !isfinite(x); }
static bool _Stl_is_neg_inf(double x) { return !isfinite(x) && signbit(x); }
static bool _Stl_is_neg_nan(double x) { return isnan(x) && signbit(x); }
# elif /* defined(__FreeBSD__) || defined(__OpenBSD__) || */ (defined(__GNUC__) && defined(__APPLE__))
static inline bool _Stl_is_nan_or_inf(double x) { return !finite(x); }
static inline bool _Stl_is_inf(double x) { return _Stl_is_nan_or_inf(x) && ! isnan(x); }
static inline bool _Stl_is_neg_inf(double x) { return _Stl_is_inf(x) && x < 0 ; }
static inline bool _Stl_is_neg_nan(double x) { return isnan(x) && copysign(1., x) < 0 ; }
# elif defined( _AIX ) // JFA 11-Aug-2000
static bool _Stl_is_nan_or_inf(double x) { return isnan(x) || !finite(x); }
static bool _Stl_is_inf(double x) { return !finite(x); }
// bool _Stl_is_neg_inf(double x) { return _class(x) == FP_MINUS_INF; }
static bool _Stl_is_neg_inf(double x) { return _Stl_is_inf(x) && ( copysign(1., x) < 0 ); }
static bool _Stl_is_neg_nan(double x) { return isnan(x) && ( copysign(1., x) < 0 ); }
# elif defined (__ISCPP__)
static inline bool _Stl_is_nan_or_inf (double x) { return _fp_isINF(x) || _fp_isNAN(x); }
static inline bool _Stl_is_inf (double x) { return _fp_isINF(x); }
static inline bool _Stl_is_neg_inf (double x) { return _fp_isINF(x) && x < 0; }
static inline bool _Stl_is_neg_nan (double x) { return _fp_isNAN(x) && x < 0; }
# elif defined (_CRAY)
# if defined (_CRAYIEEE)
static inline bool _Stl_is_nan_or_inf(double x) { return isnan(x) || isinf(x); }
static inline bool _Stl_is_inf(double x) { return isinf(x); }
static inline bool _Stl_is_neg_inf(double x) { return isinf(x) && signbit(x); }
static inline bool _Stl_is_neg_nan(double x) { return isnan(x) && signbit(x); }
# else
static inline bool _Stl_is_nan_or_inf(double x) { return false; }
static inline bool _Stl_is_inf(double x) { return false; }
static inline bool _Stl_is_neg_inf(double x) { return false; }
static inline bool _Stl_is_neg_nan(double x) { return false; }
# endif
# else // nothing from above
# define USE_SPRINTF_INSTEAD
# endif
#endif // !USE_SPRINTF_INSTEAD
#if !defined (USE_SPRINTF_INSTEAD)
// Reentrant versions of floating-point conversion functions. The argument
// lists look slightly different on different operating systems, so we're
// encapsulating the differences here.
# if defined (__CYGWIN__) || defined(__DJGPP)
static inline char* _Stl_ecvtR(double x, int n, int* pt, int* sign, char* buf)
{ return ecvtbuf(x, n, pt, sign, buf); }
static inline char* _Stl_fcvtR(double x, int n, int* pt, int* sign, char* buf)
{ return fcvtbuf(x, n, pt, sign, buf); }
# if !defined (_STLP_NO_LONG_DOUBLE)
# if defined (__CYGWIN__)
# define _STLP_EMULATE_LONG_DOUBLE_CVT
# else
static inline char* _Stl_ecvtR(long double x, int n, int* pt, int* sign, char* buf)
{ return ecvtbuf(x, n, pt, sign, buf); }
static inline char* _Stl_fcvtR(long double x, int n, int* pt, int* sign, char* buf)
{ return fcvtbuf(x, n, pt, sign, buf); }
# endif
# endif
# elif defined (_STLP_USE_GLIBC)
static inline char* _Stl_ecvtR(double x, int n, int* pt, int* sign, char* buf, size_t bsize)
{ return ecvt_r(x, n, pt, sign, buf, bsize) == 0 ? buf : 0; }
static inline char* _Stl_fcvtR(double x, int n, int* pt, int* sign, char* buf, size_t bsize)
{ return fcvt_r(x, n, pt, sign, buf, bsize) == 0 ? buf : 0; }
# ifndef _STLP_NO_LONG_DOUBLE
static inline char* _Stl_ecvtR(long double x, int n, int* pt, int* sign, char* buf, size_t bsize)
{ return qecvt_r(x, n, pt, sign, buf, bsize) == 0 ? buf : 0; }
static inline char* _Stl_fcvtR(long double x, int n, int* pt, int* sign, char* buf, size_t bsize)
{ return qfcvt_r(x, n, pt, sign, buf, bsize) == 0 ? buf : 0; }
# endif
# define _STLP_NEED_CVT_BUFFER_SIZE
# elif defined (__sun)
static inline char* _Stl_ecvtR(double x, int n, int* pt, int* sign, char* buf)
{ return econvert(x, n, pt, sign, buf); }
static inline char* _Stl_fcvtR(double x, int n, int* pt, int* sign, char* buf)
{ return fconvert(x, n, pt, sign, buf); }
# ifndef _STLP_NO_LONG_DOUBLE
static inline char* _Stl_ecvtR(long double x, int n, int* pt, int* sign, char* buf)
{ return qeconvert(&x, n, pt, sign, buf); }
static inline char* _Stl_fcvtR(long double x, int n, int* pt, int* sign, char* buf)
{ return qfconvert(&x, n, pt, sign, buf); }
# endif
# elif defined (__DECCXX)
static inline char* _Stl_ecvtR(double x, int n, int* pt, int* sign, char* buf, size_t bsize)
{ return (ecvt_r(x, n, pt, sign, buf, bsize) == 0 ? buf : 0); }
static inline char* _Stl_fcvtR(double x, int n, int* pt, int* sign, char* buf, size_t bsize)
{ return (fcvt_r(x, n, pt, sign, buf, bsize) == 0 ? buf : 0); }
# ifndef _STLP_NO_LONG_DOUBLE
// fbp : no "long double" conversions !
static inline char* _Stl_ecvtR(long double x, int n, int* pt, int* sign, char* buf, size_t bsize)
{ return (ecvt_r((double)x, n, pt, sign, buf, bsize) == 0 ? buf : 0) ; }
static inline char* _Stl_fcvtR(long double x, int n, int* pt, int* sign, char* buf, size_t bsize)
{ return (fcvt_r((double)x, n, pt, sign, buf, bsize) == 0 ? buf : 0); }
# endif
# define _STLP_NEED_CVT_BUFFER_SIZE
# elif defined (__hpux)
static inline char* _Stl_ecvtR(double x, int n, int* pt, int* sign)
{ return ecvt(x, n, pt, sign); }
static inline char* _Stl_fcvtR(double x, int n, int* pt, int* sign)
{ return fcvt(x, n, pt, sign); }
# if !defined (_STLP_NO_LONG_DOUBLE)
static inline char* _Stl_ecvtR(long double x, int n, int* pt, int* sign)
{ return _ldecvt(*(long_double*)&x, n, pt, sign); }
static inline char* _Stl_fcvtR(long double x, int n, int* pt, int* sign)
{ return _ldfcvt(*(long_double*)&x, n, pt, sign); }
# endif
# define _STLP_CVT_NEED_SYNCHRONIZATION
# elif defined (__unix) && !defined (__APPLE__) && !defined (_CRAY) && \
!defined (__ANDROID__)
static inline char* _Stl_ecvtR(double x, int n, int* pt, int* sign, char* buf)
{ return ecvt_r(x, n, pt, sign, buf); }
static inline char* _Stl_fcvtR(double x, int n, int* pt, int* sign, char* buf)
{ return fcvt_r(x, n, pt, sign, buf); }
# if !defined (_STLP_NO_LONG_DOUBLE)
static inline char* _Stl_ecvtR(long double x, int n, int* pt, int* sign, char* buf)
{ return qecvt_r(x, n, pt, sign, buf); }
static inline char* _Stl_fcvtR(long double x, int n, int* pt, int* sign, char* buf)
{ return qfcvt_r(x, n, pt, sign, buf); }
# endif
# elif defined (_STLP_MSVC_LIB) || defined (__MINGW32__) || defined (__BORLANDC__)
# if defined (_STLP_USE_SAFE_STRING_FUNCTIONS)
# define _STLP_APPEND(a, b) a##b
# define _STLP_BUF_PARAMS , char* buf, size_t bsize
# define _STLP_SECURE_FUN(F, X, N, PT, SIGN) _STLP_APPEND(F, _s)(buf, bsize, X, N, PT, SIGN); return buf
# else
# define _STLP_BUF_PARAMS
# define _STLP_SECURE_FUN(F, X, N, PT, SIGN) return F(X, N, PT, SIGN)
# define _STLP_CVT_NEED_SYNCHRONIZATION
# endif
static inline char* _Stl_ecvtR(double x, int n, int* pt, int* sign _STLP_BUF_PARAMS)
{ _STLP_SECURE_FUN(_ecvt, x, n, pt, sign); }
static inline char* _Stl_fcvtR(double x, int n, int* pt, int* sign _STLP_BUF_PARAMS)
{ _STLP_SECURE_FUN(_fcvt, x, n, pt, sign); }
# if !defined (_STLP_NO_LONG_DOUBLE)
# if defined (_STLP_USE_SAFE_STRING_FUNCTIONS)
# define _STLP_PARAMS , buf, bsize
# else
# define _STLP_PARAMS
# endif
static inline char* _Stl_ecvtR(long double x, int n, int* pt, int* sign _STLP_BUF_PARAMS)
{ return _Stl_ecvtR(__STATIC_CAST(double, x), n, pt, sign _STLP_PARAMS); }
static inline char* _Stl_fcvtR(long double x, int n, int* pt, int* sign _STLP_BUF_PARAMS)
{ return _Stl_fcvtR(__STATIC_CAST(double, x), n, pt, sign _STLP_PARAMS); }
# undef _STLP_PARAMS
# endif
# undef _STLP_SECURE_FUN
# undef _STLP_BUF_PARAMS
# undef _STLP_APPEND
# if defined (__BORLANDC__) /* || defined (__GNUC__) MinGW do not support 'L' modifier so emulation do not work */
# define _STLP_EMULATE_LONG_DOUBLE_CVT
# endif
# elif defined (__ISCPP__)
static inline char* _Stl_ecvtR(double x, int n, int* pt, int* sign, char* buf)
{ return _fp_ecvt( x, n, pt, sign, buf); }
static inline char* _Stl_fcvtR(double x, int n, int* pt, int* sign, char* buf)
{ return _fp_fcvt(x, n, pt, sign, buf); }
# if !defined (_STLP_NO_LONG_DOUBLE)
static inline char* _Stl_ecvtR(long double x, int n, int* pt, int* sign, char* buf)
{ return _fp_ecvt( x, n, pt, sign, buf); }
static inline char* _Stl_fcvtR(long double x, int n, int* pt, int* sign, char* buf)
{ return _fp_fcvt(x, n, pt, sign, buf); }
# endif
# elif defined (_AIX) || defined (__FreeBSD__) || defined (__NetBSD__) || defined (__OpenBSD__) || \
defined (__MRC__) || defined (__SC__) || defined (_CRAY) || \
defined (_STLP_SCO_OPENSERVER) || defined (__NCR_SVR) || \
defined (__DMC__)
static inline char* _Stl_ecvtR(double x, int n, int* pt, int* sign)
{ return ecvt(x, n, pt, sign ); }
static inline char* _Stl_fcvtR(double x, int n, int* pt, int* sign)
{ return fcvt(x, n, pt, sign); }
# if !defined (_STLP_NO_LONG_DOUBLE)
static inline char* _Stl_ecvtR(long double x, int n, int* pt, int* sign)
{ return ecvt(x, n, pt, sign ); }
static inline char* _Stl_fcvtR(long double x, int n, int* pt, int* sign)
{ return fcvt(x, n, pt, sign); }
# endif
# define _STLP_CVT_NEED_SYNCHRONIZATION
# else
# error Missing _Stl_ecvtR and _Stl_fcvtR implementations.
# endif
#if defined (_STLP_CVT_NEED_SYNCHRONIZATION)
/* STLport synchronize access to *cvt functions but those methods might
* be called from outside, in this case we will still have a race condition. */
# if defined (_STLP_THREADS)
static _STLP_STATIC_MUTEX& put_float_mutex() {
static _STLP_STATIC_MUTEX __put_float_mutex _STLP_MUTEX_INITIALIZER;
return __put_float_mutex;
}
static inline char* _Stl_ecvtR(double x, int n, int* pt, int* sign, char* buf) {
_STLP_auto_lock lock(put_float_mutex());
strcpy(buf, _Stl_ecvtR(x, n, pt, sign)); return buf;
}
static inline char* _Stl_fcvtR(double x, int n, int* pt, int* sign, char* buf) {
_STLP_auto_lock lock(put_float_mutex());
strcpy(buf, _Stl_fcvtR(x, n, pt, sign)); return buf;
}
# if !defined (_STLP_NO_LONG_DOUBLE) && !defined (_STLP_EMULATE_LONG_DOUBLE_CVT)
static inline char* _Stl_ecvtR(long double x, int n, int* pt, int* sign, char* buf) {
_STLP_auto_lock lock(put_float_mutex());
strcpy(buf, _Stl_ecvtR(x, n, pt, sign)); return buf;
}
static inline char* _Stl_fcvtR(long double x, int n, int* pt, int* sign, char* buf) {
_STLP_auto_lock lock(put_float_mutex());
strcpy(buf, _Stl_fcvtR(x, n, pt, sign)); return buf;
}
# endif
# else
static inline char* _Stl_ecvtR(double x, int n, int* pt, int* sign, char*)
{ return _Stl_ecvtR(x, n, pt, sign); }
static inline char* _Stl_fcvtR(double x, int n, int* pt, int* sign, char*)
{ return _Stl_fcvtR(x, n, pt, sign); }
# if !defined (_STLP_NO_LONG_DOUBLE) && !defined (_STLP_EMULATE_LONG_DOUBLE_CVT)
static inline char* _Stl_ecvtR(long double x, int n, int* pt, int* sign, char*)
{ return _Stl_ecvtR(x, n, pt, sign); }
static inline char* _Stl_fcvtR(long double x, int n, int* pt, int* sign, char*)
{ return _Stl_fcvtR(x, n, pt, sign); }
# endif
# endif
#endif
# if !defined (_STLP_USE_SAFE_STRING_FUNCTIONS) && !defined (_STLP_NEED_CVT_BUFFER_SIZE)
# define _STLP_CVT_BUFFER(B) B
# else
# define _STLP_CVT_BUFFER(B) _STLP_ARRAY_AND_SIZE(B)
# endif
# if defined (_STLP_EMULATE_LONG_DOUBLE_CVT)
static void __fill_fmtbuf(char* fmtbuf, ios_base::fmtflags flags, char long_modifier);
// Emulation of ecvt/fcvt functions using sprintf:
static char* _Stl_ecvtR(long double x, int n, int* pt, int* sign, char* buf) {
// If long double value can be safely converted to double without losing precision
// we use the ecvt function for double:
double y = __STATIC_CAST(double, x);
if (x == y)
return _Stl_ecvtR(y, n, pt, sign, buf);
char fmtbuf[32];
__fill_fmtbuf(fmtbuf, 0, 'L');
sprintf(buf, fmtbuf, n, x < 0.0l ? -x : x);
/* We are waiting for something having the form x.xxxe+yyyy */
*pt = 0;
*sign = 0;
int i = -1;
int offset = 0;
while (buf[++i] != 0 && n != 0) {
if (buf[i] >= '0' && buf[i] <= '9') {
--n;
if (offset != 0)
buf[i - offset] = buf[i];
}
else {
if (offset != 0) break;
++offset;
*pt = i;
}
}
if (offset != 0)
buf[i - offset] = 0;
// Extract exponent part in point position:
int e = 0;
while (buf[++i] != 0) {
if (buf[i] >= '0' && buf[i] <= '9') {
e = e * 10 + (buf[i] - '0');
}
}
*pt += e;
return buf;
}
static char* _Stl_fcvtR(long double x, int n, int* pt, int* sign, char* buf) {
// If long double value can be safely converted to double without losing precision
// we use the fcvt function for double:
double y = __STATIC_CAST(double, x);
if (x == y)
return _Stl_fcvtR(y, n, pt, sign, buf);
char fmtbuf[32];
__fill_fmtbuf(fmtbuf, ios_base::fixed, 'L');
sprintf(buf, fmtbuf, n, x < 0.0l ? -x : x);
*pt = 0;
*sign = 0;
int i = -1;
int offset = 0;
while (buf[++i] != 0 && (offset == 0 || n != 0)) {
if (buf[i] >= '0' && buf[i] <= '9') {
if (offset != 0) {
--n;
buf[i - offset] = buf[i];
}
}
else {
++offset;
*pt = i;
}
}
if (offset != 0)
buf[i - offset] = 0;
else
*pt = i;
return buf;
}
#endif
//----------------------------------------------------------------------
// num_put
// __format_float formats a mantissa and exponent as returned by
// one of the conversion functions (ecvt_r, fcvt_r, qecvt_r, qfcvt_r)
// according to the specified precision and format flags. This is
// based on doprnt but is much simpler since it is concerned only
// with floating point input and does not consider all formats. It
// also does not deal with blank padding, which is handled by
// __copy_float_and_fill.
static size_t __format_float_scientific( __iostring& buf, const char *bp,
int decpt, int sign, bool is_zero,
ios_base::fmtflags flags,
int precision) {
// sign if required
if (sign)
buf += '-';
else if (flags & ios_base::showpos)
buf += '+';
// first digit of mantissa
buf += *bp++;
// start of grouping position, grouping won't occur in scientific notation
// as it is impossible to have something like 1234.0e04 but we return a correct
// group position for coherency with __format_float_fixed.
size_t __group_pos = buf.size();
// decimal point if required
if (precision != 0 || flags & ios_base::showpoint) {
buf += '.';
}
// rest of mantissa
while (*bp != 0 && precision--)
buf += *bp++;
// trailing 0 if needed
if (precision > 0)
buf.append(precision, '0');
// exponent size = number of digits + exponent sign + exponent symbol + trailing zero
char expbuf[MAXEDIGITS + 3];
//We start filling at the buffer end
char *suffix = expbuf + MAXEDIGITS + 2;
*suffix = 0;
if (!is_zero) {
int nn = decpt - 1;
if (nn < 0)
nn = -nn;
for (; nn > 9; nn /= 10)
*--suffix = (char) todigit(nn % 10);
*--suffix = (char) todigit(nn);
}
// prepend leading zeros to exponent
// C89 Standard says that it should be at least 2 digits, C99 Standard says that
// we stop prepend zeros if more than 3 digits. To repect both STLport prepend zeros
// until it is 2 digits.
while (suffix > &expbuf[MAXEDIGITS])
*--suffix = '0';
// put in the exponent sign
*--suffix = (char) ((decpt > 0 || is_zero ) ? '+' : '-');
// put in the e
*--suffix = flags & ios_base::uppercase ? 'E' : 'e';
// copy the suffix
buf += suffix;
return __group_pos;
}
static size_t __format_float_fixed( __iostring &buf, const char *bp,
int decpt, int sign,
ios_base::fmtflags flags,
int precision) {
if ( sign && (decpt > -precision) && (*bp != 0) )
buf += '-';
else if ( flags & ios_base::showpos )
buf += '+';
// digits before decimal point
int nnn = decpt;
do {
buf += (nnn <= 0 || *bp == 0) ? '0' : *bp++;
} while ( --nnn > 0 );
// start of grouping position
size_t __group_pos = buf.size();
// decimal point if needed
if ( flags & ios_base::showpoint || precision > 0 ) {
buf += '.';
}
// digits after decimal point if any
while ( *bp != 0 && --precision >= 0 ) {
buf += (++decpt <= 0) ? '0' : *bp++;
}
// trailing zeros if needed
if (precision > 0)
buf.append(precision, '0');
return __group_pos;
}
#if defined (_STLP_USE_SIGN_HELPER)
template<class _FloatT>
struct float_sign_helper {
float_sign_helper(_FloatT __x)
{ _M_number._num = __x; }
bool is_negative() const {
const unsigned short sign_mask(1 << (sizeof(unsigned short) * CHAR_BIT - 1));
return (get_sign_word() & sign_mask) != 0;
}
private:
union {
unsigned short _Words[8];
_FloatT _num;
} _M_number;
unsigned short get_word_higher() const _STLP_NOTHROW
{ return _M_number._Words[0]; }
unsigned short get_word_lower() const _STLP_NOTHROW
{ return _M_number._Words[(sizeof(_FloatT) >= 12 ? 10 : sizeof(_FloatT)) / sizeof(unsigned short) - 1]; }
unsigned short get_sign_word() const _STLP_NOTHROW
# if defined (_STLP_BIG_ENDIAN)
{ return get_word_higher(); }
# else /* _STLP_LITTLE_ENDIAN */
{ return get_word_lower(); }
# endif
};
#endif
template <class _FloatT>
static size_t __format_nan_or_inf(__iostring& buf, _FloatT x, ios_base::fmtflags flags) {
static const char* inf[2] = { "inf", "Inf" };
static const char* nan[2] = { "nan", "NaN" };
const char** inf_or_nan;
#if !defined (_STLP_USE_SIGN_HELPER)
if (_Stl_is_inf(x)) { // Infinity
inf_or_nan = inf;
if (_Stl_is_neg_inf(x))
buf += '-';
else if (flags & ios_base::showpos)
buf += '+';
} else { // NaN
inf_or_nan = nan;
if (_Stl_is_neg_nan(x))
buf += '-';
else if (flags & ios_base::showpos)
buf += '+';
}
#else
typedef numeric_limits<_FloatT> limits;
if (x == limits::infinity() || x == -limits::infinity()) {
inf_or_nan = inf;
} else { // NaN
inf_or_nan = nan;
}
float_sign_helper<_FloatT> helper(x);
if (helper.is_negative())
buf += '-';
else if (flags & ios_base::showpos)
buf += '+';
#endif
size_t ret = buf.size();
buf += inf_or_nan[flags & ios_base::uppercase ? 1 : 0];
return ret;
}
static inline size_t __format_float(__iostring &buf, const char * bp,
int decpt, int sign, bool is_zero,
ios_base::fmtflags flags,
int precision) {
size_t __group_pos = 0;
switch (flags & ios_base::floatfield) {
case ios_base::scientific:
__group_pos = __format_float_scientific( buf, bp, decpt, sign, is_zero,
flags, precision);
break;
case ios_base::fixed:
__group_pos = __format_float_fixed( buf, bp, decpt, sign,
flags, precision);
break;
default: // g format
// establish default precision
if (flags & ios_base::showpoint || precision > 0) {
if (precision == 0) precision = 1;
} else
precision = 6;
// reset exponent if value is zero
if (is_zero)
decpt = 1;
int kk = precision;
if (!(flags & ios_base::showpoint)) {
size_t n = strlen(bp);
if (n < (size_t)kk)
kk = (int)n;
while (kk >= 1 && bp[kk-1] == '0')
--kk;
}
if (decpt < -3 || decpt > precision) {
precision = kk - 1;
__group_pos = __format_float_scientific( buf, bp, decpt, sign, is_zero,
flags, precision);
} else {
precision = kk - decpt;
__group_pos = __format_float_fixed( buf, bp, decpt, sign,
flags, precision);
}
break;
} /* switch */
return __group_pos;
}
#endif
#if defined (USE_SPRINTF_INSTEAD) || defined (_STLP_EMULATE_LONG_DOUBLE_CVT)
struct GroupPos {
bool operator () (char __c) const {
return __c == '.' ||
__c == 'e' || __c == 'E';
}
};
// Creates a format string for sprintf()
static void __fill_fmtbuf(char* fmtbuf, ios_base::fmtflags flags, char long_modifier) {
fmtbuf[0] = '%';
int i = 1;
if (flags & ios_base::showpos)
fmtbuf[i++] = '+';
if (flags & ios_base::showpoint)
fmtbuf[i++] = '#';
fmtbuf[i++] = '.';
fmtbuf[i++] = '*';
if (long_modifier)
fmtbuf[i++] = long_modifier;
switch (flags & ios_base::floatfield)
{
case ios_base::scientific:
fmtbuf[i++] = (flags & ios_base::uppercase) ? 'E' : 'e';
break;
case ios_base::fixed:
# if defined (__FreeBSD__)
fmtbuf[i++] = 'f';
# else
fmtbuf[i++] = (flags & ios_base::uppercase) ? 'F' : 'f';
# endif
break;
default:
fmtbuf[i++] = (flags & ios_base::uppercase) ? 'G' : 'g';
break;
}
fmtbuf[i] = 0;
}
#endif /* USE_SPRINTF_INSTEAD */
template <class _FloatT>
static size_t __write_floatT(__iostring &buf, ios_base::fmtflags flags, int precision,
_FloatT x
#if defined (USE_SPRINTF_INSTEAD)
, char modifier) {
/* In theory, if we want 'arbitrary' precision, we should use 'arbitrary'
* buffer size below, but really we limited by exponent part in double.
* - ptr
*/
typedef numeric_limits<_FloatT> limits;
char static_buf[limits::max_exponent10 + 6]; // 6: -xxx.yyyE-zzz (sign, dot, E, exp sign, \0)
char fmtbuf[32];
__fill_fmtbuf(fmtbuf, flags, modifier);
snprintf(_STLP_ARRAY_AND_SIZE(static_buf), fmtbuf, precision, x);
buf = static_buf;
return find_if(buf.begin(), buf.end(), GroupPos()) - buf.begin();
#else
) {
typedef numeric_limits<_FloatT> limits;
//If numeric_limits support is correct we use the exposed values to detect NaN and infinity:
if (limits::has_infinity && limits::has_quiet_NaN) {
if (!(x == x) || // NaN check
(x == limits::infinity() || x == -limits::infinity())) {
return __format_nan_or_inf(buf, x, flags);
}
}
// numeric_limits support is not good enough, we rely on platform dependent function
// _Stl_is_nan_or_inf that do not support long double.
else if (_Stl_is_nan_or_inf(x)) {
return __format_nan_or_inf(buf, x, flags);
}
# if defined (__MINGW32__)
//For the moment MinGW is limited to display at most numeric_limits<double>::max()
if (x > numeric_limits<double>::max() ||
x < -numeric_limits<double>::max()) {
return __format_nan_or_inf(buf, x, flags);
}
# endif
/* Buffer size is max number of digits which is the addition of:
* - max_exponent10: max number of digits in fixed mode
* - digits10 + 2: max number of significant digits
* - trailing '\0'
*/
char cvtbuf[limits::max_exponent10 + limits::digits10 + 2 + 1];
char *bp;
int decpt, sign;
switch (flags & ios_base::floatfield) {
case ios_base::fixed:
{
/* Here, number of digits represents digits _after_ decimal point.
* In order to limit static buffer size we have to give 2 different values depending on x value.
* For small values (abs(x) < 1) we need as many digits as requested by precision limited by the maximum number of digits
* which is min_exponent10 + digits10 + 2
* For bigger values we won't have more than limits::digits10 + 2 digits after decimal point. */
int digits10 = (x > -1.0 && x < 1.0 ? -limits::min_exponent10 + limits::digits10 + 2
: limits::digits10 + 2);
bp = _Stl_fcvtR(x, (min) (precision, digits10), &decpt, &sign, _STLP_CVT_BUFFER(cvtbuf) );
}
break;
case ios_base::scientific:
default:
/* Here, number of digits is total number of digits which is limited to digits10 + 2. */
{
int digits10 = limits::digits10 + 2;
bp = _Stl_ecvtR(x, (min) (precision, digits10), &decpt, &sign, _STLP_CVT_BUFFER(cvtbuf) );
}
break;
}
return __format_float(buf, bp, decpt, sign, x == 0.0, flags, precision);
#endif
}
size_t _STLP_CALL
__write_float(__iostring &buf, ios_base::fmtflags flags, int precision,
double x) {
return __write_floatT(buf, flags, precision, x
#if defined (USE_SPRINTF_INSTEAD)
, 0
#endif
);
}
#if !defined (_STLP_NO_LONG_DOUBLE)
size_t _STLP_CALL
__write_float(__iostring &buf, ios_base::fmtflags flags, int precision,
long double x) {
return __write_floatT(buf, flags, precision, x
#if defined (USE_SPRINTF_INSTEAD)
, 'L'
#endif
);
}
#endif
void _STLP_CALL __get_floor_digits(__iostring &out, _STLP_LONGEST_FLOAT_TYPE __x) {
typedef numeric_limits<_STLP_LONGEST_FLOAT_TYPE> limits;
#if defined (USE_SPRINTF_INSTEAD)
char cvtbuf[limits::max_exponent10 + 6];
# if !defined (_STLP_NO_LONG_DOUBLE)
snprintf(_STLP_ARRAY_AND_SIZE(cvtbuf), "%Lf", __x); // check for 1234.56!
# else
snprintf(_STLP_ARRAY_AND_SIZE(cvtbuf), "%f", __x); // check for 1234.56!
# endif
char *p = strchr( cvtbuf, '.' );
if ( p == 0 ) {
out.append( cvtbuf );
} else {
out.append( cvtbuf, p );
}
#else
char cvtbuf[limits::max_exponent10 + 1];
char * bp;
int decpt, sign;
bp = _Stl_fcvtR(__x, 0, &decpt, &sign, _STLP_CVT_BUFFER(cvtbuf));
if (sign) {
out += '-';
}
out.append(bp, bp + decpt);
#endif
}
#if !defined (_STLP_NO_WCHAR_T)
void _STLP_CALL __convert_float_buffer( __iostring const& str, __iowstring &out,
const ctype<wchar_t>& ct, wchar_t dot, bool __check_dot) {
string::const_iterator str_ite(str.begin()), str_end(str.end());
//First loop, check the dot char
if (__check_dot) {
while (str_ite != str_end) {
if (*str_ite != '.') {
out += ct.widen(*str_ite++);
} else {
out += dot;
break;
}
}
} else {
if (str_ite != str_end) {
out += ct.widen(*str_ite);
}
}
if (str_ite != str_end) {
//Second loop, dot has been found, no check anymore
while (++str_ite != str_end) {
out += ct.widen(*str_ite);
}
}
}
#endif
void _STLP_CALL
__adjust_float_buffer(__iostring &str, char dot) {
if ('.' != dot) {
size_t __dot_pos = str.find('.');
if (__dot_pos != string::npos) {
str[__dot_pos] = dot;
}
}
}
_STLP_MOVE_TO_STD_NAMESPACE
_STLP_END_NAMESPACE
// Local Variables:
// mode:C++
// End:

Просмотреть файл

@ -1,46 +0,0 @@
/*
* Copyright (c) 1999
* Silicon Graphics Computer Systems, Inc.
*
* Copyright (c) 1999
* Boris Fomitchev
*
* This material is provided "as is", with absolutely no warranty expressed
* or implied. Any use is at your own risk.
*
* Permission to use or copy this software for any purpose is hereby granted
* without fee, provided the above notices are retained on all copies.
* Permission to modify the code and to distribute modified code is granted,
* provided the above notices are retained, and a notice that the code was
* modified is included with the above copyright notice.
*
*/
#include "stlport_prefix.h"
#include <locale>
_STLP_BEGIN_NAMESPACE
//----------------------------------------------------------------------
// numpunct<char>
char numpunct<char>::do_decimal_point() const {return '.';}
char numpunct<char>::do_thousands_sep() const { return ','; }
string numpunct<char>::do_grouping() const { return string();}
string numpunct<char>::do_truename() const { return "true";}
string numpunct<char>::do_falsename() const { return "false"; }
numpunct<char>::~numpunct() {}
#if !defined (_STLP_NO_WCHAR_T)
wchar_t numpunct<wchar_t>::do_decimal_point() const { return L'.'; }
wchar_t numpunct<wchar_t>::do_thousands_sep() const { return L','; }
string numpunct<wchar_t>::do_grouping() const { return string(); }
wstring numpunct<wchar_t>::do_truename() const { return L"true"; }
wstring numpunct<wchar_t>::do_falsename() const { return L"false"; }
numpunct<wchar_t>::~numpunct() {}
#endif
_STLP_END_NAMESPACE
// Local Variables:
// mode:C++
// End:

Просмотреть файл

@ -1,47 +0,0 @@
/*
* Copyright (c) 1999
* Silicon Graphics Computer Systems, Inc.
*
* Copyright (c) 1999
* Boris Fomitchev
*
* This material is provided "as is", with absolutely no warranty expressed
* or implied. Any use is at your own risk.
*
* Permission to use or copy this software for any purpose is hereby granted
* without fee, provided the above notices are retained on all copies.
* Permission to modify the code and to distribute modified code is granted,
* provided the above notices are retained, and a notice that the code was
* modified is included with the above copyright notice.
*
*/
#include "stlport_prefix.h"
#include <ostream>
_STLP_BEGIN_NAMESPACE
#if !defined(_STLP_NO_FORCE_INSTANTIATE)
// instantiations
template class _STLP_CLASS_DECLSPEC basic_ostream<char, char_traits<char> >;
# if defined (_STLP_USE_TEMPLATE_EXPORT)
template class _STLP_CLASS_DECLSPEC _Osentry<char, char_traits<char> >;
# endif
#ifndef _STLP_NO_WCHAR_T
# if defined (_STLP_USE_TEMPLATE_EXPORT)
template class _STLP_CLASS_DECLSPEC _Osentry<wchar_t, char_traits<wchar_t> >;
# endif
template class _STLP_CLASS_DECLSPEC basic_ostream<wchar_t, char_traits<wchar_t> >;
#endif
#endif
_STLP_END_NAMESPACE
// Local Variables:
// mode:C++
// End:

Просмотреть файл

@ -1,68 +0,0 @@
.section ".text",#alloc,#execinstr
.align 8
.skip 16
/*
** int _STLP_atomic_exchange (void *pvalue, int value)
*/
.type _STLP_atomic_exchange,#function
.global _STLP_atomic_exchange
.align 8
_STLP_atomic_exchange:
0:
ld [%o0], %o2 ! Set the current value
mov %o1, %o3 ! Set the new value
! swap [%o0], %o3 ! Do the compare and swap
cas [%o0], %o2, %o3
cmp %o2, %o3 ! Check whether successful
bne 0b ! Retry upon failure
stbar
mov %o2, %o0 ! Set the new value
retl ! return
nop
.size _STLP_atomic_exchange,(.-_STLP_atomic_exchange)
/* int _STLP_atomic_increment (void *pvalue) */
.type _STLP_atomic_increment,#function
.global _STLP_atomic_increment
.align 8
_STLP_atomic_increment:
1:
ld [%o0], %o2 ! set the current
add %o2, 0x1, %o3 ! Increment and store current
! swap [%o0], %o3 ! Do the compare and swap
cas [%o0], %o2, %o3
cmp %o3, %o2 ! Check whether successful
bne 1b ! Retry if we failed.
membar #LoadLoad | #LoadStore ! Ensure the cas finishes before
! returning
nop
retl ! return
nop
.size _STLP_atomic_increment,(.-_STLP_atomic_increment)
/* int _STLP_atomic_decrement (void *pvalue) */
.type _STLP_atomic_decrement,#function
.global _STLP_atomic_decrement
.align 8
_STLP_atomic_decrement:
2:
ld [%o0], %o2 ! set the current
sub %o2, 0x1, %o3 ! decrement and store current
! swap [%o0], %o3 ! Do the compare and swap
cas [%o0], %o2, %o3
cmp %o3, %o2 ! Check whether successful
bne 2b ! Retry if we failed.
membar #LoadLoad | #LoadStore ! Ensure the cas finishes before
nop
! returning
retl ! return
nop
.size _STLP_atomic_decrement,(.-_STLP_atomic_decrement)

Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше