static void qlist_add(t_qlist *x, t_symbol *s, int ac, t_atom *av)
{
    t_atom a;
    SETSEMI(&a);
    binbuf_add(x->x_binbuf, ac, av);
    binbuf_add(x->x_binbuf, 1, &a);
}
示例#2
0
文件: m_binbuf.c 项目: 4nykey/rockbox
void binbuf_addv(t_binbuf *x, char *fmt, ...)
{
    va_list ap;
    t_atom arg[MAXADDMESSV], *at =arg;
    int nargs = 0;
    char *fp = fmt;

    va_start(ap, fmt);
    while (1)
    {
    	if (nargs >= MAXADDMESSV)
    	{
    	    error("binbuf_addmessv: only %d allowed", MAXADDMESSV);
    	    break;
    	}
    	switch(*fp++)
    	{
    	case 'i': SETFLOAT(at, va_arg(ap, t_int)); break;
    	case 'f': SETFLOAT(at, va_arg(ap, double)); break;
    	case 's': SETSYMBOL(at, va_arg(ap, t_symbol *)); break;
    	case ';': SETSEMI(at); break;
    	case ',': SETCOMMA(at); break;
    	default: goto done;
    	}
    	at++;
    	nargs++;
    }
done:
    va_end(ap);
    binbuf_add(x, nargs, arg);
}
示例#3
0
文件: x_misc.c 项目: danomatika/ofxPd
static void fudiformat_any(t_fudiformat *x, t_symbol*s, int argc, t_atom*argv) {
  char *buf;
  int length;
  int i;
  t_atom at;
  t_binbuf*bbuf = binbuf_new();
  SETSYMBOL(&at, s);
  binbuf_add(bbuf, 1, &at);

  binbuf_add(bbuf, argc, argv);

  if(!x->x_udp) {
    SETSEMI(&at);
    binbuf_add(bbuf, 1, &at);
  }
  binbuf_gettext(bbuf, &buf, &length);
  binbuf_free(bbuf);

  if((size_t)length>x->x_numatoms) {
    freebytes(x->x_atoms, sizeof(*x->x_atoms) * x->x_numatoms);
    x->x_numatoms = length;
    x->x_atoms = getbytes(sizeof(*x->x_atoms) * x->x_numatoms);
  }

  for(i=0; i<length; i++) {
    SETFLOAT(x->x_atoms+i, buf[i]);
  }
  freebytes(buf, length);
  outlet_list(x->x_msgout, 0, length, x->x_atoms);
}
示例#4
0
static int imaction_P2_scope(t_port *x, char *name)
{
    if (x->x_inatoms > 6)
    {
	t_atom *out = x->x_outmess;
	int i, xpix, ypix;
	SETSYMBOL(out, gensym("#X")); out++;
	SETSYMBOL(out, gensym("obj")); out++;
	port_setxy(x, 3, out);
	xpix = (int)out++->a_w.w_float;
	ypix = (int)out->a_w.w_float;
	binbuf_add(x->x_outbb, 4, x->x_outmess);
	import_addclassname(x, name, &x->x_inmess[2]);
	out = x->x_outmess;
	port_setxy(x, 5, out);
	out++->a_w.w_float -= xpix;
	out++->a_w.w_float -= ypix;
	out = import_copyatoms(out, x->x_inmess + 7, x->x_inatoms - 7);
	SETSEMI(out);
	binbuf_add(x->x_outbb, x->x_inatoms - 4, x->x_outmess);
	x->x_nobj++;
	return (PORT_NEXT);
    }
    else return (PORT_CORRUPT);
}
示例#5
0
文件: mfbb.c 项目: pure-data/xeq
static void mfbb_setevehook(t_mfbb_iterator *it, t_mifi_event *evp, int *incr)
{
    if (it->i_i < it->i_b->b_n)
    {
	t_atom *ap = it->i_a;
	SETFLOAT(ap, evp->e_delay), ap++;
	ap++;  /* target is set in a separate mfbb_settarhook() call */
	SETFLOAT(ap, evp->e_status), ap++;
	SETFLOAT(ap, evp->e_data[0]), ap++;
	if (MIFI_ONE_DATABYTE(evp->e_status))
	{
	    SETFLOAT(ap, evp->e_channel + 1), ap++;
	    SETFLOAT(ap, 0), ap++;
	}
	else {
	    SETFLOAT(ap, evp->e_data[1]), ap++;
	    SETFLOAT(ap, evp->e_channel + 1), ap++;
	}
	SETSEMI(ap);
	if (incr)
	{
	    it->i_a += MFBB_PARTICLE_SIZE;
	    it->i_i += MFBB_PARTICLE_SIZE;
	    *incr = 1;
	}
    }
    else if (incr) *incr = 0;
}
示例#6
0
static int import_emaddv(t_port *x, t_symbol *state, char *fmt, ...)
{
    va_list ap;
    t_atom arg[64], *at = arg;
    int nargs = 0;
    char *fp = fmt;
    va_start(ap, fmt);
    SETSYMBOL(at, gensym("#C"));
    at++; nargs++;
    if (import_emcheck(x, state)) while (1)
    {
	switch(*fp++)
	{
	case 'i': SETFLOAT(at, va_arg(ap, t_int)); break;
	case 'f': SETFLOAT(at, va_arg(ap, double)); break;
	case 's': SETSYMBOL(at, va_arg(ap, t_symbol *)); break;
	case ';': SETSEMI(at); break;
	case 0: goto done;
	default: nargs = 0; goto done;
	}
	at++; nargs++;
    }
done:
    va_end(ap);
    if (nargs > 1)
    {
	binbuf_add(x->x_embb, nargs, arg);
	return (1);
    }
    else return (0);
}
示例#7
0
文件: sync.c 项目: jondf/pd
static void *sync_new(t_symbol *s, int ac, t_atom *at)
{
    int n = 0;
    int i;
    t_sync *x = (t_sync *)pd_new(sync_class);
    t_proxy *inlet[SYNC_MAX_SIZE];

    /* void state - we fill with SEMI and treat this as 'void' */
    for(i=0; i<SYNC_MAX_SIZE; i++)
        SETSEMI(x->x_a + i);

    if(ac == 1)
    {
        if(at->a_type == A_FLOAT)
        {
            n = atom_getfloat(at);

            if(n < 2)
                n = 2;
            else if(n > SYNC_MAX_SIZE)
                n = SYNC_MAX_SIZE;
        }
        else
        {
            post("sync: wrong argument");
            return (0);
        }
    }
    else if(ac > 1)
    {
        if(ac > SYNC_MAX_SIZE)
            ac = SYNC_MAX_SIZE;

        n = ac;

        for(i=0; i<n; i++)
            x->x_a[i] = at[i];
    }

    x->x_n = n;
    x->x_trigger = x->x_require = x->x_reset = x->x_wait = (1 << n) - 1;

    x->x_outlet[0] = outlet_new(&x->x_ob, gensym("list"));

    for(i=1; i<n; i++)
    {
        inlet[i] = (t_proxy *)pd_new(proxy_class);	/* create the proxy inlet */
        inlet[i]->x = x;		/* make t_sync *x visible to the proxy inlets */
        inlet[i]->index = i;	/* remember it's number */
        /* it belongs to the object t_sync but the destination is t_proxy */
        inlet_new(&x->x_ob, &inlet[i]->obj.ob_pd, 0,0);

        x->x_outlet[i] = outlet_new(&x->x_ob, gensym("list"));
    }

    return (void *)x;
}
示例#8
0
static void netsend_send(t_netsend *x, t_symbol *s, int argc, t_atom *argv)
{
#ifdef ROCKBOX
    (void) x;
    (void) s;
    (void) argc;
    (void) argv;
#else /* ROCKBOX */
    if (x->x_fd >= 0)
    {
	t_binbuf *b = binbuf_new();
	char *buf, *bp;
	int length, sent;
	t_atom at;
	binbuf_add(b, argc, argv);
	SETSEMI(&at);
	binbuf_add(b, 1, &at);
	binbuf_gettext(b, &buf, &length);
	for (bp = buf, sent = 0; sent < length;)
	{
	    static double lastwarntime;
	    static double pleasewarn;
	    double timebefore = sys_getrealtime();
    	    int res = send(x->x_fd, buf, length-sent, 0);
    	    double timeafter = sys_getrealtime();
    	    int late = (timeafter - timebefore > 0.005);
    	    if (late || pleasewarn)
    	    {
    	    	if (timeafter > lastwarntime + 2)
    	    	{
    	    	     post("netsend blocked %d msec",
    	    	     	(int)(1000 * ((timeafter - timebefore) + pleasewarn)));
    	    	     pleasewarn = 0;
    	    	     lastwarntime = timeafter;
    	    	}
    	    	else if (late) pleasewarn += timeafter - timebefore;
    	    }
    	    if (res <= 0)
    	    {
    		sys_sockerror("netsend");
    		netsend_disconnect(x);
    		break;
    	    }
    	    else
    	    {
    		sent += res;
    		bp += res;
    	    }
	}
	t_freebytes(buf, length);
	binbuf_free(b);
    }
    else error("netsend: not connected");
#endif /* ROCKBOX */
}
示例#9
0
static void netdist_send(t_netdist *x, t_symbol *s, int argc, t_atom *argv)
{
	int i = 0;

	for(i = 0; i <= x->x_numconnect; i++)
	{
		if (x->x_fd[i] >= 0)
		{
			t_binbuf *b = binbuf_new();
			char *buf, *bp;
			int length, sent;
			t_atom at;
			binbuf_add(b, argc, argv);
			SETSEMI(&at);
			binbuf_add(b, 1, &at);
			binbuf_gettext(b, &buf, &length);
			for (bp = buf, sent = 0; sent < length;)
			{
				static double lastwarntime;
				static double pleasewarn;
				double timebefore = clock_getlogicaltime();
    				int res = send(x->x_fd[i], buf, length-sent, 0);
    				double timeafter = clock_getlogicaltime();
    				int late = (timeafter - timebefore > 0.005);
    				if (late || pleasewarn)
    				{
    	    			if (timeafter > lastwarntime + 2)
    	    			{
    	    				 post("netdist blocked %d msec",
    	    	     			(int)(1000 * ((timeafter - timebefore) + pleasewarn)));
    	    				 pleasewarn = 0;
    	    				 lastwarntime = timeafter;
    	    			}
    	    			else if (late) pleasewarn += timeafter - timebefore;
    				}
    				if (res <= 0)
    				{
    					sys_sockerror("netdist");
    					netdist_disconnect(x, gensym(x->x_hostname[i]), x->x_port[i]);
    					break;
    				}
    				else
    				{
    					sent += res;
    					bp += res;
    				}
			}
			t_freebytes(buf, length);
			binbuf_free(b);
		}
	}
	if(x->x_numconnect == -1) error("netdist: not connected");
}
示例#10
0
static int import_emcopy(t_port *x, t_symbol *state)
{
    if (import_emcheck(x, state))
    {
	t_atom *out = x->x_outmess;
	SETSYMBOL(out, gensym("#C")); out++;
	out = import_copyatoms(out, x->x_inmess + 1, x->x_inatoms - 1);
	SETSEMI(out);
	binbuf_add(x->x_embb, x->x_inatoms + 1, x->x_outmess);
	return (1);
    }
    else return (0);
}
示例#11
0
文件: mtr.c 项目: EQ4/PdPulpito
static void mtrack_doadd(t_mtrack *tp, int ac, t_atom *av)
{
    if (tp->tr_prevtime > 0.)
    {
	t_binbuf *bb = tp->tr_binbuf;
	t_atom at;
    	float elapsed = clock_gettimesince(tp->tr_prevtime);
	SETFLOAT(&at, elapsed);
	binbuf_add(bb, 1, &at);
	binbuf_add(bb, ac, av);
	SETSEMI(&at);
	binbuf_add(bb, 1, &at);
	tp->tr_prevtime = clock_getlogicaltime();
    }
}
示例#12
0
文件: xeq.c 项目: pure-data/xeq
static void xeq_addline(t_xeq *x, t_symbol *s, int ac, t_atom *av)
{
    int i;
    for (i = 0; i < ac; i++)
    {
    	if (av[i].a_type == A_SYMBOL)
	{
	    if (!strcmp(av[i].a_w.w_symbol->s_name, "_semi_"))
	    	SETSEMI(&av[i]);
	    else if (!strcmp(av[i].a_w.w_symbol->s_name, "_comma_"))
	    	SETCOMMA(&av[i]);
    	}
    }
    binbuf_add(x->x_binbuf, ac, av);
}
示例#13
0
文件: m_binbuf.c 项目: 4nykey/rockbox
void binbuf_restore(t_binbuf *x, int argc, t_atom *argv)
{
    int newsize = x->b_n + argc, i;
    t_atom *ap;
    if((ap = t_resizebytes(x->b_vec, x->b_n * sizeof(*x->b_vec),
	newsize * sizeof(*x->b_vec))))
	    x->b_vec = ap;
    else
    {
    	error("binbuf_addmessage: out of space");
    	return;
    }

    for (ap = x->b_vec + x->b_n, i = argc; i--; ap++)
    {
    	if (argv->a_type == A_SYMBOL)
    	{
	    char *str = argv->a_w.w_symbol->s_name;
    	    if (!strcmp(str, ";")) SETSEMI(ap);
    	    else if (!strcmp(str, ",")) SETCOMMA(ap);
    	    else if (str[0] == '$' && str[1] >= '0' && str[1] <= '9')
    	    {
	    	int dollsym = 0;
	    	char *str2;
		for (str2 = str + 2; *str2; str2++)
		    if (*str2 < '0' || *str2 > '9')
		    	dollsym = 1;
    	    	if (dollsym)
		    SETDOLLSYM(ap, gensym(str + 1));
		else
		{
		    int dollar = 0;
#ifdef ROCKBOX
                    dollar = atoi(argv->a_w.w_symbol->s_name + 1);
#else
    	    	    sscanf(argv->a_w.w_symbol->s_name + 1, "%d", &dollar);
#endif
    	    	    SETDOLLAR(ap, dollar);
    	    	}
	    }
    	    else *ap = *argv;
    	    argv++;
    	}
    	else *ap = *(argv++);
    }
    x->b_n = newsize;
}
示例#14
0
文件: zmq.c 项目: sansculotte/pd-zmq
/**
 * send a message
 */
