void DwHeaders::Assemble() { if (!mIsModified) return; mString = ""; DwField* field = FirstField(); while (field) { field->Assemble(); mString += field->AsString(); field = field->Next(); } mString += DW_EOL; mIsModified = 0; }
/** * Reads a property file. * * There are several property files, this code can read all * of those but will only make use of the properties it recognizes. * * @returns 0 on success. * @returns !0 on failure. * @param pszBasePath The base path, can be NULL. * @param pszFilename The name of the file. */ static int ReadProperties(const char *pszBasePath, const char *pszFilename) { /* * Open input. */ FILE *pFile = OpenFile(pszBasePath, pszFilename); if (!pFile) return 1; /* * Parse the input and spit out the output. */ char szLine[4096]; while (GetLineFromFile(szLine, sizeof(szLine), pFile) != NULL) { if (IsCommentOrBlankLine(szLine)) continue; char *pszCurField; char *pszRange = FirstField(&pszCurField, StripLine(szLine)); char *pszProperty = NextField(&pszCurField); if (!*pszProperty) { ParseError("no property field.\n"); continue; } RTUNICP LastCP; RTUNICP StartCP = ToRange(pszRange, &LastCP); if (StartCP == ~(RTUNICP)0) continue; while (StartCP <= LastCP) ApplyProperty(StartCP++, pszProperty, pszCurField); } CloseFile(pFile); return 0; }
/** * Read the UnicodeData.txt file. * @returns 0 on success. * @returns !0 on failure. * @param pszBasePath The base path, can be NULL. * @param pszFilename The name of the file. */ static int ReadUnicodeData(const char *pszBasePath, const char *pszFilename) { /* * Open input. */ FILE *pFile = OpenFile(pszBasePath, pszFilename); if (!pFile) return 1; /* * Parse the input and spit out the output. */ char szLine[4096]; RTUNICP i = 0; while (GetLineFromFile(szLine, sizeof(szLine), pFile) != NULL) { if (IsCommentOrBlankLine(szLine)) continue; char *pszCurField; char *pszCodePoint = FirstField(&pszCurField, StripLine(szLine)); /* 0 */ char *pszName = NextField(&pszCurField); /* 1 */ char *pszGeneralCategory = NextField(&pszCurField); /* 2 */ char *pszCanonicalCombiningClass = NextField(&pszCurField); /* 3 */ char *pszBidiClass = NextField(&pszCurField); /* 4 */ char *pszDecompositionType = NextField(&pszCurField); /* 5 */ char *pszDecompositionMapping = SplitDecompField(&pszDecompositionType); char *pszNumericType = NextField(&pszCurField); /* 6 */ char *pszNumericValueD = NextField(&pszCurField); /* 7 */ char *pszNumericValueN = NextField(&pszCurField); /* 8 */ char *pszBidiMirrored = NextField(&pszCurField); /* 9 */ char *pszUnicode1Name = NextField(&pszCurField); /* 10 */ char *pszISOComment = NextField(&pszCurField); /* 11 */ char *pszSimpleUpperCaseMapping = NextField(&pszCurField); /* 12 */ char *pszSimpleLowerCaseMapping = NextField(&pszCurField); /* 13 */ char *pszSimpleTitleCaseMapping = NextField(&pszCurField); /* 14 */ RTUNICP CodePoint = ToNum(pszCodePoint); if (CodePoint >= RT_ELEMENTS(g_aCPInfo)) { ParseError("U+05X is out of range\n", CodePoint); continue; } /* catchup? */ while (i < CodePoint) NullEntry(i++); if (i != CodePoint) { ParseError("i=%d CodePoint=%u\n", i, CodePoint); CloseFile(pFile); return 1; } /* this one */ g_aCPInfo[i].CodePoint = i; g_aCPInfo[i].fNullEntry = 0; g_aCPInfo[i].pszName = DupStr(pszName); g_aCPInfo[i].SimpleUpperCaseMapping = ToNumDefault(pszSimpleUpperCaseMapping, CodePoint); g_aCPInfo[i].SimpleLowerCaseMapping = ToNumDefault(pszSimpleLowerCaseMapping, CodePoint); g_aCPInfo[i].SimpleTitleCaseMapping = ToNumDefault(pszSimpleTitleCaseMapping, CodePoint); g_aCPInfo[i].CanonicalCombiningClass = ToNum(pszCanonicalCombiningClass); g_aCPInfo[i].pszDecompositionType = DupStr(pszDecompositionType); g_aCPInfo[i].paDecompositionMapping = ToMapping(pszDecompositionMapping, &g_aCPInfo[i].cDecompositionMapping, 20); g_aCPInfo[i].pszGeneralCategory = DupStr(pszGeneralCategory); g_aCPInfo[i].pszBidiClass = DupStr(pszBidiClass); g_aCPInfo[i].pszNumericType = DupStr(pszNumericType); g_aCPInfo[i].pszNumericValueD = DupStr(pszNumericValueD); g_aCPInfo[i].pszNumericValueN = DupStr(pszNumericValueN); g_aCPInfo[i].pszBidiMirrored = DupStr(pszBidiMirrored); g_aCPInfo[i].pszUnicode1Name = DupStr(pszUnicode1Name); g_aCPInfo[i].pszISOComment = DupStr(pszISOComment); i++; } /* catchup? */ while (i < RT_ELEMENTS(g_aCPInfo)) NullEntry(i++); CloseFile(pFile); return 0; }
/** * Get the next field in a field enumeration. * * @returns Pointer to the next field. * @param ppsz Where to get and store the string position. */ static char *NextField(char **ppsz) { return FirstField(ppsz, *ppsz); }