Back to index

texmacs  1.0.7.15
Functions
pst_obj.h File Reference
#include "pst.h"
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

pst_objpst_parse_null (unsigned char **inbuf, unsigned char *inbufend)
pst_objpst_parse_boolean (unsigned char **inbuf, unsigned char *inbufend)
pst_objpst_parse_name (unsigned char **inbuf, unsigned char *inbufend)
pst_objpst_parse_number (unsigned char **inbuf, unsigned char *inbufend)
pst_objpst_parse_string (unsigned char **inbuf, unsigned char *inbufend)

Function Documentation

pst_obj* pst_parse_boolean ( unsigned char **  inbuf,
unsigned char *  inbufend 
)

Definition at line 367 of file pst_obj.c.

{
  if (*inbuf + 4 <= inbufend &&
      memcmp(*inbuf, "true", 4) == 0 &&
      PST_TOKEN_END(*inbuf + 4, inbufend)) {
    *inbuf += 4;
    return pst_new_obj(PST_TYPE_BOOLEAN, pst_boolean_new(1));
  } else if (*inbuf + 5 <= inbufend &&
            memcmp(*inbuf, "false", 5) == 0 &&
            PST_TOKEN_END(*inbuf + 5, inbufend)) {
    *inbuf += 5;
    return pst_new_obj(PST_TYPE_BOOLEAN, pst_boolean_new(0));
  } else
    return NULL;
}

Here is the call graph for this function:

Here is the caller graph for this function:

pst_obj* pst_parse_name ( unsigned char **  inbuf,
unsigned char *  inbufend 
)

Definition at line 633 of file pst_obj.c.

{
  unsigned char  wbuf[PST_NAME_LEN_MAX+1];
  unsigned char  c, *p = wbuf, *cur = *inbuf;
  int     len = 0;

  if (*cur != '/')
    return NULL;
  cur++;

  while (!PST_TOKEN_END(cur, inbufend)) {
    c = *cur++;
    if (c == '#') {
      int val;
      if (cur + 2 >= inbufend) {
       WARN("Premature end of input name string.");
       break;
      }
      val = getxpair(&cur);
      if (val <= 0) {
       WARN("Invalid char for name object. (ignored)");
       continue;
      } else
       c = (unsigned char) val;
    }
    if (len < PST_NAME_LEN_MAX)
      *p++ = c;
    len++;
  }
  *p = '\0';

  if (len > PST_NAME_LEN_MAX)
    WARN("String too long for name object. Output will be truncated.");

  *inbuf = cur;
  return pst_new_obj(PST_TYPE_NAME, pst_name_new((char *)wbuf));
}

Here is the call graph for this function:

Here is the caller graph for this function:

pst_obj* pst_parse_null ( unsigned char **  inbuf,
unsigned char *  inbufend 
)

Definition at line 386 of file pst_obj.c.

{
  if (*inbuf + 4 <= inbufend &&
      memcmp(*inbuf, "null", 4) == 0 &&
      PST_TOKEN_END(*inbuf+4, inbufend)) {
    *inbuf += 4;
    return pst_new_obj(PST_TYPE_NULL, (void*)pst_const_null);
  } else
    return NULL;
}

Here is the call graph for this function:

Here is the caller graph for this function:

pst_obj* pst_parse_number ( unsigned char **  inbuf,
unsigned char *  inbufend 
)

Definition at line 527 of file pst_obj.c.

{
  unsigned char  *cur;
  long    lval;
  double  dval;

  errno = 0;
  lval = strtol((char *) *inbuf, (char **) (void *) &cur, 10);
  if (errno || *cur == '.' || *cur == 'e' || *cur == 'E') {
    /* real */
    errno = 0;
    dval = strtod((char *) *inbuf, (char **) (void *) &cur);
    if (!errno && PST_TOKEN_END(cur, inbufend)) {
      *inbuf = cur;
      return pst_new_obj(PST_TYPE_REAL, pst_real_new(dval));
    }
  } else if (cur != *inbuf && PST_TOKEN_END(cur, inbufend)) {
    /* integer */
    *inbuf = cur;
    return pst_new_obj(PST_TYPE_INTEGER, pst_integer_new(lval));
  } else if (lval >= 2 && lval <= 36 && *cur == '#' && isalnum(*++cur) &&
            /* strtod allows leading "0x" for hex numbers, but we don't */
            (lval != 16 || (cur[1] != 'x' && cur[1] != 'X'))) {
    /* integer with radix */
    /* Can the base have a (plus) sign? I think yes. */
    errno = 0;
    lval = strtol((char *) cur, (char **) (void *) &cur, lval);
    if (!errno && PST_TOKEN_END(cur, inbufend)) {
      *inbuf = cur;
      return pst_new_obj(PST_TYPE_INTEGER, pst_integer_new(lval));
    }
  }
  /* error */
  return NULL;
}

Here is the call graph for this function:

Here is the caller graph for this function:

pst_obj* pst_parse_string ( unsigned char **  inbuf,
unsigned char *  inbufend 
)

Definition at line 741 of file pst_obj.c.

{
  if (*inbuf + 2 >= inbufend) {
    return NULL;
  } else if (**inbuf == '(')
    return pst_new_obj(PST_TYPE_STRING, pst_string_parse_literal(inbuf, inbufend));
  else if (**inbuf == '<' && *(*inbuf+1) == '~')
    ERROR("ASCII85 string not supported yet.");
  else if (**inbuf == '<')
    return pst_new_obj(PST_TYPE_STRING, pst_string_parse_hex(inbuf, inbufend));
  return NULL;
}

Here is the call graph for this function:

Here is the caller graph for this function: