예제 #1
0
int MFAnyStrPtr(WYSIWYG *wn, CNTRLS *control, int frame, char *data, int to_ac)
{
	if (trace_misc)
		p_info(PI_TRACE, "entering MFAnyStrPtr(p%1d:%#x %s data:%#x)\n",
				  control->off_rel, *(&REL_DATA(frame) p0 + control-> off_rel),
				  to_ac ? "-->" : "<--", data);
	
	if (to_ac)
	{
		if (*(&REL_DATA(frame) p0 + control -> off_rel) && data)
			strcpy(data, *(&REL_DATA(frame) p0 + control -> off_rel));
	}
	else if (data)
	{
		if (*(&REL_DATA(frame) p0 + control -> off_rel))
			*(&REL_DATA(frame) p0 + control -> off_rel) =
				p_realloc(*(&REL_DATA(frame) p0	+ control -> off_rel),
						  strlen(data)+1);
		else
			*(&REL_DATA(frame) p0 + control -> off_rel) =
				p_alloc(strlen(data)+1);
		
		strcpy(*(&REL_DATA(frame) p0 + control -> off_rel), data);
	}
	
	if (trace_misc)
		p_info(PI_TRACE, "leaving MFAnyStrPtr(p%1d:%#x %s data:%#x (%s))\n",
				  control->off_rel, *(&REL_DATA(frame) p0 + control-> off_rel),
				  to_ac ? "-->" : "<--", data, data ? data : "NULL");
	return(0);					/* Just so it returns something */
}
예제 #2
0
파일: yinput.c 프로젝트: dhmunro/yorick
void YpPush(const char *input)
{
  if (nYpInputs>=maxYpInputs) {
    int newSize= maxYpInputs+4;
    ypInputs= p_realloc(ypInputs, sizeof(char *)*newSize);
    maxYpInputs= newSize;
  }
  ypInputs[nYpInputs++]= p_strcpy(input);
}
예제 #3
0
파일: parse.c 프로젝트: MattWherry/yorick
static int CheckConstSpace(void)
{
  if (nConstants >= maxConstants) {
    long newSize= (maxConstants? maxConstants<<1 : 16);
    constantTable= p_realloc(constantTable, sizeof(Symbol)*newSize);
    maxConstants= newSize;
  }
  return 0;
}
예제 #4
0
파일: parse.c 프로젝트: MattWherry/yorick
static void RecordLineNumber(long pc)
{
  if ((nYpReList&0xff)==0) {
    long newSize= nYpReList+0x100;
    ypReList= p_realloc(ypReList, sizeof(long)*newSize);
  }
  ypReList[nYpReList++]= pc;              /* record pc and... */
  ypReList[nYpReList++]= YpLineNumber();  /* ...corresponding line number */
}
예제 #5
0
파일: parse.c 프로젝트: MattWherry/yorick
static int ConstantReference(long pc)
{
  if (nConstantRefs >= maxConstantRefs) {
    long newSize= (maxConstantRefs? maxConstantRefs<<1 : 16);
    constantRefs= p_realloc(constantRefs, sizeof(long)*newSize);
    maxConstantRefs= newSize;
  }
  constantRefs[nConstantRefs++]= pc;
  return 0;
}
예제 #6
0
파일: yinput.c 프로젝트: dhmunro/yorick
static void AddPrefix(char *prefix)
{
  if (nYpPrefixes>=maxYpPrefixes) {
    int newSize= maxYpPrefixes+4;
    ypPrefixes= p_realloc(ypPrefixes, sizeof(char *)*newSize);
    maxYpPrefixes= newSize;
  }
  YNameToHead(&prefix);
  ypPrefixes[nYpPrefixes++]= prefix;
}
예제 #7
0
파일: parse.c 프로젝트: MattWherry/yorick
static void PushMarkStack(int pushing)
{
  if (nMatrixMarkers >= maxMatrixMarkers) {
    long newSize= maxMatrixMarkers+4;
    matrixMarkers= p_realloc(matrixMarkers, sizeof(MatrixMarker)*newSize);
    maxMatrixMarkers= newSize;
  }
  matrixMarkers[nMatrixMarkers].stackDepth= stackDepth+pushing;
  matrixMarkers[nMatrixMarkers++].evalled= 0;
}
예제 #8
0
파일: parse.c 프로젝트: MattWherry/yorick
static void PushBreak(int isBreak, long pc)
{
  if (nextBSP >= breakStackSize) {
    breakStack= p_realloc(breakStack, sizeof(BreakStack)*(breakStackSize+16));
    breakStackSize+= 16;
  }
  breakStack[nextBSP].id= (loopDepth<<1)|isBreak;
  breakStack[nextBSP].pc= pc;
  nextBSP++;
}
예제 #9
0
파일: parse.c 프로젝트: MattWherry/yorick
static int CheckCodeSpace(long n)
{
  if (nextPC+n > vmCodeSize) {
    long newSize= (vmCodeSize? vmCodeSize<<1 : 64);
    vmCode= p_realloc(vmCode, sizeof(Instruction)*newSize);
    memset(&vmCode[vmCodeSize], 0, sizeof(Instruction)*(newSize-vmCodeSize));
    vmCodeSize= newSize;
  }
  return 0;
}
예제 #10
0
파일: upoll.c 프로젝트: MattWherry/yorick
int
u__poll(struct pollfd *fds, unsigned long int nfds, int timeout)
{
  int i, n, bit, word;
  int maxfd = -1;
  struct timeval tm, *ptm;

  for (i=0 ; i<nfds ; i++) if (fds[i].fd>maxfd) maxfd = fds[i].fd;
  if (maxfd+1 > poll_n*(8*sizeof(unsigned int))) {
    n = poll_n? (poll_n<<1) : 8;
    poll_mask = p_realloc(poll_mask, 2*n*sizeof(unsigned int));
    poll_n = n;
  }
  n = maxfd<0? -1 : maxfd/(8*sizeof(unsigned int));
  for (i=0 ; i<=n ; i++) poll_mask[i]= poll_mask[poll_n+i]= 0;

  for (i=0 ; i<nfds ; i++) {
    if (fds[i].fd>=0) {
      word = fds[i].fd/(8*sizeof(unsigned int));
      bit = 1 << (fds[i].fd%(8*sizeof(unsigned int)));
      if (fds[i].events&(POLLIN|POLLPRI)) poll_mask[word]|= bit;
      poll_mask[poll_n+word]|= bit;
      fds[i].revents = 0;
    } else {
      fds[i].revents = POLLNVAL;
    }
  }

  if (timeout>=0) {
    ptm = &tm;
    tm.tv_sec = timeout/1000;
    tm.tv_usec = 1000*(timeout%1000);
  } else {
    ptm = 0;
  }

  /* select may return EBADF, poll cannot
   * select cannot return EAGAIN, poll may
   * the critical EINTR errno is the same for either
   * return value is same for select as poll */
  n = select(maxfd+1, (void *)poll_mask, (void *)0,
             (void *)(poll_mask+poll_n), ptm);

  if (n>0) {
    for (i=0 ; i<nfds && n>0 ; i++)
      if (fds[i].fd>=0) {
        word = fds[i].fd/(8*sizeof(unsigned int));
        bit = 1 << (fds[i].fd%(8*sizeof(unsigned int)));
        if (poll_mask[word] & bit) fds[i].revents |= POLLIN;
        if (poll_mask[poll_n+word] & bit) fds[i].revents |= POLLERR;
      }
  }

  return n;
}
예제 #11
0
/* ARGSUSED */
static void
u_fd0_ready(void *c)
{
  char *line = u_input_line;
  int n;

  /* before calling fgets, check to be sure that this process is
   * not in the background (via UNIX shell job control) */
  if (u_in_background()) return;

  do {
    if (u_input_max < (line-u_input_line)+1024) {
      if (u_input_max > 16000) break;
      n = line - u_input_line;
      u_input_line = p_realloc(u_input_line, u_input_max+1024);
      u_input_max += 1024;
      line = u_input_line + n;
    }
    if (!fgets(line, 1024, stdin)) {
      int at_eof = feof(stdin);
      clearerr(stdin);
      if (++u_term_errs>3 || at_eof) {
        /* cannot read stdin -- maybe serious error, remove it */
        u_event_src(0, (void (*)(void *))0, (void *)0);
        return;
      }
    } else {
      u_term_errs = 0;  /* reset error counter on each successful read */
    }
    n = strlen(line);
    line += n;
  } while (n==1023 && line[-1]!='\n');
  if (line[-1]=='\n') line[-1] = '\0';

  if (u_stdin) u_stdin(u_input_line);
  else p_stderr("\a");  /* beep to indicate rejection */

  if (u_input_max>1024) {
    u_input_line = p_realloc(u_input_line, 1024);
    u_input_max = 1024;
  }
}
예제 #12
0
파일: parse.c 프로젝트: MattWherry/yorick
static int VariableReference(Literal name)
{
  if (nVariableRefs >= maxVariableRefs) {
    long newSize= (maxVariableRefs? maxVariableRefs<<1 : 16);
    variableRefs= p_realloc(variableRefs, sizeof(long)*newSize);
    maxVariableRefs= newSize;
  }
  variableRefs[nVariableRefs++]= nextPC;
  vmCode[nextPC++].index= name;
  literalTypes[name]|= L_REFERENCE;
  return 0;
}
예제 #13
0
bool TBTempBuffer::Reserve(int size)
{
	if (size > m_data_size)
	{
		char *new_data = p_realloc(m_data, size);
		if (!new_data)
			return false;
		m_data = new_data;
		m_data_size = size;
	}
	return true;
}
예제 #14
0
void buffer_verify_pool(buffer_t *_buf)
{
	const struct real_buffer *buf = (const struct real_buffer *)_buf;
	void *ret;

	if (buf->pool != NULL && buf->pool->datastack_pool && buf->alloc > 0) {
		/* this doesn't really do anything except verify the
		   stack frame */
		ret = p_realloc(buf->pool, buf->w_buffer,
				buf->alloc, buf->alloc);
		i_assert(ret == buf->w_buffer);
	}
}
예제 #15
0
p_scr *
g_connect(char *displayName)
{
  p_scr *s = 0;
  int i, j, i0=-1, len=0, number=0;

  /* split display into base name and screen number (separated by dot) */
  if (displayName) while (displayName[len]) len++;
  if (len) {
    for (i=len-1 ; i>=0 ; i--) if (displayName[i]=='.') break;
    if (i>=0) {
      int i0 = i;
      for (i++ ; i<len && displayName[i]<='9' && displayName[i]>='0' ; i++)
        number = 10*number + (displayName[i]-'0');
      if (i == len) len = i0;
      else number = 0;
    }
  }
  if (!len) displayName = 0;
  if (g_screens) {
    for (i=0 ; i<n_screens ; i++) {
      j = 0;
      if (g_screens[i].name) {
        for ( ; j<len ; j++)
          if (g_screens[i].s && g_screens[i].name[j]!=displayName[j]) break;
      }
      if (j==len && (len? (!g_screens[i].name[j]) : !g_screens[i].name)) {
        if (number == g_screens[i].number) break;
        else if (i0<0) i0 = i;
      }
    }
    if (i<n_screens) s = g_screens[i].s;
  }
  if (!s) {
    if (i0<0) s = p_connect(displayName);
    else s = p_multihead(g_screens[i0].s, number);
    if (!s) return s;
    g_test_pending(s);
    for (i=0 ; i<n_screens ; i++) if (!g_screens[i].s) break;
    if (i==n_screens && !(i & (i-1))) {
      int n = i? 2*i : 1;
      g_screens = p_realloc(g_screens, sizeof(g_scr)*n);
    }
    g_screens[i].number = number;
    g_screens[i].name = displayName? p_strncat(0, displayName, len) : 0;
    g_screens[i].s = s;
    if (i==n_screens) n_screens++;
  }

  return s;
}
예제 #16
0
파일: std2.c 프로젝트: MattWherry/yorick
static void
y_add_item(void *plist, long *pn, void *item)
{
  void **list = *(void ***)plist;
  long n = *pn;
  if (!list) {
    *(void ***)plist = list = p_malloc(sizeof(void *)*32);
    n = 0;
  } else if (n>31 && !((n-1)&n)) {
    *(void ***)plist = list = p_realloc(list, sizeof(void *)*2*n);
  }
  list[n] = item;
  *pn = n+1;
}
예제 #17
0
파일: yinput.c 프로젝트: dhmunro/yorick
static p_file *PushInclude(const char *filename, int fullparse)
{
  p_file *file= 0;
  char *name= 0;
  long i;

  if (YIsAbsolute(filename)) {
    /* absolute pathname doesn't need any prefix */
    file= open_include(filename, fullparse);
    if (!file) return 0;
    name= p_strcpy(filename);

  } else {
    char *tmp;
    for (i=0 ; i<=nYpPrefixes ; i++) {
      if (i<nYpPrefixes) {
        tmp= p_strncat(ypPrefixes[i], filename, 0);
        name= YExpandName(tmp);
        p_free(tmp);
      } else {
        /* this branch is probably a bug --
         * if . is not on path probably should not find file...
         * maybe protects against empty path?
         */
        name= YExpandName(filename);
        if (!YIsAbsolute(name)) break;
      }
      file= open_include(name, fullparse);
      if (file) break;
      p_free(name);
    }
    if (!file) return 0;
  }

  if (nYpIncludes>=maxYpIncludes) {
    int newSize= maxYpIncludes+4;
    ypIncludes= p_realloc(ypIncludes, sizeof(IncludeFile)*newSize);
    maxYpIncludes= newSize;
  }

  if (fullparse) ClearSourceList(name);

  ypIncludes[nYpIncludes].file= file;
  ypIncludes[nYpIncludes].filename= name;
  ypIncludes[nYpIncludes].lastLineRead= 0;
  ypIncludes[nYpIncludes++].index = -1;
  prevErrLine= -1;
  return file;
}
예제 #18
0
파일: yinput.c 프로젝트: dhmunro/yorick
void
y_push_include(p_file *file, const char *filename)
{
  if (nYpIncludes >= maxYpIncludes) {
    int newSize = maxYpIncludes + 4;
    ypIncludes = p_realloc(ypIncludes, sizeof(IncludeFile)*newSize);
    maxYpIncludes = newSize;
  }

  ypIncludes[nYpIncludes].file = file;
  ypIncludes[nYpIncludes].filename = p_strcpy(filename);
  ypIncludes[nYpIncludes].lastLineRead = 0;
  ypIncludes[nYpIncludes++].index = -1;
  prevErrLine= -1;
}
예제 #19
0
static void buffer_alloc(struct real_buffer *buf, size_t size)
{
	i_assert(buf->w_buffer == NULL || buf->alloced);

	if (size == buf->alloc)
		return;

	i_assert(size > buf->alloc);

	buf->w_buffer = p_realloc(buf->pool, buf->w_buffer, buf->alloc, size);
	buf->alloc = size;

	buf->r_buffer = buf->w_buffer;
	buf->alloced = TRUE;
}
예제 #20
0
파일: parse.c 프로젝트: MattWherry/yorick
static int TargetReference(Literal label)
{
  if (nGotoTargets >= maxGotoTargets) {
    long newSize= (maxGotoTargets? maxGotoTargets<<1 : 16);
    gotoTargets= p_realloc(gotoTargets, sizeof(long)*newSize);
    maxGotoTargets= newSize;
  }
  if (!(literalTypes[label]&L_TARGET)) {
    literalTypes[label]|= L_TARGET;
    nTarget++;  /* count first forward reference to each label */
  }
  gotoTargets[nGotoTargets++]= nextPC;
  vmCode[nextPC++].index= label;
  return 0;
}
예제 #21
0
파일: parse.c 프로젝트: MattWherry/yorick
CodeBlock YpFor(CodeBlock init, CodeBlock test, CodeBlock body)
{
  long inc= nextPC;

  if (nextInc && incCode[nextInc-1].count==loopDepth) {
    /* move for-increment code out of incCode into vmCode */
    long delta= inc-body;   /* distance inc block will move */
    long n= incCode[nextInc-=2].index;
    long lastConstant= incCode[--nextInc].index;
    long lastVariable= incCode[--nextInc].index;
    long firstConstant= incCode[--nextInc].index;
    long firstVariable= incCode[--nextInc].index;
    long i;
    /* patch up line number information */
    if (reparsing) {
      long nLineNums= incCode[--nextInc].index;
      long size= nYpReList>0? ((nYpReList-1)&0xffffff00)+0x100 : 0;
      if (nYpReList+nLineNums > size) {
        size= ((nYpReList+nLineNums-1)&0xffffff00)+0x100;
        ypReList= p_realloc(ypReList, sizeof(long)*size);
      }
      nextInc-= nLineNums;
      for (i=0 ; i<nLineNums ; i+=2) {
        ypReList[nYpReList+i]= incCode[nextInc+i].index + delta;    /* pc */
        ypReList[nYpReList+i+1]= incCode[nextInc+i+1].index;    /* line # */
      }
      nYpReList+= nLineNums;
    }
    /* move code */
    i= (nextInc-= n);   /* nextInc points to first word of inc */
    if (CheckCodeSpace(n)) return init;
    while (n--) vmCode[nextPC++]= incCode[i++];
    /* adjust constant and variable references */
    while (firstConstant<lastConstant) constantRefs[firstConstant++]+= delta;
    while (firstVariable<lastVariable) variableRefs[firstVariable++]+= delta;
  }

  if (CheckCodeSpace(2)) return init;
  vmCode[nextPC++].Action= previousOp= &Branch;
  if (test==NONE) {
    SetBranchTarget(nextPC++, body);
  } else {
    SetBranchTarget(nextPC++, test);
    SetBranchTarget(body-1, nextPC);
  }
  PopBreak(nextPC, inc);
  return init;
}
예제 #22
0
파일: parse.c 프로젝트: MattWherry/yorick
void YpEndInc(CodeBlock inc)
{
  long nLineNums= 0;
  long initialPC= inc;
  long n= nextPC-initialPC;
  nextPC= initialPC;    /* set vmCode pc to overwrite for-increment code */

  if (reparsing) {
    long i= nYpReList-2;
    while (nLineNums<nYpReList && ypReList[i-nLineNums]>=initialPC)
      nLineNums+= 2;
    nLineNums++;  /* 1 extra to record count */
  }

  if (nextInc+n+nLineNums+6 > incCodeSize) {
    long newSize= (nextInc+n+nLineNums+76);
    incCode= p_realloc(incCode, newSize*sizeof(Instruction));
    incCodeSize= newSize;
  }

  /* move for-increment code out of vmCode buffer */
  while (n--) incCode[nextInc++]= vmCode[initialPC++];
  /* move line number information out of ypReList */
  if (reparsing) {
    long i;
    nLineNums--;
    nYpReList-= nLineNums;
    for (i=0 ; i<nLineNums ; i++)
      incCode[nextInc+i].index= ypReList[nYpReList+i];
    nextInc+= nLineNums;
    incCode[nextInc++].index= nLineNums;
  }
  /* variable reference PCs will need adjustment later */
  incCode[nextInc++].index= firstVariable;
  incCode[nextInc++].index= firstConstant;
  incCode[nextInc++].index= nVariableRefs;
  incCode[nextInc++].index= nConstantRefs;
  incCode[nextInc++].index= initialPC-nextPC; /* they've switched places */
  incCode[nextInc++].count= loopDepth;
}
예제 #23
0
파일: yinput.c 프로젝트: dhmunro/yorick
/* Record the given globTab index in the sourceList.  This index
   corresponds to either a func definition, a struct definition, or an
   extern statement outside of any functions.  */
