Back to index

lightning-sunbird  0.9+nobinonly
Classes | Functions
nsMorkReader.cpp File Reference
#include "nsMorkReader.h"
#include "prio.h"
#include "nsNetUtil.h"
#include "nsVoidArray.h"

Go to the source code of this file.

Classes

class  nsCLineString
struct  AddColumnClosure

Functions

PRBool ConvertChar (char *c)
static void MorkUnescape (const nsCSubstring &aString, nsCString &aResult)
 DeleteStringArray (const nsCSubstring &aKey, nsTArray< nsCString > *aData, void *aUserArg)
 AddColumn (const nsCSubstring &id, nsCString name, void *userData)

Function Documentation

AddColumn ( const nsCSubstring id,
nsCString  name,
void userData 
)

Definition at line 174 of file nsMorkReader.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

PRBool ConvertChar ( char *  c) [inline]

Definition at line 62 of file nsMorkReader.cpp.

{
  char c1 = *c;
  if ('0' <= c1 && c1 <= '9') {
    *c = c1 - '0';
    return PR_TRUE;
  }
  if ('A' <= c1 && c1 <= 'F') {
    *c = c1 - 'A' + 10;
    return PR_TRUE;
  }
  return PR_FALSE;
}

Here is the caller graph for this function:

DeleteStringArray ( const nsCSubstring aKey,
nsTArray< nsCString > *  aData,
void aUserArg 
)

Definition at line 149 of file nsMorkReader.cpp.

{
  delete aData;
  return PL_DHASH_NEXT;
}

Here is the caller graph for this function:

static void MorkUnescape ( const nsCSubstring aString,
nsCString aResult 
) [static]

Definition at line 81 of file nsMorkReader.cpp.

{
  PRUint32 len = aString.Length();

  // We optimize for speed over space here -- size the result buffer to
  // the size of the source, which is an upper bound on the size of the
  // unescaped string.
  // FIXME: Mork assume there will never be errors
  if (!EnsureStringLength(aResult, len)) {
    aResult.Truncate();
    return; // out of memory.
  }

  char *result = aResult.BeginWriting();
  const char *source = aString.BeginReading();
  const char *sourceEnd = source + len;

  const char *startPos = nsnull;
  PRUint32 bytes;
  for (; source < sourceEnd; ++source) {
    char c = *source;
    if (c == '\\') {
      if (startPos) {
        bytes = source - startPos;
        memcpy(result, startPos, bytes);
        result += bytes;
        startPos = nsnull;
      }
      if (source < sourceEnd - 1) {
        *(result++) = *(++source);
      }
    } else if (c == '$') {
      if (startPos) {
        bytes = source - startPos;
        memcpy(result, startPos, bytes);
        result += bytes;
        startPos = nsnull;
      }
      if (source < sourceEnd - 2) {
        // Would be nice to use ToInteger() here, but it currently
        // requires a null-terminated string.
        char c2 = *(++source);
        char c3 = *(++source);
        if (ConvertChar(&c2) && ConvertChar(&c3)) {
          *(result++) = ((c2 << 4) | c3);
        }
      }
    } else if (!startPos) {
      startPos = source;
    }
  }
  if (startPos) {
    bytes = source - startPos;
    memcpy(result, startPos, bytes);
    result += bytes;
  }
  aResult.SetLength(result - aResult.BeginReading());
}

Here is the call graph for this function:

Here is the caller graph for this function: