예제 #1
0
파일: osutil.c 프로젝트: doniexun/OrangeC
/* Callbacks of the form
 *   void boolcallback( char selectchar, int value)
 *   void switchcallback( char selectchar, int value)  ;; value always true
 *   void stringcallback( char selectchar, char *string)
 */
static int scan_args(char *string, int index, char *arg)
{
    int i =  - 1;
    while (ArgList[++i].id)
    {
        switch (ArgList[i].mode)
        {
            case ARG_SWITCHSTRING:
                if (cmatch(string[index], ArgList[i].id))
                {
                    (*ArgList[i].routine)(string[index], &string[index]);
                    return (ARG_NEXTCHAR);
                }
                break;
            case ARG_SWITCH:
                if (cmatch(string[index], ArgList[i].id))
                {
                    (*ArgList[i].routine)(string[index], (char*)TRUE);
                    return (ARG_NEXTCHAR);
                }
                break;
            case ARG_BOOL:
                if (cmatch(string[index], ArgList[i].id))
                {
                    if (string[0] == ARG_SEPTRUE || string[0] == '/')
                        (*ArgList[i].routine)(string[index], (char*)TRUE);
                    else
                        (*ArgList[i].routine)(string[index], (char*)FALSE);
                    return (ARG_NEXTCHAR);
                }
                break;
            case ARG_CONCATSTRING:
                if (cmatch(string[index], ArgList[i].id))
                {
                    (*ArgList[i].routine)(string[index], string + index + 1);
                    return (ARG_NEXTARG);
                }
                break;
            case ARG_NOCONCATSTRING:
                if (cmatch(string[index], ArgList[i].id))
                {
                    if (!arg)
                        return (ARG_NOARG);
                    (*ArgList[i].routine)(string[index], arg);
                    return (ARG_NEXTNOCAT);
                }
                break;
        }
    }
    return (ARG_NOMATCH);
}
예제 #2
0
static void clickColor(control c, int argument)
{
    int element = cmatch(gettext(guielement), GuiElementNames);
    dialogColors[element] = nametorgb(ColorName[argument]);
    setforeground(guisample, dialogColors[whichfg[element]]);
    setbackground(guisample, dialogColors[whichbg[element]]);
}
예제 #3
0
static void getChoices(Gui p)
{
    p->MDI = ischecked(rb_mdi);
    p->toolbar = ischecked(toolbar);
    p->statusbar = ischecked(statusbar);
    p->pagerMultiple = ischecked(rb_mwin);
    strcpy(p->language, gettext(f_lang));
    strcpy(p->font, gettext(f_font));
    p->tt_font = ischecked(tt_font);
    p->pointsize = atoi(gettext(d_point));
    strcpy(p->style, gettext(f_style));
    p->crows = atoi(gettext(f_crows));
    p->ccols = atoi(gettext(f_ccols));
    p->cx = atoi(gettext(f_cx));
    p->cy = atoi(gettext(f_cy));
    p->setWidthOnResize = ischecked(c_resize);
    p->buffered = ischecked(c_buff);
    p->cbb = atoi(gettext(f_cbb));
    p->cbl = atoi(gettext(f_cbl));
    p->prows = atoi(gettext(f_prows));
    p->pcols = atoi(gettext(f_pcols));
    p->grx = atoi(gettext(f_grx));
    p->gry = atoi(gettext(f_gry));
    p->cursor_blink = getlistitem(f_blink);
    dialogColors[cmatch(gettext(guielement),GuiElementNames)] = nametorgb(gettext(guicolor));
    for (int i=0; i<numGuiColors; i++)
	p->guiColors[i] = dialogColors[i];    
    /* MDIsize is not currently a choice in the dialog, only in the Rconsole file */
    p->warning[0] = 0;
}
예제 #4
0
static BOOL fnmatch(BYTE FAR * s, BYTE FAR * d, COUNT n, COUNT mode)
{
  while (n--)
  {
    if (!cmatch(*s++, *d++, mode))
      return FALSE;
  }
  return TRUE;
}
예제 #5
0
파일: metacommand.c 프로젝트: BPaden/garglk
/*  --If x_obj(the explicit object) is defined, it must match with
      the "real" object-- that is, the global dobj or iobj value. */
static rbool cm_obj(word name, word adj, int x_obj, int obj, int real_obj)
{
  if (name==-1) return (obj==0); /* <NONE> */

  if (x_obj && !cm_x_obj(x_obj,real_obj)) return 0;
  
  /* (Note that ANY does not match ALL) */
  if (obj==-ext_code[wall])
    return(name==ext_code[wall] && adj==0);
  
  do {  /* Work our way up the class hierarchy */
    if (cmatch(name,it_name(obj)) && cmatch(adj,it_adj(obj)))
      return 1;
    obj=it_class(obj);
  } while(obj!=0);
 
  return 0;
}
예제 #6
0
파일: head.c 프로젝트: mulichao/freebsd
int
isdate(char date[])
{
	int i;

	for(i = 0; date_formats[i] != NULL; i++) {
		if (cmatch(date, date_formats[i]))
			return (1);
	}
	return (0);
}
예제 #7
0
int
isdate(char *date)
{
	int i;

	for(i = 0; *date_formats[i]; i++) {
		if (cmatch(date, date_formats[i]))
			return 1;
	}
	return 0;
}
예제 #8
0
파일: logic.c 프로젝트: AustenConrad/plan-9
Brick *
bmatch(Click c)
{
	Click lc;

	lc = cmatch(c, Depth);
	if(lc.d == -1)
		return nil;
	else
		return &level.board[lc.d][lc.x][lc.y];
}
예제 #9
0
파일: declvar.c 프로젝트: dex4er/deb-z88dk
/*
 * make a first stab at determining the ident of a variable
 */
int 
get_ident (void)
{
    if ( match("**") )
        return PTR_TO_PTR ;
    if ( match("*(*") )
        return PTR_TO_FNP;
    if ( cmatch('*') )
        return POINTER ;
    if ( match("(*") )
        return PTR_TO_FN ;
    return VARIABLE ;
}
예제 #10
0
파일: declvar.c 프로젝트: dex4er/deb-z88dk
void defenum(char *sname, char storage)
{
    SYMBOL  *ptr;
    char    name[NAMEMAX];
    long    value;
    /* Add it into the symbol table, we do not need to keep track of the
     * tag because we treat enums as constants
     */
    addglb(sname, ENUM, CINT, 0, storage, 0, 0);
    value=0;        /* initial constant */
    needchar('{');
    do {
        if (symname(name)==0)
            illname(name);
        if ( cmatch('=') )
            constexpr(&value,1);
        ptr=addglb(name,VARIABLE,ENUM,0,STATIK,0,0);
        ptr->size=value;
        value++;

    } while (cmatch(','));
    needchar('}');
}
예제 #11
0
파일: metacommand.c 프로젝트: BPaden/garglk
static rbool cm_command(cmd_rec *cmd,
		       integer m_actor, int m_verb,
		       integer m_dobj, word m_prep, integer m_iobj)
{
  if (cmd->verbcmd==0) { /* ANY */
    if (cmd->actor==0 && aver>=AGX00)
      return (m_verb==0); /* ANY command: rest of line ignored */
    /* Else ANY matchs; go on to test other things. */
  } else 
    if (cmd->verbcmd!=m_verb) return 0;
  
  return 
    cm_actor(cmd->actor,m_actor)
    && cm_obj(cmd->nouncmd,cmd->noun_adj,cmd->noun_obj,m_dobj,dobj) 
    && cmatch(cmd->prep,m_prep)
    && cm_obj(cmd->objcmd,cmd->obj_adj,cmd->obj_obj,m_iobj,iobj);
}
예제 #12
0
/*
 * initialise aggregate
 */
void agg_init(int size, int type, int ident, int *dim, int more, TAG_SYMBOL *tag)
{
    while (*dim) {
	if (ident == ARRAY && type == STRUCT) {
	    /* array of struct */
	    needchar('{');
	    str_init(tag);
	    --*dim;
	    needchar('}');
	} else {
	    init(size, ident, dim, more, (ident == ARRAY && more == CCHAR),0);
	}
	
	if (cmatch(',') == 0)
	    break;	
	blanks();
    }
}
예제 #13
0
파일: graphics.c 프로젝트: aahud/harvey
void
clearlevel(void)
{
	Click c, cm;

	for(c.d = Depth - 1; c.d >= 0; c.d--)
		for(c.y = 0; c.y < Ly; c.y++)
			for(c.x = 0; c.x < Lx; c.x++)
				if(level.board[c.d][c.x][c.y].which == TL &&
				    isfree(c)) {
					cm = cmatch(c, c.d);
					if(cm.d != -1) {
						clearbrick(cm);
						clearbrick(c);
						updatelevel();
						clearlevel();
					}
				}
}
예제 #14
0
파일: 2-4.c 프로젝트: DeadDork/learning_c
void squeeze( char string[], char sqzstr[] )
{
	int e, ee; // Element, Element copy 1, Element copy 2
	char sstring[ MAXLEN ]; // STRING[] copy 1

	for( e = ee = 0; string[ e ] != NUL; ++e )
	{
		if( !cmatch( string[ e ], sqzstr ) )
		{
			sstring[ ee++ ] = string[ e ];
		}
	}
	sstring[ ee ] = NUL;

	while( ee >= 0 )
	{
		string[ ee ] = sstring[ ee ];
		--ee;
	}
}
예제 #15
0
파일: main.c 프로젝트: meesokim/z88dk
void PragmaBytes(int flag)
{
    FILE   *fp;
    char   sname[NAMESIZE];
    int32_t value;
    int     count;

    if ( symname(sname) ) {
   if ( (fp=fopen("zcc_opt.def","a")) == NULL ) {
       error(E_ZCCOPT);
   }
   fprintf(fp,"\nIF NEED_%s\n",sname);
   if ( flag ) 
       fprintf(fp,"\tdefc DEFINED_NEED_%s = 1\n",sname);

   /* Now, do the numbers */
   count=0;
   while ( !cmatch(';') ) {
       if ( count == 0 )
      fprintf(fp,"\n\tdefb\t");
       else
      fprintf(fp,",");
       if ( number(&value) ) {
      fprintf(fp,"%d",value);
       } else {
      warning(W_EXPARG);
       }
       if ( rcmatch(';') ) {
      break;
       }
       needchar(',');
       count++;
       if ( count == 9 ) count=0;
   }
   fprintf(fp,"\nENDIF\n");
   fclose(fp);
   needchar(';');
    }
}   
예제 #16
0
/*
 * initialise global object
 */