static void _zmq_send(t_zmq *x, t_symbol *s, int argc, t_atom* argv) {

   if ( ! x->zmq_socket) {
      post("[!] create and connect socket before sending");
      return;
   }

   if ( ! _can_send(x)) {
       return;
   }

   int r;
   int length;
   char *buf;
   t_binbuf *b = 0;

   t_atom at;
   b = binbuf_new();
   binbuf_add(b, argc, argv);
   SETSEMI(&at);
   binbuf_add(b, 1, &at);
   binbuf_gettext(b, &buf, &length);
   //post("msg length %i", length);

   //s_send(x->zmq_socket, buf);
   r=zmq_send (x->zmq_socket, buf, strlen(buf), 0);

   t_freebytes(buf, length);
   binbuf_free(b);

   if(r == -1) {
      _zmq_error(zmq_errno());
      return;
   }

   // if REQ socket wait for reply
   if(x->socket_type==ZMQ_REQ) {
      _zmq_receive(x);
   }

   return;
}
示例#15
0
static int import_objarg(t_port *x, char *name)
{
    int ndx = (x->x_inmess[1].a_w.w_symbol == gensym("user") ? 3 : 2);
    if (x->x_inatoms > 6
	|| (ndx == 3 && x->x_inatoms > 4))
    {
	t_atom *out = x->x_outmess;
	SETSYMBOL(out, gensym("#X")); out++;
	SETSYMBOL(out, gensym("obj")); out++;
	port_setxy(x, ndx, out);
	binbuf_add(x->x_outbb, 4, x->x_outmess);
	import_addclassname(x, name, &x->x_inmess[ndx == 2 ? 6 : 2]);
	out = import_copyatoms(x->x_outmess, x->x_inmess + 7, x->x_inatoms - 7);
	SETSEMI(out);
	binbuf_add(x->x_outbb, x->x_inatoms - 6, x->x_outmess);
	x->x_nobj++;
	return (PORT_NEXT);
    }
    else return (PORT_CORRUPT);
}
示例#16
0
static void hammereditor_addline(t_hammerfile *f,
				 t_symbol *s, int ac, t_atom *av)
{
    if (f->f_editorfn)
    {
	int i;
	t_atom *ap;
	for (i = 0, ap = av; i < ac; i++, ap++)
	{
	    if (ap->a_type == A_SYMBOL)
	    {
		/* LATER rethink semi/comma mapping */
		if (!strcmp(ap->a_w.w_symbol->s_name, "_semi_"))
		    SETSEMI(ap);
		else if (!strcmp(ap->a_w.w_symbol->s_name, "_comma_"))
		    SETCOMMA(ap);
	    }
	}
	binbuf_add(f->f_binbuf, ac, av);
    }
}
示例#17
0
文件: binarymsg.c 项目: jyg/pure-data
static int pd_tilde_getatom(t_atom *ap, FILE *fd)
{
    char buf[MAXPDSTRING];
    while (1)
    {
        int type = getc(fd), fill;
        float f;
        switch (type)
        {
        case EOF:
            return (0);
        case A_SEMI:
            SETSEMI(ap);
            return (1);
        case A_FLOAT:
            if (fread(&f, sizeof(f), 1, fd) >= 1)
            {
                SETFLOAT(ap, f);
                return (1);
            }
            else return (0);
        case A_SYMBOL:
            for (fill = 0; fill < MAXPDSTRING; fill++)
            {
                int c = getc(fd);
                if (c == EOF)
                    return (0);
                else buf[fill] = c;
                if (!c)
                {
                    SETSYMBOL(ap, gensym(buf));
                    return (1);
                }
            }
            return (0);
        }
    }
}
示例#18
0
文件: netserver.c 项目: IcaroL2ORK/pd
/* send message to client using client number 
   note that the client numbers might change in case a client disconnects! */
