Changeset 267 for trunk/src/symtab.c


Ignore:
Timestamp:
Mar 20, 2009, 12:18:53 PM (11 years ago)
Author:
ksherdy
Message:

Construct and pass string literals as read only (const char *) types.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/symtab.c

    r184 r267  
    5353        else switch (codepoint >> 12) {
    5454                case 0: case 1: return true;
    55                 case 2: if (codepoint >= 0x2070) 
     55                case 2: if (codepoint >= 0x2070)
    5656                                if (codepoint <= 0x218F) return true;
    5757                                else return (codepoint >= 0x2C00) & (codepoint <= 0x2FEF);
     
    7171        else switch (codepoint >> 12) {
    7272                case 0: case 1: return true;
    73                 case 2: if (codepoint >= 0x2070) 
     73                case 2: if (codepoint >= 0x2070)
    7474                                if (codepoint <= 0x218F) return true;
    7575                                else return (codepoint >= 0x2C00) & (codepoint <= 0x2FEF);
     
    134134        }
    135135        else {
    136                 int codepoint = ((bytes[0] & 0x0F) << 18)| ((bytes[1] & 0x3F) << 12) | 
     136                int codepoint = ((bytes[0] & 0x0F) << 18)| ((bytes[1] & 0x3F) << 12) |
    137137                                ((bytes[2] & 0x3F) << 6) | (bytes[3] & 0x3F);
    138138                return is_XML11_NameStrt_codepoint(codepoint) ? 4 : 0;
     
    154154        }
    155155        else {
    156                 int codepoint = ((bytes[0] & 0x0F) << 18)| ((bytes[1] & 0x3F) << 12) | 
     156                int codepoint = ((bytes[0] & 0x0F) << 18)| ((bytes[1] & 0x3F) << 12) |
    157157                                ((bytes[2] & 0x3F) << 6) | (bytes[3] & 0x3F);
    158158                return is_XML11_NameChar_codepoint(codepoint) ? 4 : 0;
     
    166166                valid_bytes = XML_10_UTF8_NameChar_bytes((unsigned char *) &protoname[pos]);
    167167                pos += valid_bytes;
    168                  
     168
    169169        }
    170170        /* Success requires that every byte sequence processed be valid
    171171           and that the total lgth processed be exactly that provided on
    172172           input. */
    173          
     173
    174174        return (valid_bytes > 0) & (pos == lgth);
    175175}
     
    194194                valid_bytes = XML_10_UTF8_NameChar_bytes((unsigned char *) &prototoken[pos]);
    195195                pos += valid_bytes;
    196                  
     196
    197197        }
    198198        /* Success requires that every byte sequence processed be valid
    199199           and that the total lgth processed be exactly that provided on
    200200           input. */
    201          
     201
    202202        return (valid_bytes > 0) & (pos == lgth);
    203203}
     
    216216}
    217217
    218 int Symbol_Table::Insert_Name(char * name, int lgth) {
     218int Symbol_Table::Insert_Name(const char * name, int lgth) {
    219219//      char * s = copy_name(name,lgth);
    220220        char * s = pool.Insert(name,lgth);
     
    240240                /* Clear bytes beyond the length of the name. */
    241241                b = sisd_sfl(b, sisd_from_int(8 * (sizeof(BytePack) - name_lgth)));
    242         } 
     242        }
    243243        else {
    244244                int offset = name_lgth % sizeof(BytePack);
     
    271271
    272272int Symbol_Table::UTF8_Lookup_or_Insert_Name(char * name, int lgth) {
    273                
     273
    274274        char delim = name[lgth];
    275275        name[lgth] = '\0';
    276276        int nameID = UTF8NameMap[name];
    277         name[lgth] = delim;     
    278        
     277        name[lgth] = delim;
     278
    279279        if(nameID == 0){
    280280        #if (not defined(OMISSION)) or (OMISSION != NAME_VALIDATION)
     
    335335
    336336int Symbol_Table::UTF8_Lookup_or_Insert_Nmtoken(char * nmtoken, int lgth) {
    337                
     337
    338338        char delim = nmtoken[lgth];
    339339        nmtoken[lgth] = '\0';
    340340        int nmtokenID = UTF8NmtokenMap[nmtoken];
    341         nmtoken[lgth] = delim; 
    342        
     341        nmtoken[lgth] = delim;
     342
    343343        if(nmtokenID == 0){
    344344        #if (not defined(OMISSION)) or (OMISSION != NAME_VALIDATION)
     
    394394}
    395395
    396 int Symbol_Table::LookupOrInsertReserved(){             
     396int Symbol_Table::LookupOrInsertReserved(){
    397397        int nameID = UTF8NameMap[reserved];
    398398        if(nameID == 0){
     
    417417}
    418418
    419 int Symbol_Table::LookupOrInsertReserved_nmtoken(){             
     419int Symbol_Table::LookupOrInsertReserved_nmtoken(){
    420420        int nmtokenID = UTF8NmtokenMap[reserved];
    421421        if(nmtokenID == 0){
Note: See TracChangeset for help on using the changeset viewer.