int initials(char *sname,
             int type, int ident, int dim, int more,
             TAG_SYMBOL * tag, char zfar)
{
    int size, desize = 0;
    int olddim = dim;


    if (cmatch('=')) {
        /* initialiser present */
        defstatic = 1;		/* So no 2nd redefine djm */
        gltptr = 0;
        glblab = getlabel();
        if (dim == 0)
            dim = -1;
        switch (type) {
        case CCHAR:
            size = 1;
            break;
        case LONG:
            size = 4;
            break;
        case CINT:
        default:
            size = 2;
        }
	    
        output_section("data_compiler");  // output_section("text");
        prefix();
        outname(sname, YES);
        col();
        nl();

        if (cmatch('{')) {
            /* aggregate initialiser */
            if ((ident == POINTER || ident == VARIABLE) && type == STRUCT) {
                /* aggregate is structure or pointer to structure */
                dim = 0; olddim = 1;
                if (ident == POINTER)
                    point();
                str_init(tag);
            } else {
                /* aggregate is not struct or struct pointer */
                agg_init(size, type, ident, &dim, more, tag);
            }
            needchar('}');
        } else {
            /* single initialiser */
            init(size, ident, &dim, more, 0, 0);
        }


        /* dump literal queue and fill tail of array with zeros */
        if ((ident == ARRAY && more == CCHAR) || type == STRUCT) {
            if (type == STRUCT) {
                dumpzero(tag->size, dim);
                desize = dim < 0 ? abs(dim+1)*tag->size : olddim * tag->size;
            } else { /* Handles unsized arrays of chars */
                dumpzero(size, dim);
                dim = dim < 0 ? abs(dim+1) : olddim;
                cscale(type,tag,&dim);
                desize = dim;
            }
            dumplits(0, YES, gltptr, glblab, glbq);
        } else {
            if (!(ident == POINTER && type == CCHAR)) {
                dumplits(((size == 1) ? 0 : size), NO, gltptr, glblab,glbq);
                if ( type != CCHAR )  /* Already dumped by init? */
                    desize = dumpzero(size, dim);
                dim = dim < 0 ? abs(dim+1) : olddim;
                cscale(type,tag,&dim);
                desize = dim;
            }             
        }
        output_section("code_compiler");  // output_section("code");
    } else {
        char *dosign, *typ;
        dosign = "";
        if (ident == ARRAY && (dim == 0)) {
            typ = ExpandType(more, &dosign, (tag - tagtab));
            warning(W_NULLARRAY, dosign, typ);
        }
        /* no initialiser present, let loader insert zero */
        if (ident == POINTER)
            type = (zfar ? CPTR : CINT);
        cscale(type, tag, &dim);
        desize = dim;
    }
    return (desize);
}
예제 #17
0
파일: smatch.c 프로젝트: GlowMUCK/GlowMUCK
int 
smatch(char *s1, char *s2)
{
    char    ch, *start = s2;

    while (*s1) {
	switch (*s1) {
	    case '\\':
		if (!*(s1+1)) {
		    return 1;
		} else {
		    s1++;
		    if (DOWNCASE(*s1++) != DOWNCASE(*s2++))
			return 1;
		}
		break;
	    case '?':
		if (!*s2++)
		    return 1;
		s1++;
		break;
	    case '*':
		while (*s1 == '*' || (*s1 == '?' && *s2++))
		    s1++;
		if (*s1 == '?')
		    return 1;
		if (*s1 == '{') {
		    if (s2 == start)
			if (!smatch(s1, s2))
			    return 0;
		    while ((s2 = strchr(s2, ' ')) != NULL)
			if (!smatch(s1, ++s2))
			    return 0;
		    return 1;
		} else if (*s1 == '[') {
		    while (*s2)
			if (!smatch(s1, s2++))
			    return 0;
		    return 1;
		}
		if (*s1 == '\\' && *(s1+1))
		    ch = *(s1 + 1);
		else
		    ch = *s1;
		while ((s2 = cstrchr(s2, ch)) != NULL) {
		    if (!smatch(s1, s2))
			return 0;
		    s2++;
		}
		return 1;
	    case '[':
		{
		    char   *end;
		    int     tmpflg;

		    if (!(end = estrchr(s1, ']', '\\'))) {
			return 1;
		    }
		    *end = '\0';
		    tmpflg = cmatch(&s1[1], *s2++);
		    *end = ']';

		    if (tmpflg) {
			return 1;
		    }
		    s1 = end + 1;
		}
		break;
	    case '{':
		if (s2 != start && *(s2 - 1) != ' ')
		    return 1;
		{
		    char   *end;
		    int     tmpflg = 0;

		    if (s1[1] == '^')
			tmpflg = 1;

		    if (!(end = estrchr(s1, '}', '\\'))) {
			return 1;
		    }
		    *end = '\0';
		    tmpflg -= (wmatch(&s1[tmpflg + 1], &s2)) ? 1 : 0;
		    *end = '}';

		    if (tmpflg) {
			return 1;
		    }
		    s1 = end + 1;
		}
		break;
	    default:
		if (DOWNCASE(*s1++) != DOWNCASE(*s2++))
		    return 1;
		break;
	}
    }
    return DOWNCASE(*s1) - DOWNCASE(*s2);
}
예제 #18
0
파일: declfunc.c 프로젝트: dex4er/deb-z88dk
SYMBOL *
#endif

