Ejemplo n.º 1
0
t_p		*ft_posxy(t_p *f, char ***t, int l, int h)
{
	int i;

	i = 0;
	f = zoom(f);
	while (t[h])
	{
		while (t[h][l])
		{
			if (!(f->m[h][l] = (int *)malloc(sizeof(int) * 1)))
				exit(EXIT_FAILURE);
			if (ft_atoi(t[h][l]) > 100)
				ft_big();
			isdig(t[h][l]);
			f->m[h][l][0] = ft_atoi(t[h][l]);
			f->pos[h][l] = (int *)malloc(sizeof(int) * 1);
			f->posy[h][l] = (int *)malloc(sizeof(int) * 1);
			f->pos[h][l][0] = l * f->zoom + f->h / 25 + h * f->zoom;
			f->posy[h][l][0] = h * f->zoomy + f->l / 4 - f->m[h][l][0] * 5;
			l++;
			i++;
		}
		l = 0;
		h++;
	}
	return (f);
}
Ejemplo n.º 2
0
PHPAPI char *
php_canonicalize_version(const char *version)
{
    int len = strlen(version);
    char *buf = safe_emalloc(len, 2, 1), *q, lp, lq;
    const char *p;

    if (len == 0) {
        *buf = '\0';
        return buf;
    }

    p = version;
    q = buf;
    *q++ = lp = *p++;

    while (*p) {
/*  s/[-_+]/./g;
 *  s/([^\d\.])([^\D\.])/$1.$2/g;
 *  s/([^\D\.])([^\d\.])/$1.$2/g;
 */
#define isdig(x) (isdigit(x)&&(x)!='.')
#define isndig(x) (!isdigit(x)&&(x)!='.')
#define isspecialver(x) ((x)=='-'||(x)=='_'||(x)=='+')

		lq = *(q - 1);
		if (isspecialver(*p)) {
			if (lq != '.') {
				*q++ = '.';
			}
		} else if ((isndig(lp) && isdig(*p)) || (isdig(lp) && isndig(*p))) {
			if (lq != '.') {
				*q++ = '.';
			}
			*q++ = *p;
		} else if (!isalnum(*p)) {
			if (lq != '.') {
				*q++ = '.';
			}
		} else {
			*q++ = *p;
		}
		lp = *p++;
    }
    *q++ = '\0';
    return buf;
}
Ejemplo n.º 3
0
Archivo: xkey.c Proyecto: 8l/ted
char *varname(char *s,char *fn)
{
  char *t;
  int len;
  t=s=skip_spc(s);
  if (!isvarchr(*s)) return 0;
  while (isvarchr(*t)||isdig(*t)) t++;
  mkstr(s,t,fn);
  return t;
}
Ejemplo n.º 4
0
Archivo: xkey.c Proyecto: 8l/ted
u_char takearg(char *tedname, int lno, char *ss, char **ostr, char **next)
{
  static char ooo[64];
  char *tt, *env;
  char *aa;
  ss=skip_spc(ss);
  *next=tt=ss;
  if (!*ss) return 0;
  if (isdig(*tt)) {
    while (isdig(*tt)) tt++;
    mkstr(ss,*next=tt,*ostr=ooo);
    return 1;
  }
  else
  if (*tt=='"') {
    *ostr=parse_Cstr(tedname, lno, tt,next);
    return 2;
  }
  return 0;
}
Ejemplo n.º 5
0
Archivo: q1.c Proyecto: dylan007/Coding
int main()
{
	char p[50];
	scanf("%s",p);
	int l = strlen(p);
	int i;
	stack s;
	s.top = -1;
	for(i=l-1;i>=0;i--)
	{
		if(isdig(p[i])>=0)
			push(&s,isdig(p[i]));
		else
		{
			int x,y;
			x = pop(&s);
			y = pop(&s);
			push(&s,eval(p[i],x,y));
		}
	}
	printf("%d\n",pop(&s));
	return 0;
}
Ejemplo n.º 6
0
Archivo: stdlib.c Proyecto: sng7ca/ygg
/* ... */
int atoi(const char *s, int bs)
{
	register int sg, n;

	/* skip spaces */
	for (; isspc(*s); s++)
		;
	/* get sign */
	switch (*s) {
	case '-':
		sg = -1;
		s++;
		break;
	case '+':
		s++;
	default:
		sg = 1;
	}
	/* calc val */
	for (n = 0; isdig(*s); s++)
		n = n * bs + *s - '0';
	return n * sg;
}
Ejemplo n.º 7
0
Archivo: xkey.c Proyecto: 8l/ted
char *varname_sh(char *s,char *fn)
{
  char *t;
  int len;
  char uu[256];
  char *env;

  t=s+1;
  if (!isvarchr(*t)) {
skip:
    strcpy(fn,"$");
    return s+1;
  }
  while (isvarchr(*t)||isdig(*t))
    t++;
  mkstr(s+1,t,uu);
  if (env=getenv(uu)) {
    strcpy(fn,env);
    return t;
  } else {
    if (!strcmp(uu,"TEDDIR")) {
      strcpy(fn,TEDDIR);
      return t;
    } else
    if (!strcmp(uu,"DBGSTOP")) {
#ifdef	__GNUC__
      strcpy(fn,"b");
#else
      strcpy(fn,"stop at");
#endif
      return t;
    }
    else
      goto skip;
  }
}
Ejemplo n.º 8
0
Archivo: xkey.c Proyecto: 8l/ted
isvardig(int ch)
{
return (isvarchr(ch)||isdig(ch));
}
Ejemplo n.º 9
0
int vprintf(int (*ofnc)(void*, char), void *arg, const char *fmt, va_list ap){
	/* Warning:
		there is NO error checking on 
		width, precision, or base
		so do not pass in unreasonable values
		or bad things will happen
	*/

	const char *p = fmt;
	char *s;
	long val, width = 0, prec = 0;
	u_char* addr;
	u_long  addrl;
	u_short flags;
	int base;
	int pos = 0;
	
	while(*p){
		prec = width = flags = 0;
		base = 10;
		if(*p != '%'){
			(*ofnc)(arg, *p++);
			pos++;
		}else{
rflag:
			p++;
reswitch:
			switch(*p){
			  case 's':
				/* %s - string */
				s = va_arg(ap, char*);
				val = 0;
				while(*s){
					(*ofnc)(arg, *s++);
					pos ++;
					/* no more than prec chars out */
					/* width is meaningless */
					if(prec && (++val>prec)) break;
				}
				break;
			  case 'I':
				/* %I - IP addy */
				addrl = va_arg(ap, u_long);
				addr  = (u_char*)&addrl;

				for(val=0; val<4; val++){
					if( val ){
						(*ofnc)(arg, '.');
						pos++;
					}
					pos += putnum(ofnc, arg, addr[val], 10, width, prec, flags);
				}
				break;
				
			  case '&':		/* magic zero-width character */
				break;
			  case '%':
				(*ofnc)(arg, '%');
				pos ++;
				break;
			  case 'c':
				val = va_arg(ap, int);
					/* char gets passed as int */
				(*ofnc)(arg, val);
				pos ++;
			  	break;
			  case 'd':
			  case 'D':
				flags |= B(PF_SIGNED);
				/* fall thru - weeee!!! */
			  case 'u':
			  case 'U':
				base = 10;
				goto donum;
			  case 'o':
				base = 8;
				goto donum;
			  case '=':
				/* arbitrary base */
				if(!prec) prec = 16;
				if(*++p == '*'){
					val = va_arg(ap, int);
					base = (val<0)?-val:val;
					goto donum;
				}
				val = 0;
				while( isdig(*p) ){
					val =  10*val + *p -'0';
					p++;
				}
				base = val;
				p--; /* push back */
				goto donum;
			  case 'x':
				flags |= B(PF_ALT);
				/* fallthru' */
			  case 'X':
				base = 0x10;
		    donum:			
				if( flags & B(PF_DLONG) )
					val = va_arg(ap, u_long);
				else
					val = va_arg(ap, unsigned int);
#if 1				
			 	/* sign extend */
				if(flags & B(PF_SIGNED)){
					if(!(flags & B(PF_DLONG))){
						if(!(flags & B(PF_LONG))){
							/* 8bit */
							val = (long)(char)val;
						}else{
							/* 16 bit */
							val = (long)(short)val;
						}
					}
				}
#else
				if(!(flags & B(PF_LONG)))  val &= 0xff;
#endif
				pos += putnum(ofnc, arg, val, base, width, prec, flags);
				break;
  			  case '*':
				width = va_arg(ap,int);
				goto rflag;		
			  case '.':
				/* set prec */
				if(*++p == '*'){
					prec = va_arg(ap, int);
					goto rflag;
				}
				val = 0;
				while( isdig(*p) ){
					val =  10*val + *p -'0';
					p++;
				}
				prec = val;
				goto reswitch;
			  case '1': case '2': case '3':
			  case '4': case '5': case '6': 
			  case '7': case '8': case '9':
				/* set width */
				val = 0;
				while( isdig(*p) ){
					val = 10*val + *p - '0';
					p++;
				}
				width = val;
				goto reswitch;
#ifndef TESTING
			  case 'p':
				/* spin */
				while(prec--){
					(*ofnc)(arg, spinchar[prec%4]);
					msleep(width);
					(*ofnc)(arg, '\b');
				}
#endif				
				break;
			  case '\0':
				return;
			  case 'L': 
				flags |= B(PF_DLONG);
				/* fall thru' */
			  case 'l': /* long arg */
				flags |= B(PF_LONG);
				goto rflag;
			  case '#':
				flags |= B(PF_ALT);
				goto rflag;
			  case '0': 
				flags |= B(PF_ZERO);
				goto rflag;
  			  case '+':
				flags |= B(PF_SHOW_PLS);
				goto rflag;
			  case '-':
				flags |= B(PF_LEFT);
				goto rflag;
			  default:
				break;

			}
			p++;
		}
Ejemplo n.º 10
0
// numbers become Numbers; every other token is a Symbol
cell atom(const std::string & token)
{
    if (isdig(token[0]) || (token[0] == '-' && isdig(token[1])))
        return cell(Number, token);
    return cell(Symbol, token);
}
Ejemplo n.º 11
0
/*
 * Take care of storing keydown and keyup,
 * take care of flower/command keys, which control VTs and GRFs
 * directly, and also take care of distinguishing RAW from COOKED
 * key strokes, if the keypress can be sent on to VT.
 */
void 
kbd_doevent(
    int key)
{
	int     numchars;
	u_char  chars[256];
	u_char  ochar = 0;
	int     i;

	kbd_setkeybits(key);

	if (!ADBK_PRESS(key)) {
		/* Key up... */
		return;
	}
	numchars = kbd_scantokey(key, chars);

	if (ISKEYDOWN(ADBK_FLOWER)) {	/* flower/command */
		switch (key) {
		case ADBK_F:	/* font change */
			mux_changefont();
			break;

		case ADBK_P:	/* pointer */
			mouse_on = !mouse_on;
			mux_mouseon(mouse_on);
#ifdef HIDE_MOUSE
			mouse_vis = 1;	/* make sure we show the pointer when
					 * it's turned on */
#endif				/* HIDE_MOUSE */
			break;

		case ADBK_O:	/* open new vt */
			main_newvt();
			break;

		case ADBK_X:	/* old paste */
			mux_paste();
			break;

		case ADBK_C:	/* copy, mac-style */
			mux_copy();
			break;

		case ADBK_V:	/* paste, mac-style */
			mux_realpaste();
			break;

			/* Digits: */
		case ADBK_1:
		case ADBK_2:
		case ADBK_3:
		case ADBK_4:
		case ADBK_5:
		case ADBK_6:
		case ADBK_7:
		case ADBK_8:
		case ADBK_9:
			i = keyboard[key][0] - '1';
			if (ISKEYDOWN(ADBK_SHIFT)) {
				mux_vttogrf(i);
			} else {
				mux_switchtovt(i);
			}
			break;

		case ADBK_UP:	/* up */
			mux_vtscroll(1);
			break;
		case ADBK_DOWN:/* dn */
			mux_vtscroll(-1);
			break;
		case ADBK_PGUP:/* pgup */
			mux_vtpage(1);
			break;
		case ADBK_PGDN:/* pgdn */
			mux_vtpage(-1);
			break;
		case ADBK_END:	/* end */
			mux_vtbottom();
			break;
		case ADBK_HOME:/* home */
			mux_vttop();
			break;
		}
		return;
	}
#ifdef HIDE_MOUSE
	if (mouse_on && mouse_vis && numchars) {	/* we have actual
							 * typing, hide the
							 * mouse */
		mux_mouseon(!mouse_on);
		mouse_vis = 0;
	}
#endif				/* HIDE_MOUSE */

	for (i = 0; i < numchars; i++) {
		if (indig) {
			if (chars[i] != ' ')
				ochar = chars[i];
			else
				ochar = 0;
			chars[i] = dodig(chars[i], &ochar);
			goto hoppari;
		}		/* process a digraph */
		if ((indig = isdig(chars[i])))
			continue;	/* if we got a digraph key, don't say
					 * it yet */
hoppari:			/* I'm becoming a serious goto-user */
		main_keyhit(mux_curvt, chars[i]);
		if (ochar) {
			main_keyhit(mux_curvt, ochar);
			ochar = 0;
		}
	}
}