Changeset 1409


Ignore:
Timestamp:
Apr 30, 2004, 10:39:38 AM (21 years ago)
Author:
bird
Message:

Fixed problem with GCC 3.3.3 and nextcolon().

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/emx/src/emxomf/stabshll.c

    • Property cvs2svn:cvs-rev changed from 1.31 to 1.32
    r1408 r1409  
    1919the Free Software Foundation, 59 Temple Place - Suite 330,
    2020Boston, MA 02111-1307, USA.  */
    21 
     21//#define HLL_DEBUG 1
    2222
    2323/*******************************************************************************
     
    3030#include <time.h>
    3131#include <alloca.h>
     32#include <ctype.h>
    3233#include "defs.h"
    3334#include "emxomf.h"
     
    407408    {
    408409      if (parse_pindex && *parse_pindex >= 0 && *parse_pindex < sym_count)
    409         fprintf (stderr, "emxomf info: parsing sym no.%d type=%d at char '%c' in position %ld:\n%s\n",
     410        fprintf (stderr, "emxomf info: parsing sym no.%d type=%d at char '%c' in position %d:\n%s\n",
    410411                 *parse_pindex, sym_ptr[*parse_pindex].n_type,
    411412                 *parse_ptr, parse_ptr - parse_start, parse_start);
    412413      else
    413         fprintf (stderr, "emxomf info: parsing '%c' at position %ld:\n%s\n",
     414        fprintf (stderr, "emxomf info: parsing '%c' at position %d:\n%s\n",
    414415                 *parse_ptr, parse_ptr - parse_start, parse_start);
    415416    }
     
    15561557 * @returns Pointer to next colon within psz.
    15571558 * @returns NULL if not found.
    1558  * @param   psz     String to search.
     1559 * @param   pszString   String to search.
     1560 * @param   chType      Type we're parsing. Use '\0' if unknown or it
     1561 *                      should be ignored
     1562 * @remark  Still a bad hack this.
    15591563 */
    1560 static const char *nextcolon(const char *psz)
    1561 {
    1562   int cNesting = 0;                     /* <> level */
    1563 
    1564   for (;;psz++)
    1565     switch (*psz)
    1566       {
    1567         case '<':
    1568           if (psz[1] == ':')
    1569             return psz + 1;
    1570           if (psz[1] == '<')            /* hack for operators. */
     1564#ifdef COLON_DEBUG
     1565static const char *nextcolon2(const char *pszString, char chType)
     1566{
     1567    static const char *_nextcolon2(const char *pszString, char chType);
     1568    const char *psz = _nextcolon2(pszString, chType);
     1569    fprintf(stderr, "COLON: %.100s\n%.32s\n", pszString, psz);
     1570    return psz;
     1571}
     1572static const char *_nextcolon2(const char *pszString, char chType)
     1573#else
     1574static const char *nextcolon2(const char *pszString, char chType)
     1575#endif
     1576{
     1577    const char *pszColon;
     1578    const char *psz;
     1579
     1580    /* permanent operator hack */
     1581    if (    pszString[0] == 'o'
     1582        &&  pszString[1] == 'p'
     1583        &&  pszString[2] == 'e'
     1584        &&  pszString[3] == 'r'
     1585        &&  pszString[4] == 'a'
     1586        &&  pszString[5] == 't'
     1587        &&  pszString[6] == 'o'
     1588        &&  pszString[7] == 'r')
     1589    {
     1590        psz = pszString + 8;
     1591        while (*psz && !isalnum(*psz) && *psz != '_') /* potential operator chars */
     1592        {
     1593            if (*psz == ':')
    15711594            {
    1572               psz++;
    1573               break;
     1595                if (    psz - pszString >= 1 + 8
     1596                    &&  psz - pszString <= 3 + 8)
     1597                    return psz;
     1598                break;
    15741599            }
    1575           cNesting++;
    1576           break;
    1577         case '>':
    1578           if (psz[1] == ':')
    1579             return psz + 1;
    1580           if (psz[1] == '>')            /* hack for operators. */
     1600            psz++;
     1601        }
     1602
     1603    }
     1604
     1605    /* normal life */
     1606    pszColon = strchr(pszString, ':');
     1607    if (!pszColon)
     1608        return NULL;
     1609    psz = strchr(pszString, '<');
     1610
     1611    if (psz && psz < pszColon && pszColon[1] == ':')
     1612    {
     1613        int   cNesting = 0;             /* <> level */
     1614
     1615        for (;;psz++)
     1616        {
     1617            switch (*psz)
    15811618            {
    1582               psz++;
    1583               break;
     1619                case '<':   cNesting++; break;
     1620                case '>':   cNesting--; break;
     1621                case ':':
     1622                    if (cNesting > 0)
     1623                        break;
     1624                    /* hack: continue on ">::" (but not on "operator...") */
     1625                    if (    psz[1] == ':'
     1626                        &&  psz > pszString && psz[-1] == '>'
     1627                            )
     1628                    {
     1629                        psz++;
     1630                        break;
     1631                    }
     1632                    return psz;
     1633                case '\0':
     1634                    return NULL;
    15841635            }
    1585           cNesting--;
    1586           break;
    1587         case ':':
    1588           if (cNesting <= 0)
    1589             return psz;
    1590           break;
    1591         case '\0':
    1592           return NULL;
    1593       }
    1594   return NULL;
    1595 }
     1636        }
     1637    }
     1638    else
     1639    {
     1640        if (chType != 'x')
     1641        {
     1642            /* skip '::' (hack:) if not followed by number. */
     1643            while (*pszColon && pszColon[1] == ':' && (pszColon[2] > '9' || pszColon[2] < '0'))
     1644            {
     1645                pszColon += 2;
     1646                while (*pszColon != ':' && *pszColon)
     1647                    pszColon++;
     1648            }
     1649        }
     1650    }
     1651
     1652    return pszColon;
     1653}
     1654
     1655/* old version */
     1656static inline const char *nextcolon(const char *pszString)
     1657{
     1658    return nextcolon2(pszString, '\0');
     1659}
     1660
    15961661
    15971662
     
    16211686      if (!parse_number (&num1))
    16221687        goto syntax;
     1688
    16231689      /* Special case: self reference => void */
    16241690      is_void = FALSE;
     
    19682034      ++parse_ptr;
    19692035      ch = *parse_ptr++;
    1970       p1 = nextcolon (parse_ptr);
     2036      p1 = nextcolon2 (parse_ptr, 'x');
    19712037      if (p1 == NULL)
    19722038        {
Note: See TracChangeset for help on using the changeset viewer.