- Timestamp:
- Oct 16, 2002 11:09:44 PM (22 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/doc/docdesign.c
r14 r15 84 84 char *pszEnd = &szLine[strlen(szLine) - 1]; 85 85 /* 86 * Strip off any ' ', '\t', '\n', '\r', '\*\/' and '*' from end 86 87 * Strip off any ' ', '\t', '\/\*', '*' and '//' from start. 87 * Strip off any ' ', '\t', '\n', '\r', '\*\/' and '*' from end88 88 * Need to check for closing comment too. 89 89 */ 90 while ( *psz == '*'91 || *psz == ' '92 || *psz == '\t'93 || (*psz == '/' && (psz[1] == '*' || psz[1] == '/')))94 {95 if (*psz++ == '/')96 psz++;97 }98 99 90 while ( pszEnd >= psz 100 91 && ( *pszEnd == '*' … … 120 111 ) 121 112 { 122 if (*pszEnd != '/')123 pszEnd--;113 if (*pszEnd == '/') 114 *pszEnd-- = '\0'; 124 115 *pszEnd-- = '\0'; 116 } 117 118 while ( *psz == '*' 119 || *psz == ' ' 120 || *psz == '\t' 121 || (*psz == '/' && (psz[1] == '*' || psz[1] == '/'))) 122 { 123 if (*psz++ == '/') 124 psz++; 125 125 } 126 126 … … 220 220 221 221 /** 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 */ 227 int 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 */ 266 void 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, "<"); 285 break; 286 } 287 288 case '>': 289 strcpy(sz, ">"); 290 break; 291 292 case '&': 293 strcpy(sz, "&"); 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 /** 222 307 * Keep track and formats section level. 223 308 */ … … 262 347 printf("<!-- Generate by docdesign -->\n" 263 348 "<head>\n" 264 "<title> </title>\n"349 "<title>Design Document</title>\n" 265 350 "\n" 266 351 "<body>\n" … … 293 378 printf("<p><br><p>\n" 294 379 "<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 380 "\n", 381 szSection, iHNumber, szSection, pCurSection->pszHeader, iHNumber); 382 if (pCurSection->pszText) 383 PutHtmlText(pCurSection->pszText); 299 384 } 300 385 printf("</ul>\n"
Note:
See TracChangeset
for help on using the changeset viewer.