Changeset 6663 for trunk/tools/database/StateUpd.cpp
- Timestamp:
- Sep 6, 2001, 5:07:32 AM (24 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/database/StateUpd.cpp
r6660 r6663 1 /* $Id: StateUpd.cpp,v 1.3 5 2001-09-05 23:14:12bird Exp $1 /* $Id: StateUpd.cpp,v 1.36 2001-09-06 03:07:31 bird Exp $ 2 2 * 3 3 * StateUpd - Scans source files for API functions and imports data on them. … … 65 65 inline char *trim(char *psz); 66 66 inline char *trimR(char *psz); 67 static char *trimHtml(char *psz); 67 68 inline char *skip(const char *psz); 68 69 static void copy(char *psz, char *pszFrom, int iFrom, char *pszTo, int iTo, char **papszLines); … … 827 828 unsigned long ulRc = 0; 828 829 char szBuffer[0x10000]; 829 char * psz ;830 char * pszTitle; 830 831 831 832 /* … … 835 836 * 836 837 */ 837 psz = stristr(papszLines[i], "@design"); 838 if (psz != NULL && (psz[7] == '\0' || psz[7] == ' ')) 839 { 838 pszTitle = stristr(papszLines[i], "@design"); 839 if (pszTitle != NULL && (pszTitle[7] == '\0' || pszTitle[7] == ' ')) 840 { 841 char * psz; 840 842 signed long lSeqNbr; 841 842 psz = findEndOfWord(psz+1)+1; 843 lSeqNbr = atol(psz); 843 signed long lSeqNbrNote; 844 signed long lRefCode; 845 long alSeqNbrs[1024]; 846 long lLevel; 847 848 memset(alSeqNbrs, 0, sizeof(alSeqNbrs)); 849 850 /* 851 * Get title and seqnbr. Then copy the entire stuff to the buffer. 852 */ 853 pszTitle = findEndOfWord(pszTitle+1)+1; 854 lSeqNbr = atol(pszTitle); 844 855 if (lSeqNbr != 0) 845 psz = findEndOfWord(psz);846 psz = trim(psz);847 if (psz != NULL && strstr(psz, "*/") != NULL)856 pszTitle = findEndOfWord(pszTitle); 857 pszTitle = trim(pszTitle); 858 if (pszTitle != NULL && strstr(pszTitle, "*/") != NULL) 848 859 { 849 860 szBuffer[0] = '\0'; 850 *strstr(psz , "*/") = '\0';861 *strstr(pszTitle, "*/") = '\0'; 851 862 } 852 863 else 853 864 copyComment(&szBuffer[0], 0, i+1, papszLines, TRUE, TRUE); 854 855 /* Update database */ 856 if (!dbAddDesignNote(pOptions->lDllRefcode, pOptions->lFileRefcode, psz, &szBuffer[0], lSeqNbr, pOptions->lSeqFile++, i + 1)) 857 { 858 ulRc = 0x00010000; 859 fprintf(phSignal, "%s(%d): Failed to add designnote. %s\n", dbGetLastErrorDesc()); 860 } 865 pszTitle = trim(pszTitle); 866 867 /* 868 * Add design note section by section. 869 */ 870 psz = &szBuffer[0]; 871 lLevel = 0; 872 lSeqNbrNote = 0; 873 do 874 { 875 char * pszEnd; 876 long lNextLevel = -1; 877 878 /* 879 * Parse out title and section/squence number if not lLevel 0. 880 * (psz = "@sub...") 881 */ 882 if (lLevel > 0) 883 { 884 pszTitle = findEndOfWord(psz+1); 885 lSeqNbr = atol(pszTitle); 886 if (lSeqNbr != 0) 887 { 888 pszTitle = findEndOfWord(pszTitle); 889 alSeqNbrs[lLevel] = lSeqNbr; 890 } 891 else 892 lSeqNbr = ++alSeqNbrs[lLevel]; 893 894 pszTitle = trim(pszTitle); 895 if (pszTitle != NULL && (psz = strstr(pszTitle, "\n")) != NULL) 896 *psz++ = '\0'; 897 else 898 psz = ""; 899 } 900 901 902 /* 903 * Find end of this section. 904 * (pszEnd will point at @sub or '\0'.) 905 */ 906 pszEnd = psz; 907 do 908 { 909 while (*pszEnd == '\n' || *pszEnd == ' ' || *pszEnd == '\t' || *pszEnd == '\r') 910 ++pszEnd; 911 if (!strnicmp(pszEnd, "@sub", 4) && !strnicmp(findEndOfWord(pszEnd + 1) - 7, "section", 7)) 912 { 913 lNextLevel = 1; 914 while (!strnicmp(pszEnd + 1 + lNextLevel * 3, "sub", 3)) 915 lNextLevel++; 916 break; 917 } 918 } while ((pszEnd = strchr(pszEnd, '\n')) != NULL); 919 if (!pszEnd) 920 pszEnd = psz + strlen(psz); 921 else 922 pszEnd[-1] = '\0'; 923 924 /* 925 * Strip end and start of section. 926 */ 927 psz = trimHtml(psz); 928 pszTitle = trimHtml(pszTitle); 929 930 /* 931 * Add the note. 932 */ 933 if (!dbAddDesignNote(pOptions->lDllRefcode, pOptions->lFileRefcode, 934 pszTitle, psz, 935 lLevel, lSeqNbr, lSeqNbrNote++, i + 1, lLevel > 0, &lRefCode)) 936 { 937 ulRc += 0x00010000; 938 fprintf(phSignal, "%s(%d): Failed to add designnote. %s\n", pszFilename, i, dbGetLastErrorDesc()); 939 } 940 941 /* 942 * Next. 943 */ 944 psz = pszEnd; 945 if (lLevel < lNextLevel) 946 memset(&alSeqNbrs[lLevel+1], 0, (lNextLevel - lLevel) * sizeof(alSeqNbrs[0])); 947 lLevel = lNextLevel; 948 949 } while (*psz); 950 861 951 862 952 /* Skip to line after comment end. */ … … 2457 2547 } 2458 2548 2549 /** 2550 * Trims string. <BR>, <P>, '@', '\t', '\n' and '\t' is trimmed from both ends of the string. 2551 * @returns Pointer to string. 2552 * @param psz String to trim. 2553 */ 2554 char *trimHtml(char *psz) 2555 { 2556 if (!psz) 2557 return NULL; 2558 2559 char *pszEnd = psz + strlen(psz) - 1; 2560 2561 while (pszEnd > psz) 2562 { 2563 if (*pszEnd == '@' || *pszEnd == ' ' || *pszEnd == '\t' || *pszEnd == '\n' || *pszEnd == '\r') 2564 pszEnd--; 2565 else if (!strnicmp(pszEnd - 3, "<BR>", 4)) 2566 pszEnd -= 4; 2567 else if (!strnicmp(pszEnd - 2, "<P>", 3)) 2568 pszEnd -= 3; 2569 else 2570 break; 2571 } 2572 *++pszEnd = '\0'; 2573 2574 while (psz < pszEnd) 2575 { 2576 if (*psz == '@' || *psz == ' ' || *psz == '\t' || *psz == '\n' || *psz == '\r') 2577 psz++; 2578 else if (!strnicmp(psz, "<BR>", 4)) 2579 psz += 4; 2580 else if (!strnicmp(psz, "<P>", 3)) 2581 psz += 3; 2582 else 2583 break; 2584 } 2585 2586 return psz; 2587 } 2588 2459 2589 2460 2590 /**
Note:
See TracChangeset
for help on using the changeset viewer.