static void netserver_client_send(t_netserver *x, t_symbol *s, int argc, t_atom *argv)
{
   int sockfd, client;
   if(x->x_nconnections < 0)
   {
	  if (x->x_log_pri >= LOG_WARNING)
		 post("netserver: no clients connected");
	  return;
   }
   if(argc < 2)
   {
	  if (x->x_log_pri >= LOG_WARNING)
		 post("netserver: nothing to send");
	  return;
   }
   /* get number of client (first element in list) */
   if(argv[0].a_type == A_FLOAT)
	  client = atom_getfloatarg(0, argc, argv);
   else
   {
	  if (x->x_log_pri >= LOG_WARNING)
		 post("netserver: no client specified");
	  return;
   }
   sockfd = x->x_fd[client - 1];	/* get socket number for that client */

   /* process & send data */
   if(sockfd > 0)
   {
	  t_binbuf *b = binbuf_new();
	  char *buf, *bp;
	  int length, sent;
	  t_atom at;
	  binbuf_add(b, argc - 1, argv + 1);	/* skip first element */
	  SETSEMI(&at);
	  binbuf_add(b, 1, &at);
	  binbuf_gettext(b, &buf, &length);

	  if (x->x_log_pri >= LOG_DEBUG)
	  {
		 post("netserver: sending data to client %d on socket %d", client, sockfd);
		 post("netserver: >> sending \"%s\"", buf);
	  }

	  for (bp = buf, sent = 0; sent < length;)
	  {
		 static double lastwarntime;
		 static double pleasewarn;
		 double timebefore = clock_getlogicaltime();
		 int res = send(sockfd, buf, length-sent, 0);
		 double timeafter = clock_getlogicaltime();
		 int late = (timeafter - timebefore > 0.005);
		 if (late || pleasewarn)
		 {
			if (timeafter > lastwarntime + 2)
			{
			   if (x->x_log_pri >= LOG_WARNING)
				  post("netserver blocked %d msec",
					   (int)(1000 * ((timeafter - timebefore) + pleasewarn)));
			   pleasewarn = 0;
			   lastwarntime = timeafter;
			}
			else if (late) pleasewarn += timeafter - timebefore;
		 }
		 if (res <= 0)
		 {
			sys_sockerror("netserver");
			if (x->x_log_pri >= LOG_ERR)
			   post("netserver: could not send data to cient");
			break;
		 }
		 else
		 {
			sent += res;
			bp += res;
		 }
	  }
	  t_freebytes(buf, length);
	  binbuf_free(b);
   }
   else if (x->x_log_pri >= LOG_CRIT)
	  post("netserver: not a valid socket number (%d)", sockfd);
}
示例#19
0
文件: x_net.c 项目: pedebt/pd-vanilla
static int netsend_dosend(t_netsend *x, int sockfd,
    t_symbol *s, int argc, t_atom *argv)
{
    char *buf, *bp;
    int length, sent, fail = 0;
    t_binbuf *b = 0;
    if (x->x_bin)
    {
        int i;
        buf = alloca(argc);
        for (i = 0; i < argc; i++)
            ((unsigned char *)buf)[i] = atom_getfloatarg(i, argc, argv);
        length = argc;
    }
    else
    {
        t_atom at;
        b = binbuf_new();
        binbuf_add(b, argc, argv);
        SETSEMI(&at);
        binbuf_add(b, 1, &at);
        binbuf_gettext(b, &buf, &length);
    }
    for (bp = buf, sent = 0; sent < length;)
    {
        static double lastwarntime;
        static double pleasewarn;
        double timebefore = sys_getrealtime();
        int res = send(sockfd, bp, length-sent, 0);
        double timeafter = sys_getrealtime();
        int late = (timeafter - timebefore > 0.005);
        if (late || pleasewarn)
        {
            if (timeafter > lastwarntime + 2)
            {
                 post("netsend/netreceive blocked %d msec",
                    (int)(1000 * ((timeafter - timebefore) +
                        pleasewarn)));
                 pleasewarn = 0;
                 lastwarntime = timeafter;
            }
            else if (late) pleasewarn += timeafter - timebefore;
        }
        if (res <= 0)
        {
            sys_sockerror("netsend");
            fail = 1;
            break;
        }
        else
        {
            sent += res;
            bp += res;
        }
    }
    done:
    if (!x->x_bin)
    {
        t_freebytes(buf, length);
        binbuf_free(b);
    }
    return (fail);
}
示例#20
0
文件: m_binbuf.c 项目: 4nykey/rockbox
    /* convert text to a binbuf */
