VirtualBox

Changeset 15 in kBuild for trunk/doc


Ignore:
Timestamp:
Oct 16, 2002 11:09:44 PM (22 years ago)
Author:
bird
Message:

Some htmlifying.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/doc/docdesign.c

    r14 r15  
    8484            char   *pszEnd = &szLine[strlen(szLine) - 1];
    8585            /*
     86             * Strip off any ' ', '\t', '\n', '\r', '\*\/' and '*' from end
    8687             * Strip off any ' ', '\t', '\/\*', '*' and '//' from start.
    87              * Strip off any ' ', '\t', '\n', '\r', '\*\/' and '*' from end
    8888             * Need to check for closing comment too.
    8989             */
    90             while (   *psz == '*'
    91                    || *psz == ' '
    92                    || *psz == '\t'
    93                    || (*psz == '/' && (psz[1] == '*' || psz[1] == '/')))
    94             {
    95                 if (*psz++ == '/')
    96                     psz++;
    97             }
    98 
    9990            while (     pszEnd >= psz
    10091                   && (   *pszEnd == '*'
     
    120111                    )
    121112            {
    122                 if (*pszEnd != '/')
    123                     pszEnd--;
     113                if (*pszEnd == '/')
     114                    *pszEnd-- = '\0';
    124115                *pszEnd-- = '\0';
     116            }
     117
     118            while (   *psz == '*'
     119                   || *psz == ' '
     120                   || *psz == '\t'
     121                   || (*psz == '/' && (psz[1] == '*' || psz[1] == '/')))
     122            {
     123                if (*psz++ == '/')
     124                    psz++;
    125125            }
    126126
     
    220220
    221221/**
     222 * Checks if psz is point to a tag we pass thru.
     223 * @returns length of tag if pass thru tag.
     224 * @returns 0 if not.
     225 * @param   psz     Pointer to text string.
     226 */
     227int isTag(const char *psz)
     228{
     229    int     i;
     230    static char *  apszTags[] =
     231    {
     232        "<b>",  "</b>",
     233        "<i>",  "</i>",
     234        "<ul>",  "</ul>",
     235        "<ol>",  "</ol>",
     236        "<pre>", "</pre>",
     237        "<h1>",  "</h1>",
     238        "<h2>",  "</h2>",
     239        "<h3>",  "</h3>",
     240        "<h4>",  "</h4>",
     241        "<h5>",  "</h5>",
     242        "<h6>",  "</h6>",
     243        "<li>",
     244        "<p>",
     245        "<br>"
     246    };
     247
     248    if (*psz == '<')
     249    {
     250        for (i = 0; i < sizeof(apszTags) / sizeof(apszTags[0]); i++)
     251        {
     252            int cch = strlen(apszTags[i]);
     253            if (!strnicmp(apszTags[i], psz, cch))
     254                return cch;
     255        }
     256    }
     257
     258    return 0;
     259}
     260
     261
     262/**
     263 * HTMLify text and print it.
     264 * @param   pszText     Text in question.
     265 */
     266void PutHtmlText(const char *pszText)
     267{
     268    while (*pszText)
     269    {
     270        char ch = *pszText;
     271        char sz[256];
     272        sz[0] = '\0';
     273        switch (ch)
     274        {
     275            case '<':
     276            {
     277                int cch = isTag(pszText);
     278                if (cch)
     279                {
     280                    strncat(sz, pszText, cch);
     281                    pszText += cch - 1;
     282                }
     283                else
     284                    strcpy(sz, "&lt;");
     285                break;
     286            }
     287
     288            case '>':
     289                strcpy(sz, "&gt;");
     290                break;
     291
     292            case '&':
     293                strcpy(sz, "&amp;");
     294                break;
     295
     296            default:
     297                sz[0] = ch;
     298                sz[1] = '\0';
     299        }
     300        printf("%s", sz);
     301        pszText++;
     302    }
     303}
     304
     305
     306/**
    222307 * Keep track and formats section level.
    223308 */
     
    262347    printf("<!-- Generate by docdesign -->\n"
    263348           "<head>\n"
    264            "<title></title>\n"
     349           "<title>Design Document</title>\n"
    265350           "\n"
    266351           "<body>\n"
     
    293378        printf("<p><br><p>\n"
    294379               "<a href=#content><a name=%s><h%d>%s %s</h%d></a></a>\n"
    295                "\n"
    296                "%s",
    297                szSection, iHNumber, szSection, pCurSection->pszHeader, iHNumber,
    298                pCurSection->pszText);
     380               "\n",
     381               szSection, iHNumber, szSection, pCurSection->pszHeader, iHNumber);
     382        if (pCurSection->pszText)
     383            PutHtmlText(pCurSection->pszText);
    299384    }
    300385    printf("</ul>\n"
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette