pike.git / src / pike_types.c

version» Context lines:

pike.git/src/pike_types.c:1:   /*\   ||| This file a part of Pike, and is copyright by Fredrik Hubinette   ||| Pike is distributed as GPL (General Public License)   ||| See the files COPYING and DISCLAIMER for more information.   \*/   #include "global.h" - RCSID("$Id: pike_types.c,v 1.27 1998/03/03 11:24:39 hubbe Exp $"); + RCSID("$Id: pike_types.c,v 1.28 1998/03/03 14:37:15 grubba Exp $");   #include <ctype.h>   #include "svalue.h"   #include "pike_types.h"   #include "stralloc.h"   #include "stuff.h"   #include "array.h"   #include "program.h"   #include "constants.h"   #include "object.h"   #include "multiset.h"   #include "mapping.h"   #include "pike_macros.h"   #include "error.h"   #include "las.h"   #include "language.h"   #include "pike_memory.h"      int max_correct_args;    - static void internal_parse_type(char **s); + static void internal_parse_type(unsigned char **s);   static int type_length(char *t);      #define TWOT(X,Y) (((X) << 8)+(Y))   #define EXTRACT_TWOT(X,Y) TWOT(EXTRACT_UCHAR(X), EXTRACT_UCHAR(Y))      /*    * basic types are represented by just their value in a string    * basic type are string, int, float, object and program    * arrays are coded like by the value T_ARRAY followed by the    * data type, if the type is not known it is T_MIXED, ie:
pike.git/src/pike_types.c:227:   }      struct pike_string *debug_pop_type(void)   {    struct pike_string *s;    s=pop_unfinished_type();    type_stack_mark();    return s;   }    - static void internal_parse_typeA(char **_s) + static void internal_parse_typeA(unsigned char **s)   {    char buf[80];    unsigned int len; -  unsigned char **s = (unsigned char **)_s; +        while(ISSPACE(**s)) ++*s;       len=0;    for(len=0;isidchar(EXTRACT_UCHAR(s[0]+len));len++)    {    if(len>=sizeof(buf)) error("Buffer overflow in parse_type\n");    buf[len] = s[0][len];    }    buf[len]=0;
pike.git/src/pike_types.c:276:    if(**s == ':')    {    push_type(T_MANY);    push_type(T_VOID);    break;    }       type_stack_mark();    type_stack_mark();    type_stack_mark(); -  internal_parse_type(_s); +  internal_parse_type(s);    type_stack_reverse();    if(**s==',')    {    ++*s;    while(ISSPACE(**s)) ++*s;    }    else if(s[0][0]=='.' && s[0][1]=='.' && s[0][2]=='.')    {    type_stack_reverse();    push_type(T_MANY);
pike.git/src/pike_types.c:298:    *s+=3;    while(ISSPACE(**s)) ++*s;    if(**s != ':') error("Missing ':' after ... in function type.\n");    break;    }    pop_stack_mark();    pop_stack_mark();    }    ++*s;    type_stack_mark(); -  internal_parse_type(_s); /* return type */ +  internal_parse_type(s); /* return type */    type_stack_reverse();    if(**s != ')') error("Missing ')' in function type.\n");    ++*s;    type_stack_reverse();    }else{    push_type(T_MIXED);    push_type(T_MIXED);    push_type(T_MANY);    }    push_type(T_FUNCTION);    }    else if(!strcmp(buf,"mapping"))    {    while(ISSPACE(**s)) ++*s;    if(**s == '(')    {    type_stack_mark();    ++*s;    type_stack_mark(); -  internal_parse_type(_s); +  internal_parse_type(s);    type_stack_reverse();    if(**s != ':') error("Expecting ':'.\n");    ++*s;    type_stack_mark(); -  internal_parse_type(_s); +  internal_parse_type(s);    type_stack_reverse();    if(**s != ')') error("Expecting ')'.\n");    ++*s;    type_stack_reverse();    }else{    push_type(T_MIXED);    push_type(T_MIXED);    }    push_type(T_MAPPING);    }    else if(!strcmp(buf,"array"))    {    while(ISSPACE(**s)) ++*s;    if(**s == '(')    {    ++*s; -  internal_parse_type(_s); +  internal_parse_type(s);    if(**s != ')') error("Expecting ')'.\n");    ++*s;    }else{    push_type(T_MIXED);    }    push_type(T_ARRAY);    }    else if(!strcmp(buf,"multiset"))    {    while(ISSPACE(**s)) ++*s;    if(**s == '(')    {    ++*s; -  internal_parse_type(_s); +  internal_parse_type(s);    if(**s != ')') error("Expecting ')'.\n");    ++*s;    }else{    push_type(T_MIXED);    }    push_type(T_MULTISET);    }    else    error("Couldn't parse type. (%s)\n",buf);       while(ISSPACE(**s)) ++*s;   }       - static void internal_parse_typeB(char **s) + static void internal_parse_typeB(unsigned char **s)   {    while(ISSPACE(**s)) ++*s;    switch(**s)    {    case '!':    ++*s;    internal_parse_typeB(s);    push_type(T_NOT);    break;   
pike.git/src/pike_types.c:393:    while(ISSPACE(**s)) ++*s;    if(**s != ')') error("Expecting ')'.\n");    break;       default:       internal_parse_typeA(s);    }   }    - static void internal_parse_typeCC(char **s) + static void internal_parse_typeCC(unsigned char **s)   {    internal_parse_typeB(s);       while(ISSPACE(**s)) ++*s;       while(**s == '*')    {    ++*s;    while(ISSPACE(**s)) ++*s;    push_type(T_ARRAY);    }   }    - static void internal_parse_typeC(char **s) + static void internal_parse_typeC(unsigned char **s)   {    type_stack_mark();       type_stack_mark();    internal_parse_typeCC(s);    type_stack_reverse();       while(ISSPACE(**s)) ++*s;       if(**s == '&')
pike.git/src/pike_types.c:430:    type_stack_mark();    internal_parse_typeC(s);    type_stack_reverse();    type_stack_reverse();    push_type(T_AND);    }else{    type_stack_reverse();    }   }    - static void internal_parse_type(char **s) + static void internal_parse_type(unsigned char **s)   {    internal_parse_typeC(s);       while(ISSPACE(**s)) ++*s;       while(**s == '|')    {    ++*s;    internal_parse_typeC(s);    push_type(T_OR);
pike.git/src/pike_types.c:452:   }      /* This function is used when adding simul efuns so that    * the types for the functions can be easily stored in strings.    * It takes a string on the exact same format as Pike and returns a type    * struct.    */   struct pike_string *parse_type(char *s)   {    type_stack_mark(); -  internal_parse_type(&s); +  internal_parse_type((unsigned char **)&s);       if( *s )    fatal("Extra junk at end of type definition.\n");       return pop_unfinished_type();   }      #ifdef DEBUG   void stupid_describe_type(char *a,INT32 len)   {