This file is indexed.

/usr/share/yacas/include/lispstring.h is in yacas 1.3.1-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
/** \file lispstring.h
 *  Defining a string class.
 */


#ifndef __lispstring_h__
#define __lispstring_h__

#include "yacasbase.h"
#include "grower.h"
#include "refcount.h"

class LispStringSmartPtr;


/** \class LispString : zero-terminated byte-counted string.
 * Also keeps a reference count for any one interested.
 * LispString is derived from CArrayGrower, so the function
 * Size returns the length of the buffer. Since the string
 * is also zero-terminated (for better interfacing with the normal
 * c functions), the string length is Size()-1.
 *
 * This class also allows the string to point to a buffer which is owned
 * by another part of the system, in which case it cannot be resized.
 * The array will then not be freed by this class.
 */
class LispString : public CArrayGrower<LispChar,ArrOpsPOD<LispChar> >
{
public:
  // Constructors
    // The constructors allow the caller to specify whether the storage is owned externally.
  // Use the assignment operators to set the string after this.
    inline LispString();
    inline LispString(LispString &aString, LispBoolean aStringOwnedExternally=LispFalse);
    inline LispString(LispChar * aString, LispBoolean aStringOwnedExternally);
    inline LispString(const LispChar * aString);

  // Assignment
  // This assignment abides by earlier functions setting the string as owned externally.
    inline LispString& operator=(LispChar * aString);

  // Assignments (with modifications).  This string cannot be owned externally.
    // Set string by taking part of another string.
    void SetStringCounted(const LispChar * aString, LispInt aLength);
    // Set string from other string, adding quotes around the string.
    void SetStringUnStringified(const LispChar * aString);
    // Set string from other string, removing quotes around the string.
    void SetStringStringified(const LispChar * aString);

  // Access
    inline LispChar * c_str() const;  // pointer to asciz 'C-string'

    // Comparison
  // If the string is in the hash table it is faster to compare the pointers to the strings
  // (instead of calling this routine), since in that case if they
    // are equal they should in fact be literally the same object.
    LispInt operator==(const LispString& aString);

    ~LispString();
private:
    inline void SetString(LispChar * aString, LispBoolean aStringOwnedExternally);
  void SetString(const LispChar * aString);
public:
  ReferenceCount iReferenceCount;
};


/** \class LispStringSmartPtr for managing strings outside
 of normal objects. This is the equivalent of LispPtr, maintaining
 a reference count for the string object.
 */
class LispStringSmartPtr
{
public:
  // Default constructor (not explicit, so it auto-initializes)
  LispStringSmartPtr() : iString(NULL) {}

  // Construct from pointer to LispString
  LispStringSmartPtr(LispString * aString) : iString(NULL)
  {
    this->operator=(aString);
  }

  // Copy constructor
  LispStringSmartPtr(const LispStringSmartPtr& aOther) : iString()
  {
    this->operator=(aOther.iString);
  }

  // Destructor
  ~LispStringSmartPtr();

  // Assignment from pointer.  (PDG - new method)
  // (we return void, not *this).
  LispStringSmartPtr& operator=(LispString * aString);

  // Assignment from another (the *default* simply assigns members, not what we want).
  // (we return void, not *this).
  LispStringSmartPtr& operator=(const LispStringSmartPtr &aOther) { this->operator=(aOther.iString); return *this; }

  // Expected pointer behavior.
  operator LispString*()    const { return  iString; }  // implicit conversion to pointer to T
  LispString *operator->()  const { return  iString; }  // so (smartPtr->member) accesses T's member
 
  // Operators below are not used yet, so they are commented out. If you want to use them you need to test if they work.
  //LispString &operator*() const { return *iString; }  // so (*smartPtr) is a reference to T
  //LispString *ptr()       const { return  iString; }  // so (smartPtr.ptr()) returns the pointer to T (boost calls this method 'get')
  //bool operator!()        const { return !iString; }  // is null pointer

private:
  LispString * iString;
};

#include "lispstring.inl"
#endif