void binbuf_text(t_binbuf *x, char *text, size_t size)
{
    char buf[MAXPDSTRING+1], *bufp, *ebuf = buf+MAXPDSTRING;
    const char *textp = text, *etext = text+size;
    t_atom *ap;
    int nalloc = 16, natom = 0;
    t_freebytes(x->b_vec, x->b_n * sizeof(*x->b_vec));
    x->b_vec = t_getbytes(nalloc * sizeof(*x->b_vec));
    ap = x->b_vec;
    x->b_n = 0;
    while (1)
    {
#ifndef ROCKBOX
	int type;
#endif
	    /* skip leading space */
	while ((textp != etext) && (*textp == ' ' || *textp == '\n'
	    || *textp == '\r' || *textp == '\t')) textp++;
	if (textp == etext) break;
	if (*textp == ';') SETSEMI(ap), textp++;
	else if (*textp == ',') SETCOMMA(ap), textp++;
	else
	{
	    	/* it's an atom other than a comma or semi */
	    char c;
	    int floatstate = 0, slash = 0, /* lastslash = 0, */
	    	firstslash = (*textp == '\\');
	    bufp = buf;
	    do
	    {
		c = *bufp = *textp++;
		/* lastslash = slash; */
		slash = (c == '\\');

		if (floatstate >= 0)
		{
		    int digit = (c >= '0' && c <= '9'),
			dot = (c == '.'), minus = (c == '-'),
			plusminus = (minus || (c == '+')),
			expon = (c == 'e' || c == 'E');
		    if (floatstate == 0)    /* beginning */
		    {
			if (minus) floatstate = 1;
			else if (digit) floatstate = 2;
			else if (dot) floatstate = 3;
			else floatstate = -1;
		    }
		    else if (floatstate == 1)	/* got minus */
		    {
			if (digit) floatstate = 2;
			else if (dot) floatstate = 3;
			else floatstate = -1;
		    }
		    else if (floatstate == 2)	/* got digits */
		    {
			if (dot) floatstate = 4;
			else if (expon) floatstate = 6;
			else if (!digit) floatstate = -1;
		    }
		    else if (floatstate == 3)	/* got '.' without digits */
		    {
			if (digit) floatstate = 5;
			else floatstate = -1;
		    }
		    else if (floatstate == 4)	/* got '.' after digits */
		    {
			if (digit) floatstate = 5;
			else if (expon) floatstate = 6;
			else floatstate = -1;
		    }
		    else if (floatstate == 5)	/* got digits after . */
		    {
			if (expon) floatstate = 6;
			else if (!digit) floatstate = -1;
		    }
		    else if (floatstate == 6)	/* got 'e' */
		    {
			if (plusminus) floatstate = 7;
			else if (digit) floatstate = 8;
			else floatstate = -1;
		    }
		    else if (floatstate == 7)	/* got plus or minus */
		    {
			if (digit) floatstate = 8;
			else floatstate = -1;
		    }
		    else if (floatstate == 8)	/* got digits */
		    {
			if (!digit) floatstate = -1;
		    }
		}
		if (!slash) bufp++;
	    }
	    while (textp != etext && bufp != ebuf && 
		(slash || (*textp != ' ' && *textp != '\n' && *textp != '\r'
		    && *textp != '\t' &&*textp != ',' && *textp != ';')));
	    *bufp = 0;
#if 0
	    post("buf %s", buf);
#endif

	    if (*buf == '$' && buf[1] >= '0' && buf[1] <= '9' && !firstslash)
	    {
		for (bufp = buf+2; *bufp; bufp++)
		    if (*bufp < '0' || *bufp > '9')
		{
		    SETDOLLSYM(ap, gensym(buf+1));
		    goto didit;
		}
		SETDOLLAR(ap, atoi(buf+1));
	    didit: ;
	    }
	    else
	    {
		if (floatstate == 2 || floatstate == 4 || floatstate == 5 ||
		    floatstate == 8)
		    	SETFLOAT(ap, atof(buf));
		else SETSYMBOL(ap, gensym(buf));
	    }
	}
	ap++;
	natom++;
	if (natom == nalloc)
	{
	    x->b_vec = t_resizebytes(x->b_vec, nalloc * sizeof(*x->b_vec),
		nalloc * (2*sizeof(*x->b_vec)));
	    nalloc = nalloc * 2;
	    ap = x->b_vec + natom;
	}
	if (textp == etext) break;
    }
    /* reallocate the vector to exactly the right size */
    x->b_vec = t_resizebytes(x->b_vec, nalloc * sizeof(*x->b_vec),
	natom * sizeof(*x->b_vec));
    x->b_n = natom;
}
示例#21
0
文件: m_binbuf.c 项目: 4nykey/rockbox
void binbuf_addsemi(t_binbuf *x)
{
    t_atom a;
    SETSEMI(&a);
    binbuf_add(x, 1, &a);
}