AddFuncCode(char *n, char type, char ident, char sign,char zfar, int storage, int more, char check,char simple,TAG_SYMBOL *otag, long *addr)
{
    unsigned char tvalue;           /* Used to hold protot value */
    char    typ;                    /* Temporary type */
    int     itag;

    itag=0;
    if (otag)
        itag=otag-tagtab;       /* tag number */

    lastst = 0;                     /* no last statement */
    locptr = STARTLOC ;             /* deallocate all locals */
    fnstart = lineno ;              /* remember where fn began */
    /*
     * Do some elementary checking before hand..
     */
    if (zfar && ident!=FUNCTIONP) { zfar=NO; warning(W_FAR); }
    if ( ( currfn=findglb(n) ) ) {
        /* already in symbol table ? */
        if ( currfn->ident != FUNCTION && currfn->ident != FUNCTIONP ) {
            /* already variable by that name */
            multidef();
        }
        else if ( currfn->offset.i == FUNCTION && !currfn->prototyped) {
            /* already function by that name */
            multidef();
        }
        else {
            /* we have what was earlier assumed to be a function */

            if (currfn->storage == EXTERNAL && currfn->flags&LIBRARY ) {
                /* Overwriting a lib function, is that what you wanted?!? Handy for
                 * compiling the library though!! Change type to local static to prevent
                 * being dumped in the scope list..
                 */
				if (makelib || storage == LSTATIC ) {
                    currfn->storage=LSTATIC;
				} else {
					currfn->storage=LIBOVER;
				} 
                currfn->offset.i=FUNCTION;
            } else {
                /*
                 * I'm not sure what *exactly* I was trying to achieve here djm 25/2/00
                 */
                if (currfn->storage != EXTERNAL && ( (currfn->flags&LIBRARY) != LIBRARY) ) {
                    currfn->flags&=(~LIBRARY);
                    currfn->size = 0;
                }
                currfn->offset.i = FUNCTION ;
                currfn->storage = storage;
            }
        }
    }
    /* if not in table, define as a function now */
    else {  
        typ=type;
        if (ident == FUNCTIONP) typ=(zfar ? CPTR : CINT );

        currfn = addglb(n, FUNCTION,  typ, FUNCTION, storage, more, 0);
        currfn->size=0;
        currfn->prototyped=0;
        currfn->flags= (sign&UNSIGNED) | (zfar&FARPTR);
        if (type == STRUCT) currfn->tagarg[0]=itag;
        /*
         *      Set our function prototype - what we are!
         *      args[0] is free for use
         */
        currfn->args[0]=CalcArgValue(type, ident, currfn->flags);

    }
    tvalue=CalcArgValue(type,ident,((sign&UNSIGNED) | (zfar&FARPTR)) );
    if ( currfn->args[0] != tvalue || (type==STRUCT && currfn->tagarg[0] != itag  )  ){
        char buffer[120];
        warning(W_DIFFTYPE);
        warning(W_DIFFTYPE2,ExpandArgValue(currfn->args[0],buffer,currfn->tagarg[0]));
        warning(W_DIFFTYPE3,ExpandArgValue(tvalue,buffer,itag) );

    }

    /* we had better see open paren for args... */
    if ( check && (cmatch('(') == 0) )
        error(E_PAREN);


    locptr = STARTLOC ;             /* "clear" local symbol table */
    undeclared = 0 ;                /* init arg count */


    /* Check to see if we are doing ANSI fn defs - must be a better way of
     * doing this! (Have an array and check by that?)           
     */
    if (CheckANSI()) {
        return( dofnansi(currfn, addr) ); /* So we can pass back result */
    }
    DoFnKR(currfn,simple);
    return(0);
}
예제 #19
0
파일: declfunc.c 프로젝트: dex4er/deb-z88dk
void DoFnKR(
SYMBOL *currfn,
char   simple)
{
    char n[NAMESIZE];
    SYMBOL *prevarg;       /* ptr to symbol table entry of most recent argument */
    SYMBOL *cptr;
    TAG_SYMBOL *otag ;     /* structure tag for structure argument */
    struct varid var;

    prevarg=0;
    Zsp=0;                  /* Reset stack pointer */
    undeclared=0;
    infunc=1;



    while ( !simple && cmatch(')') == 0 ) {    /* then count args */
        /* any legal name bumps arg count */
        if ( symname(n) ) {
            /* add link to argument chain */
            if ( (cptr=addloc(n,0,CINT,0,0)) )
                cptr->offset.p = prevarg ;
            prevarg = cptr ;
            ++undeclared ;
        }
        else {
            error(E_ARGNAME);
            junk();
        }
        blanks();
        /* if not closing paren, should be comma */
        if ( ch() != ')' && cmatch(',') == 0 ) {
            warning(W_EXPCOM);
        }
        if ( endst() ) break ;
    }

    Zsp = 0 ;                       /* preset stack ptr */

    while ( undeclared ) {
		char	regit=NO;
		if (amatch("register") ) regit=YES;
        /* Auto is be default in function defns, but someone might
         * try it on...
         */
		if (amatch("auto") ) warning(W_AUTO);

        otag=GetVarID(&var,STATIK);

        if (var.type==STRUCT) {
            getarg(STRUCT, otag,NO,0,0, var.zfar,NO) ;
        } else if (var.type || regit) {
			if (regit && var.type == NO ) var.type=CINT;
            getarg(var.type,NULL_TAG,NO,0,var.sign,var.zfar,NO);
        } else {
            error(E_BADARG) ;
            break ;
        }
    }
    /* Have finished K&R parsing */
    setlocvar(prevarg,currfn);
}
예제 #20
0
파일: declfunc.c 프로젝트: dex4er/deb-z88dk
SYMBOL *
#endif
dofnansi(SYMBOL *currfn, long *addr)
{
        SYMBOL *prevarg;       /* ptr to symbol table entry of most recent argument */
        SYMBOL *argptr;        /* Temporary holder.. */
        TAG_SYMBOL *otag ;     /* structure tag for structure argument */
        struct  varid var;
        char    proto;

        locptr=STARTLOC;
        prevarg=0;
        Zsp=0;                  /* Reset stack pointer */
        undeclared=1;
        proto=YES;

        swallow("__TD__");      /* kludge to get round typedef problem */
/* Master loop, checking for end of function */

        while ( cmatch(')') == 0 ) {  
                if (amatch("...") ) {
/*
 * Found some ellipses, so, add it to the local symbol table and
 * then return..(after breaking, and checking for ; & , )
 */
                        if (proto == 1 ) warning(W_ELLIP);
                        needchar(')');
                        argptr=addloc("ellp",0,ELLIPSES,0,0);
                        argptr->offset.p = prevarg;
                        prevarg=argptr;
                        break;
                }
                otag=GetVarID(&var,STATIK);

                if (var.type==STRUCT) {
                        prevarg=getarg(STRUCT, otag,YES,prevarg,0, var.zfar,proto) ;
                } else if (var.type) {
                        prevarg=getarg(var.type,NULL_TAG,YES,prevarg,var.sign,var.zfar,proto);

                } else {
                        warning(W_EXPARG);
                        break;
                }
                proto++;
/* Now check for comma */
                if (ch() !=')' && cmatch(',') == 0) {
                        warning(W_EXPCOM);
                        break;
                }
        }
/*
 *      Check for semicolon - I think this should be enough, just
 *      have to have prototypes on separate lines - good practice
 *      in anycase!!
 */
        if (cmatch('@') ) {
            constexpr(addr,1);
        }

        if (cmatch(';') ) return (prevarg);
        setlocvar(prevarg,currfn);
        return (0);
}
예제 #21
0
파일: declfunc.c 프로젝트: dex4er/deb-z88dk
SYMBOL *
#endif
getarg(
int typ ,               /* typ = CCHAR, CINT, DOUBLE or STRUCT */
TAG_SYMBOL *otag ,      /* structure tag for STRUCT type objects */
int deftype,            /* YES=ANSI -> addloc NO=K&R -> findloc */
SYMBOL *prevarg,        /* ptr to previous argument, only of use to ANSI */
char issigned,          /* YES=unsigned NO=signed */
char zfar,              /* FARPTR=far NO=near */
char proto)              /* YES=prototyping -> names not needed */
{
        char n[NAMESIZE] ;
        SYMBOL *argptr ;
        int legalname, ident, more ;
        int brkflag;            /* Needed to correctly break out for K&R*/
/*
 * This is of dubious need since prototyping came about, we could
 * inadvertently include fp packages if the user includes <math.h> but
 * didn't actually use them, we'll save the incfloat business for
 * static doubles and definitions of local doubles
 *
 *      if (typ == DOUBLE)
 *              incfloat=1;
 */
	argptr = NULL;

/* Only need while loop if K&R defs */

        while ( undeclared) {
                ident = get_ident() ;
                more =0;
                if ( (legalname=symname(n)) == 0 ) {
                        if (!proto) { illname(n); }
			else {
/*
 * Obligatory silly fake name
 */
                                sprintf(n,"sg6p_%d",proto);
				legalname=1;
			}
                }
                if ( ident == FUNCTIONP ) {
                           needtoken(")()");
                 /* function returning pointer needs dummy symbol */
                           more = dummy_idx(typ, otag) ;
                           typ = (zfar ? CPTR : CINT );
                } 
                else if ( ident == PTR_TO_FN ) {
                        needtoken(")()") ;
                        ident = POINTER ;
                }
                if ( cmatch('[') ) {    /* pointer ? */
                        ptrerror(ident) ;
                        /* it is a pointer, so skip all */
                        /* stuff between "[]" */
                        while ( inbyte() != ']' )
                                if ( endst() ) break;
                        /* add entry as pointer */
                        ident = (ident == POINTER) ? PTR_TO_PTR : POINTER ;
                }
                if ( legalname ) {
/*
 * For ANSI we need to add symbol name to local table - this CINT is  
 * temporary
 */
                        if (deftype) {
                                argptr=addloc(n,0,CINT,0,0);
                                argptr->offset.p = prevarg;
                        }
/*
 * If prototyping, then we can't find the name, but if we're prototyping
 * we have been defined as ANSI, therefore argptr already holds
 * the correct pointer - kinda neat!
 */
                        if ( proto || (argptr=findloc(n)) ) {
                                argptr->flags=(zfar&FARPTR)|(issigned&UNSIGNED);
                                /* add in details of the type of the name */
                                if ( ident == PTR_TO_PTR ) {
/* djm mods will be here for long pointer */
                                     //   argptr->flags = UNSIGNED |FARPTR ; /*unsigned*/
                                        argptr->ident = POINTER ;
					argptr->type = typ;
                                      //  argptr->type = ( (zfar&FARPTR) ? CPTR : CINT );
                                        argptr->more = dummy_idx(typ, otag) ;
                                }
                                else {
                                        argptr->more = more;
                                        argptr->ident = ident ;
                                        argptr->type = typ ;
                                }
                        }
                        else warning(W_EXPARG);
                        if ( otag ) {
                                argptr->tag_idx = otag - tagtab ;
                                argptr->ident = POINTER ;
                                argptr->type = STRUCT ;
                        }
                }
                brkflag=0;
                if (!deftype) {
                        --undeclared;   /* cnt down */
                        if ( endst() )
                                { brkflag=1; break; }
                       if ( cmatch(',') == 0 )
                                warning(W_EXPCOM) ;
                }
                if (brkflag || deftype) break;
        }
        if (deftype) return(argptr);
        ns();
        return(0);
}
예제 #22
0
파일: declfunc.c 프로젝트: dex4er/deb-z88dk
int AddNewFunc(
char *sname,
int type,
int storage,
char zfar,
char sign,
TAG_SYMBOL *otag,
int ident,
long *addr)
{
    SYMBOL *ptr;
    int     more;
    char    simple;         /* Simple def () */
    more=0;

    /*
     *      First of all check to see if we have a number - this is
     *      external pointer type
     */

    if (number(addr)) return (EXTERNP);

    /*
     *      Now, check for simple prototyping, we can drop that
     *      back as well, we have to check for punctuation - ; or ,
     *      afterwards, so that we can know its not a function
     *      definitions
     */
    simple=NO;
    if ( cmatch(')') ) {
        if ( rcmatch(';') || rcmatch(',') ) return(storage);
        simple=YES;
    }

    ptrerror(ident) ;
    if ( ident == POINTER ) {
        /* function returning pointer needs dummy symbol */
        more = dummy_idx(type, otag) ;
        /*                type = (zfar ? CPTR : CINT ); */
        ident=FUNCTIONP;        /* func returning ptr */
    } else ident=FUNCTION;

    /*
     *      Okay, we've got rid of everything that could pop up apart
     *      from:
     *      - ANSI prototypes
     *      - Functions themselves (ANSI & K&R)
     *
     *      First call AddNewFunc(), if this returns 0 then we have defined
     *      a function (including code)
     */
    ptr=AddFuncCode(sname, type, ident,sign, zfar, storage, more,NO,simple,otag,addr);
       
    if (ptr==0) { /* Defined a function */
        /* trap external int blah() { } things */
        if (currfn->storage==EXTERNAL) currfn->storage=STATIK;
        return(0);
    } else {
        StoreFunctionSignature(ptr);
    }
    return(0);

}
예제 #23
0
파일: const.c 프로젝트: dex4er/deb-z88dk
int fnumber(long *val)
{
    unsigned char sum[6];
    unsigned char sum2[6];
    unsigned char scale[6];
    unsigned char frcn[6];
    unsigned char dig1[6];
    unsigned char dig2[6];
    unsigned char dig3[6];
    int k;                  /* flag and mask */
    char minus;     /* is if negative! */
    char *start;    /* copy of pointer to starting point */
    char *s;             /* points into source code */
    char *dp1;	    /* First number after dp */
    char *end;
    

    if (mathz88) {             /* Z88 Representation of 0.1 */
	frcn[0] = 0;
	frcn[1] = 205;
	frcn[2] = frcn[3]=204;
	frcn[4] = 76;
	frcn[5] = 125;
    } else {                   /* Generic representation of 0.1 */
	frcn[0] = 205;
	frcn[1] = frcn[2] = frcn[3] = 204;
	frcn[4] = 76;
	frcn[5] = 125;            
    }

    start = s = line+lptr;      /* save starting point */
    k = 1;
    minus = 1;
    while(k) {
	k=0;
	if(*s == '+') {
	    ++s; k=1;
	}
	if(*s == '-') {
	    ++s; k=1; minus=(-minus);
	}
    }
        
    while (*s==' ')   /* Ignore white space after sign */
	s++;

    while ( numeric(*s) )
	++s ;

    if ( *s != '.' && *s != 'e'  ) {   /* Check that it is floating point */
	s++;
	return 0;
    }
    dp1 = ++s;
    while ( numeric(*s) )
	++s ;
    lptr = (s--) - line ;           /* save ending point */

    end = s;

    sum[0]=sum[1]=sum[2]=sum[3]=sum[4]=sum[5]='\0';
    sum2[0]=sum2[1]=sum2[2]=sum2[3]=sum2[4]=sum2[5]='\0';

    memcpy(dig3,frcn,6);	/* Copy 0.1 dig3 */
    s = dp1;
    /* Deals with the decimal place */
    while ( numeric(*s) && s <= end) {
	qfloat((*s-'0'),dig1);   /* 0-9 */
	fltmult(dig3,dig1);      /* * 0.1 */
	fltadd(dig1,sum2);
	fltmult(frcn,dig3);
	s++;
    }
    s = --dp1;	/* Now points to dp */

    qfloat(1,scale);              /* Now do numbers after decimal place */
    while ( --s >= start ) {
	qfloat((*s-'0'),dig1);
	fltmult(scale,dig1);
	fltadd(dig1,sum);
	qfloat(10,dig2);
	fltmult(dig2,scale);
    }
    fltadd(sum2,sum);


    if( cmatch('e') ) {                       /* interpret exponent */
	int neg;                        /* nonzero if exp is negative */
	long expon;                     /* the exponent */

	if( number(&expon) == 0 ) {
	    error(E_EXPON);
	    expon=0;
	}
	if( expon < 0 ) {
	    neg=1; 
	    expon=(-expon);
	} else {
	    neg = 0;
	}
	if( expon > 38 ) {
	    error(E_FLOATING);
	    expon=0;
	}
	/* Now find the scaling factor. We find 10**expon */
	if ( neg == 0 ) {
	    qfloat(1,scale);
	    k = 32;
	    while( k ) {
		memcpy(sum2,scale,6);	/* Copy scale */
		fltmult(sum2,scale);    /* scale * scale */
		if( k & expon) {
		    qfloat(10,sum2);      /* scale *= 10 */
		    fltmult(sum2,scale);
		}
		k >>= 1;
	    }
	} else {   /* Negative exponenent find 0.1 ** expon */
예제 #24
0
파일: declvar.c 프로젝트: dex4er/deb-z88dk
/*
 *      Declare a static variable (i.e. define for use)
 *
 *  makes an entry in the symbol table so subsequent
 *  references can call symbol by name
 */
void declglb(
int typ ,               /* typ is CCHAR, CINT, DOUBLE, STRUCT, LONG, */
int storage,
TAG_SYMBOL *mtag ,              /* tag of struct whose members are being declared, or zero */
TAG_SYMBOL *otag ,              /* tag of struct for object being declared */
int is_struct ,                 /* TRUE if struct member being declared, zero if union */
char sign ,                    /* TRUE if need signed */
char zfar )                      /* TRUE if far */
{
    char sname[NAMESIZE];
    int size, ident, more, itag, type, size_st;
    long addr = -1;
    char    flagdef,match,ptrtofn;
    char    libdef,fastcall,callee;
    SYMBOL *myptr ;

    do {
        if ( endst() ) break;   /* do line */

        type = typ ;
        size = 1 ;                              /* assume 1 element */
        more =                                  /* assume dummy symbol not required */
            itag = 0 ;                              /* just for tidiness */
        flagdef=libdef=fastcall=callee=NO;


		match=ptrtofn=NO;

        while (blanks(),rcmatch('_') ) {
			match=NO;
            if (amatch("__APPFUNC__") ) { match=YES; flagdef=1; }
            if (amatch("__LIB__") /* && libdef==0 */) {match=YES; libdef|=LIBRARY; }
            if (amatch("__FASTCALL__") ) {match=YES; fastcall=REGCALL; }
            if (amatch("__SHARED__") ) {match=YES; libdef|=SHARED; }
			if (amatch("__SHAREDC__") ) {match=YES; libdef|=SHAREDC; }
			if (amatch("__CALLEE__") ) {match=YES; callee=CALLEE; }
			if (match ==NO )break;
        }

        ident = get_ident() ;
        if (storage==TYPDEF && ident !=VARIABLE && mtag ==0 ) warning(W_TYPEDEF);

        if ( symname(sname) == 0 )      /* name ok? */
            illname(sname) ;                     /* no... */

        if ( ident == PTR_TO_FNP ) {
            /* function returning pointer needs dummy symbol */
            more = dummy_idx(typ, otag) ;
            type = (zfar ? CPTR : CINT );
            size=0;
			ptrtofn=YES;
        } 
        else if ( ident == PTR_TO_FN ) {
            ident = POINTER ;
			ptrtofn=YES;
#if 0
        } else if ( cmatch('@') ) {
			storage = EXTERNP;
			constexpr(&addr,1);
#endif
        } else if ( cmatch('(') ) {
            /*
             * Here we check for functions, but we can never have a pointer to
             * function because thats considered above. Which means as a very
             * nice side effect that we don't have to consider structs/unions
             * since they can't contain functions, only pointers to functions
             * this, understandably(!) makes the work here a lot, lot easier!
             */
            storage=AddNewFunc(sname,type,storage,zfar,sign,otag,ident,&addr);
            /*
             *      On return from AddNewFunc, storage will be:
             *      EXTERNP  = external pointer, in which case addr will be set
             *  !!    FUNCTION = have prototyped a function (NOT USED!)
             *      0        = have declared a function/!! prototyped ANSI
             *
             *      If 0, then we have to get the hell out of here, FUNCTION
             *      then gracefully loop round again, if EXTERNP, carry on with
             *      this function, anything else means that we've come up
             *      against a K&R style function definition () so carry on
             *      as normal!
             *
             *      If we had our function prefixed with __APPFUNC__ then we want
             *      to write it out to the zcc_opt.def file (this bloody thing
             *      is becoming invaluable for messaging!
             *
             *	__SHARED__ indicates in a library so preserve carry flag
             * 	(so we can test with iferror)
             *
             *	__CALLEE__ indicates that the function called cleans up
             *	the stack
             *
             *	__SHAREDC__ is indicates call by rst 8 but is unused..
             *	(old idea unused, but may yet be useful)
             */
            if (flagdef) WriteDefined(sname,0);
            if (currfn) {
                /* djm 1/2/03 - since we can override lib functions don't reset the library
                   flag
                   currfn->flags&=(~LIBRARY);
                */
                if (libdef) {
                    //		currfn->flags|=LIBRARY;
                    currfn->flags|=libdef;
                }
				if (callee && (libdef&SHARED) != SHARED && \
				    (libdef&SHAREDC) != SHAREDC )
					currfn->flags|=callee;
                if (fastcall) currfn->flags|=fastcall;
            }
            if (storage==0) {
                if ( addr != -1 ) {
                    currfn->size = addr;
                }
				return;
			}
            /*
             *      External pointer..check for the closing ')'
             */
            if (storage==EXTERNP) {
                needchar(')');
            } else {
                /*
                 *  Must be a devilishly simple prototype! ();/, type...
                 */
                ptrerror(ident) ;
                if ( ident == POINTER ) {
                    /* function returning pointer needs dummy symbol */
                    more = dummy_idx(typ, otag) ;
                    type = (zfar ? CPTR : CINT );
                    ident=FUNCTIONP;
                } else {
                    ident=FUNCTION;
                }
                size = 0 ;
                                
            }
        }
        if (cmatch('[')) {         /* array? */
            ptrerror(ident) ;
            if ( ident == POINTER) {
                /* array of pointers needs dummy symbol */
                more = dummy_idx(typ, otag) ;
                type = (zfar ? CPTR : CINT );
            }
            size = needsub() ;      /* get size */
            if (size == 0 && ident == POINTER ) size=0;
            ident = ARRAY;
			if ( ptrtofn ) needtoken(")()");
        } else if ( ptrtofn ) {
            needtoken(")()") ;
		} else if ( ident == PTR_TO_PTR ) {
            ident = POINTER ;
            more = dummy_idx(typ, otag) ;
            type = (zfar ? CPTR : CINT );
        }

		if ( cmatch('@') ) {
			storage = EXTERNP;
			constexpr(&addr,1);
		}
예제 #25
0
static void showDialog(Gui gui)
{
    char buf[100];

    wconfig = newwindow(G_("Rgui Configuration Editor"), rect(0, 0, 550, 450),
			Titlebar | Centered | Modal);
    setbackground(wconfig, dialog_bg());
    l_mdi = newlabel("Single or multiple windows",
		     rect(10, 10, 140, 20), AlignLeft);
    rb_mdi = newradiobutton("MDI", rect(150, 10 , 70, 20), cMDI);
    rb_sdi = newradiobutton("SDI", rect(220, 10 , 70, 20), cSDI);


    toolbar = newcheckbox("MDI toolbar", rect(300, 10, 100, 20), NULL);
    if(gui->toolbar) check(toolbar);
    statusbar = newcheckbox("MDI statusbar", rect(420, 10, 130, 20), NULL);
    if(gui->statusbar) check(statusbar);
    if(gui->MDI) {
	check(rb_mdi); cMDI(rb_mdi);
    } else {
	check(rb_sdi); cSDI(rb_sdi);
    }

    l_mwin = newlabel("Pager style", rect(10, 40, 90, 20), AlignLeft);
    g_mwin = newradiogroup();
    rb_mwin = newradiobutton("multiple windows", rect(150, 40, 150, 20), NULL);
    rb_swin = newradiobutton("single window", rect(150, 60 , 150, 20), NULL);
    if(gui->pagerMultiple) check(rb_mwin); else check(rb_swin);

    l_lang = newlabel("Language for menus\nand messages",
		      rect(320, 40, 130, 40), AlignLeft);
    f_lang = newfield(gui->language, rect(450, 45, 60, 20));

/* Font, pointsize, style */

    l_font = newlabel("Font", rect(10, 100, 40, 20), AlignLeft);

    f_font = newdropfield(FontsList, rect(50, 100, 120, 20), scrollFont);
    tt_font = newcheckbox("TrueType only", rect(180, 100, 110, 20), changeFont);
    if (gui->tt_font) check(tt_font);
    settext(f_font, gui->font);

    l_point = newlabel("size", rect(310, 100, 30, 20), AlignLeft);
    d_point = newdropfield(PointsList, rect(345, 100, 50, 20), scrollPoints);
    snprintf(buf, 100, "%d", gui->pointsize);
    settext(d_point, buf);
    l_style = newlabel("style", rect(410, 100, 40, 20), AlignLeft);
    f_style = newdroplist(StyleList, rect(450, 100, 80, 20), scrollStyle);
    setlistitem(f_style, cmatch(gui->style, StyleList));

/* Console size, set widthonresize */
    l_crows = newlabel("Console   rows", rect(10, 150, 100, 20), AlignLeft);
    snprintf(buf, 100, "%d", gui->crows);
    f_crows = newfield(buf, rect(110, 150, 30, 20));
    l_ccols = newlabel("columns", rect(150, 150, 60, 20), AlignLeft);
    snprintf(buf, 100, "%d", gui->ccols);
    f_ccols = newfield(buf, rect(220, 150, 30, 20));
    l_cx = newlabel("Initial left", rect(270, 150, 70, 20), AlignLeft);
    snprintf(buf, 100, "%d", gui->cx);
    f_cx = newfield(buf, rect(350, 150, 40, 20));
    l_cy = newlabel("top", rect(430, 150, 30, 20), AlignLeft);
    snprintf(buf, 100, "%d", gui->cy);
    f_cy = newfield(buf, rect(480, 150, 40, 20));

    c_resize = newcheckbox("set options(width) on resize?",
			   rect(20, 175, 200, 20), NULL);
    if(gui->setWidthOnResize) check(c_resize);

    l_cbb = newlabel("buffer chars", rect(270, 175, 70, 20), AlignLeft);
    snprintf(buf, 100, "%d", gui->cbb);
    f_cbb = newfield(buf, rect(350, 175, 60, 20));
    l_cbl = newlabel("lines", rect(430, 175, 50, 20), AlignLeft);
    snprintf(buf, 100, "%d", gui->cbl);
    f_cbl = newfield(buf, rect(480, 175, 40, 20));

    c_buff = newcheckbox("buffer console by default?",
			 rect(20, 190, 200, 20), NULL);
    if(gui->buffered) check(c_buff);

/* Cursor blink */

    l_blink = newlabel("Cursor blink", rect(270, 200,100, 30), AlignLeft);
    f_blink = newdroplist(BlinkList, rect(350, 200, 80, 20), NULL);
    setlistitem(f_blink, gui->cursor_blink);
    
/* Pager size */
    l_prows = newlabel("Pager   rows", rect(10, 230, 100, 20), AlignLeft);
    snprintf(buf, 100, "%d", gui->prows);
    f_prows = newfield(buf, rect(110, 230, 30, 20));
    l_pcols = newlabel("columns", rect(150, 230, 60, 20), AlignLeft);
    snprintf(buf, 100, "%d", gui->pcols);
    f_pcols = newfield(buf, rect(220, 230, 30, 20));

/* Graphics window */
    l_grx = newlabel("Graphics windows: initial left",
		     rect(10, 270, 190, 20), AlignLeft);
    snprintf(buf, 100, "%d", gui->grx);
    f_grx = newfield(buf, rect(200, 270, 40, 20));
    l_gry = newlabel("top", rect(270, 270, 30, 20), AlignLeft);
    snprintf(buf, 100, "%d", gui->gry);
    f_gry = newfield(buf, rect(300, 270, 40, 20));

/* Font colours */
    l_cols = newlabel("Console and Pager Colours",
		      rect(10, 310, 520, 20), AlignCenter);
			      
    guielement = newlistbox(GuiElementNames, rect(50, 330, 100, 80), changeElement, NULL);
    guicolor = newlistbox(ColorName, rect(205, 330, 100, 80), clickColor, NULL);
    guisample = newrichtextarea("Sample text", rect(350, 330, 150, 55));
	
    for (int i=0; i<numGuiColors; i++)
    	dialogColors[i] = gui->guiColors[i];
    	
    setlistitem(guielement, 0);
    changeElement(guielement, 0);
    sampleFontNum = cmatch(gettext(f_font), FontsList);
    samplePointsize = atoi(gettext(d_point));
    scrollStyle(f_style, 0); /* the 0 is ignored */

    bApply = newbutton("Apply", rect(50, 410, 70, 25), apply);
    bSave = newbutton("Save...", rect(130, 410, 70, 25), save);
    bLoad = newbutton("Load...", rect(210, 410, 70, 25), load);
    bOK = newbutton("OK", rect(350, 410, 70, 25), ok);
    bCancel = newbutton("Cancel", rect(430, 410, 70, 25), cancel);
    show(wconfig);
}
예제 #26
0
/*
 * initialise structure
 */
int str_init(TAG_SYMBOL *tag)
{
    int dim, flag;
    int sz, usz, numelements = 0;
    SYMBOL *ptr;
    int     nodata = NO;

    ptr = tag->ptr;
    while (ptr < tag->end) {
        numelements++;
        dim = ptr->size;
        sz = getstsize(ptr,NO);
        if ( nodata == NO ) {
            if ( rcmatch('{') ) {
                needchar('{');
                while (dim) {
                    if ( ptr->type == STRUCT ) {
                        if ( ptr->ident == ARRAY )
                        /* array of struct */
                            needchar('{');
                        str_init(tag);
                        if ( ptr->ident == ARRAY ) {
                            --dim;
                            needchar('}');
                        }
                    } else {
                        init(sz, ptr->ident, &dim, 1, 1,1);
                    }

                    if (cmatch(',') == 0)
                        break;
                    blanks();
                }
                needchar('}');
                dumpzero(sz,dim);
            } else {
                init(sz, ptr->ident, &dim, ptr->more, 1, 1);
            }
            /* Pad out afterwards */
        } else {  /* Run out of data for this initialisation, set blank */ 
            defstorage();
            outdec(dim * getstsize(ptr,YES));
            nl();		
        }



        usz = (ptr->size ? ptr->size : 1 ) * getstsize(ptr,YES);
        ++ptr;
        flag = NO;
        while (ptr->offset.i == 0 && ptr < tag->end) {
            if (getstsize(ptr,YES) * (ptr->size ? ptr->size : 1 )  > usz) {
                usz = getstsize(ptr,YES) * (ptr->size ? ptr->size : 1 ) ;
                flag = YES;
            }
            ++ptr;

        }

        /* Pad out the union */
        if (usz != sz && flag) {
            defstorage();
            outdec(usz - sz);
            nl();
        }
        if (cmatch(',') == 0 && ptr != tag->end) {
            nodata = YES;	   
        }
    }
    return numelements;
}