long RecordSource(long index)
{
  long isrc = -1;
  if (nYpIncludes) {
    long *list, len;
    if (HashAdd(&sourceTab, ypIncludes[nYpIncludes-1].filename, 0L)) {
      list = sourceList[hashIndex];
      len = lenSourceList[hashIndex];
    } else {
      HASH_MANAGE(sourceTab, long *, sourceList);
      HASH_MANAGE(sourceTab, long, lenSourceList);
      sourceList[hashIndex] = list = 0;
      lenSourceList[hashIndex] = len = 0;
    }
    if (!(len&7))
      sourceList[hashIndex] = list = p_realloc(list, sizeof(long)*(len+8));
    list[len++] = index;
    lenSourceList[hashIndex] = len;
    isrc = hashIndex;
  }
  return isrc;
}
예제 #24
0
파일: key.c 프로젝트: Akulen/awesome
/* It's caller's responsibility to release the returned string. */
static char *
get_keysym_name(xkb_keysym_t keysym)
{
    const ssize_t bufsize = 64;
    char *buf = p_new(char, bufsize);
    ssize_t len;

    if((len = xkb_keysym_get_name(keysym, buf, bufsize)) == -1)
    {
        p_delete(&buf);
        return NULL;
    }
    if(len + 1 > bufsize)
    {
        p_realloc(&buf, len + 1);
        if(xkb_keysym_get_name(keysym, buf, len + 1) != len)
        {
            p_delete(&buf);
            return NULL;
        }
    }
    return buf;
}
예제 #25
0
/** Newindex function for graph widget.
 * \param L The Lua VM state.
 * \param token The key token.
 * \return The number of elements pushed on stack.
 */
static int
luaA_graph_newindex(lua_State *L, awesome_token_t token)
{
    size_t len;
    widget_t *widget = luaA_checkudata(L, 1, &widget_class);
    graph_data_t *d = widget->data;
    const char *buf;
    int width;
    position_t pos;
    color_t color;

    switch(token)
    {
    case A_TK_HEIGHT:
        d->height = luaL_checknumber(L, 3);
        break;
    case A_TK_WIDTH:
        width = luaL_checknumber(L, 3);
        if(width >= 2 && width != d->width)
        {
            d->width = width;
            d->size = d->width - 2;
            p_realloc(&d->draw_from, d->size);
            p_realloc(&d->draw_to, d->size);
            for(int i = 0; i < d->plots.len; i++)
            {
                plot_t *plot = &d->plots.tab[i];
                p_realloc(&plot->values, d->size);
                p_realloc(&plot->lines, d->size);
                p_clear(plot->values, d->size);
                p_clear(plot->lines, d->size);
                plot->index = 0;
                plot->current_max =  0;
                plot->max_index =  0;
            }
        }
        else
            return 0;
        break;
    case A_TK_BG:
        if((buf = luaL_checklstring(L, 3, &len)))
        {
            if(color_init_reply(color_init_unchecked(&color, buf, len)))
                d->bg = color;
            else
                return 0;
        }
        break;
    case A_TK_BORDER_COLOR:
        if((buf = luaL_checklstring(L, 3, &len)))
        {
            if(color_init_reply(color_init_unchecked(&color, buf, len)))
                d->border_color = color;
            else
                return 0;
        }
        break;
    case A_TK_GROW:
        buf = luaL_checklstring(L, 3, &len);
        switch((pos = position_fromstr(buf, len)))
        {
        case Left:
        case Right:
            d->grow = pos;
            break;
        default:
            return 0;
        }
        break;
    default:
        return 0;
    }

    widget_invalidate_bywidget(widget);

    return 0;
}
예제 #26
0
파일: fonts.c 프로젝트: MattWherry/yorick
static void
x_analyze(x_display *xdpy, int fam)
{
  int i, j, n, face, pixsize, nsizes;
  char *name;
  if (tmp_fonts) tmp_free();
  tmp_fonts = XListFonts(xdpy->dpy, pattern[((unsigned int)fam)>>2], 1024, &n);

  for (i=0 ; i<n ; i++) {
    name = x_face(tmp_fonts[i], &face);
    if (!name) continue;

    /* extract pixels field */
    pixsize = 0;
    if (name[0]!='*') while (name[0] && name[0]>='0' && name[0]<='9')
      pixsize = 10*pixsize + *(name++) - '0';
    else
      name++;
    if (name[0]!='-') continue;

    /* protect against superlong font names */
    if (!pixsize && strlen(tmp_fonts[i])>120) continue;

    face += fam;

    nsizes = xdpy->available[face].nsizes;
    if (x_lookup(pixsize, xdpy->available[face].sizes, nsizes)) continue;
    if (nsizes%12==0) {
      int *sizes = xdpy->available[face].sizes;
      char **names = xdpy->available[face].names;
      xdpy->available[face].sizes = p_realloc(sizes, sizeof(int)*(nsizes+12));
      if (!xdpy->available[face].sizes) {
        xdpy->available[face].sizes = sizes;
        return;
      }
      xdpy->available[face].names = p_realloc(names,sizeof(char*)*(nsizes+13));
      if (!xdpy->available[face].names) {
        xdpy->available[face].names = names;
        return;
      }
    }
    j = x_insert(pixsize, xdpy->available[face].sizes,
                 xdpy->available[face].names, nsizes);
    xdpy->available[face].nsizes++;
    if (pixsize) {
      xdpy->available[face].names[j] = p_strcpy(tmp_fonts[i]);
    } else {
      /* scalable font needs wildcard name */
      char nm[128], *pnm = nm;
      int n = 7;
      name = tmp_fonts[i];
      while (n--) while ((*(pnm++)= *(name++))!='-');
      /* skip over pixels, points fields */
      *(pnm++)= '*';   *(pnm++)= '-';  *(pnm++)= '*';   *(pnm++)= '-';
      for (n=2 ; n-- ;) while (name[0] && *(name++)!='-');
      /* copy hres, vres, spacing fields */
      for (n=3 ; n-- ;) while (name[0] && (*(pnm++)= *(name++))!='-');
      /* skip over average width field */
      *(pnm++)= '*';   *(pnm++)= '-';
      while (name[0] && *(name++)!='-');
      /* copy remainder (character set fields) */
      while ((*(pnm++)= *(name++)));
      xdpy->available[face].names[j] = p_strcpy(nm);
    }
  }

  tmp_free();
}
예제 #27
0
파일: fortrn.c 프로젝트: dhmunro/yorick
static void *ListAppend(void *ptr)
{
  if (!(nlist&0x1f)) memlist= p_realloc(memlist, (nlist+32)*sizeof(void *));
  return memlist[nlist++]= ptr;
}
예제 #28
0
파일: parse.c 프로젝트: MattWherry/yorick
void YpFunc(int isMain, int eol)
{
  long codeSize, i, pc;
  Function *parsedFunc= 0;
  DataBlock *oldDB;
  Symbol *cTable;

  if (!eol || ypErrors) {
    if (!eol) YpError("garbage after func or struct definition");
    ClearParser((void *)0);
    return;
  }

  if (isMain && nextPC==0) return;

  /* NOTE- if stackDepth!=0 here, there is a bug in the parser...
           (unless a previous error involving matrix multiplication?) */
  if (previousOp!=&Return) YpReturn(NONE);

  if (isMain) nLocal= 0;

  /* end of function marked by code.Action==&Return followed by
     code.Action==0, followed by code.index==codeSize to enable
     error recovery to find beginning of function */
  if (CheckCodeSpace(2)) {
    ClearParser((void *)0);
    return;
  }
  vmCode[nextPC++].Action= previousOp= 0;
  vmCode[nextPC].index= codeSize= 1+nPos+(hasPosList&1)+nKey+nLocal+ nextPC;
  nextPC++;

  /* fill in all forward-referenced goto targets */
  if (nTarget) {
    YpError("missing goto label at end of func");
    ClearParser((void *)0);
    return;
  }
  for (i=0 ; i<nGotoTargets ; i++) {
    pc= gotoTargets[i];
    SetBranchTarget(pc, (literalTypes[vmCode[pc].index]>>3));
  }
  nGotoTargets= 0;

  /* shorten constant table to its final size */
  if (nConstants) {
    constantTable= p_realloc(constantTable, nConstants*sizeof(Symbol));
    maxConstants= nConstants;
  }

  /* fill in all references to constants */
  if (!reparsing) cTable= constantTable;
  else cTable= reparsing->constantTable;
  for (i=0 ; i<nConstantRefs ; i++) {
    pc= constantRefs[i];
    vmCode[pc].constant= cTable+vmCode[pc].index;
  }
  nConstantRefs= 0;

  /* locate or create all referenced variable names in globTab --
     reuse literalTypes array to hold globTab index */
  if (CheckCodeSpace(1+nPos+(hasPosList&1)+nKey+nLocal)) {
    ClearParser((void *)0);
    return;
  }
  if (isMain) {
    for (i=0 ; i<literalTable.nItems ; i++)
      if (literalTypes[i]&(L_REFERENCE|L_LOCAL))
        literalTypes[i]= Globalize(literalTable.names[i], 0L);
    vmCode[nextPC++].index=
      Globalize(isMain==1? "*main*" : literalTable.names[0], 0L);
  } else {
    for (i=0 ; i<literalTable.nItems ; i++) {
      /* Note that function name is first, then positional parameters,
         then optional *va* parameter, then keyword parameters.  */
      if (literalTypes[i]&(L_REFERENCE|L_LOCAL)) {
        if ((literalTypes[i]&(L_REFERENCE|L_LOCAL)) == (L_REFERENCE|L_LOCAL))
          vmCode[nextPC++].index=
            literalTypes[i]= Globalize(literalTable.names[i], 0L);
        else
          literalTypes[i]= Globalize(literalTable.names[i], 0L);
      }
    }
  }

  /* fill in all references to variables */
  for (i=0 ; i<nVariableRefs ; i++) {
    pc= variableRefs[i];
    vmCode[pc].index= literalTypes[vmCode[pc].index];
  }
  nVariableRefs= 0;

  /* done with literal table */
  HashClear(&literalTable);  /* sets literalTable.maxItems==0 */
  p_free(literalTypes);
  literalTypes= 0;

  if (!reparsing)
    parsedFunc= NewFunction(constantTable, nConstants, nPos, nKey, nLocal,
                            hasPosList, maxStackDepth, vmCode, codeSize);
  else
    ypReMatch=
      YpReCompare(reparsing, constantTable, nConstants, nPos, nKey, nLocal,
                  hasPosList, maxStackDepth, vmCode, codeSize);
  nConstants= maxConstants= 0;
  constantTable= 0;

  if (reparsing) return;

  i= parsedFunc->code[0].index;
  oldDB= globTab[i].value.db;
  globTab[i].value.db= (DataBlock *)parsedFunc;
  if (globTab[i].ops==&dataBlockSym) { Unref(oldDB); }
  else globTab[i].ops= &dataBlockSym;

  /* A main function must be pushed onto the stack here;
     anything else (func or struct definitions) is recorded in
     the sourceList for the current include file (see also YpExtern).  */
  if (isMain) PushTask(parsedFunc);
  else parsedFunc->isrc = RecordSource(i);
}
예제 #29
0
파일: spawn.c 프로젝트: MattWherry/yorick
/* do interpreted callback to process message from process */
static void
spawn_callback(void *vproc, int err)
{
  spawn_proc *proc = vproc;
  char *msg = 0;
  Array *msga;
  Instruction code[12];
  Symbol *ctable;
  long callback = -1;
  if (err != 2) {
    long nbytes = 0;
    if (proc && proc->proc) callback = err? proc->callerr : proc->callout;
    if (callback<0) {
      /* probably a bug, but unclear that calling YError
       * would prevent the possible fault loop
       */
      return;
    }

    /* read the message from process
     * - this just reads all available bytes, up to 2048
     */
    msg = p_malloc(2048);
    nbytes = p_recv(proc->proc, msg, 2048);
    if (nbytes <= 0) {
      p_free(msg);
      /* can get this when an unrelated process finishes, just ignore */
      /* YError("spawn process read error in callback"); */
      /* also could get this if the fd gave POLLERR, possibly should
       * find some way to figure out what's going on
       */
      return;
    }
    msg = p_realloc(msg, nbytes+1);
    msg[nbytes] ='\0';
  } else {
    if (!proc || proc->callout<0) return;
    callback = proc->callout;
    proc->callout = -1;
    p_spawf(proc->proc, 1);
    proc->proc = 0;
  }

  if (callback < 0) return;

  /* task constant table contains only message string */
  msga = NewArray(&stringStruct, (Dimension *)0);
  msga->value.q[0] = msg;
  ctable = p_malloc(sizeof(Symbol));
  ctable->ops = &dataBlockSym;
  ctable->value.db = (DataBlock *)msga;

  /* fill in function code */
  code[0].Action = &PushVariable;
  code[1].index = callback;
  code[2].Action = &PushString;
  code[3].constant = ctable;
  code[4].Action = &Eval;
  code[5].count = 1;
  code[6].Action = &DropTop;
  code[7].Action = &PushNil;
  code[8].Action = &Return;
  code[9].Action = 0;
  code[10].index = 11;
  /* NewFunction moves this to beginning */
  code[11].index = Globalize("*callback*", 0L);
  PushTask(NewFunction(ctable, 1, 0, 0, 0, 0, 2, code, 11));
}
예제 #30
0
파일: imem.c 프로젝트: aosm/dovecot
void *i_realloc(void *mem, size_t old_size, size_t new_size)
{
        return p_realloc(default_pool, mem, old_size, new_size);
}