Index: src/wp/impexp/cocoa/ie_impGraphic_Cocoa.mm =================================================================== RCS file: /cvsroot/abi/src/wp/impexp/cocoa/ie_impGraphic_Cocoa.mm,v retrieving revision 1.6 diff -u -r1.6 ie_impGraphic_Cocoa.mm --- src/wp/impexp/cocoa/ie_impGraphic_Cocoa.mm 16 Jan 2007 23:17:03 -0000 1.6 +++ src/wp/impexp/cocoa/ie_impGraphic_Cocoa.mm 17 Jan 2007 02:07:20 -0000 @@ -45,13 +45,12 @@ int idx = 0; while((aType = [suffixIter nextObject]) != nil) { - suffixConfidence[idx].suffix = g_strdup([aType UTF8String]); + suffixConfidence[idx].suffix = [aType UTF8String]; suffixConfidence[idx].confidence = UT_CONFIDENCE_PERFECT; idx++; } // NULL-terminator - suffixConfidence[idx].suffix = NULL; suffixConfidence[idx].confidence = UT_CONFIDENCE_ZILCH; } @@ -60,35 +59,12 @@ const IE_MimeConfidence * IE_ImpGraphicCocoa_Sniffer::getMimeConfidence() { - static IE_MimeConfidence *mimeConfidence = NULL; - - if (mimeConfidence) { - return mimeConfidence; - } - - mimeConfidence = new IE_MimeConfidence[4]; - - // FIXME this shouldn't be hardcoded - int idx = 0; - mimeConfidence[idx].match = IE_MIME_MATCH_FULL; - mimeConfidence[idx].mimetype = "image/png"; - mimeConfidence[idx].confidence = UT_CONFIDENCE_PERFECT; - idx++; - - mimeConfidence[idx].match = IE_MIME_MATCH_FULL; - mimeConfidence[idx].mimetype = "image/jpeg"; - mimeConfidence[idx].confidence = UT_CONFIDENCE_PERFECT; - idx++; - - mimeConfidence[idx].match = IE_MIME_MATCH_FULL; - mimeConfidence[idx].mimetype = "image/tiff"; - mimeConfidence[idx].confidence = UT_CONFIDENCE_PERFECT; - idx++; - - // null-terminator - mimeConfidence[idx].match = IE_MIME_MATCH_BOGUS; - mimeConfidence[idx].mimetype = NULL; - mimeConfidence[idx].confidence = UT_CONFIDENCE_ZILCH; + static IE_MimeConfidence *mimeConfidence = { + { IE_MIME_MATCH_FULL, "image/png", UT_CONFIDENCE_PERFECT }, + { IE_MIME_MATCH_FULL, "image/jpeg", UT_CONFIDENCE_PERFECT }, + { IE_MIME_MATCH_FULL, "image/tiff", UT_CONFIDENCE_PERFECT }, + { IE_MIME_MATCH_BOGUS,"", UT_CONFIDENCE_ZILCH } + }; return mimeConfidence; } Index: src/wp/impexp/unix/ie_impGraphic_GdkPixbuf.cpp =================================================================== RCS file: /cvsroot/abi/src/wp/impexp/unix/ie_impGraphic_GdkPixbuf.cpp,v retrieving revision 1.12 diff -u -r1.12 ie_impGraphic_GdkPixbuf.cpp --- src/wp/impexp/unix/ie_impGraphic_GdkPixbuf.cpp 16 Jan 2007 23:17:04 -0000 1.12 +++ src/wp/impexp/unix/ie_impGraphic_GdkPixbuf.cpp 17 Jan 2007 02:07:21 -0000 @@ -572,48 +572,42 @@ GSList *formatList = gdk_pixbuf_get_formats (); GSList *formatIter; - GSList *tmp; GdkPixbufFormat *format; - gchar **mime_types; - gsize n_mime_types; gsize idx; + std::vector all_mime_types; // dry run to count entries formatIter = formatList; - n_mime_types = 0; while (formatIter) { + gchar **mime_types; format = (GdkPixbufFormat *) formatIter->data; mime_types = gdk_pixbuf_format_get_mime_types (format); - while (*mime_types) { - n_mime_types++; - mime_types++; + gchar **tmp = mime_types; + while (*tmp) { + all_mime_types.push_back(*tmp); + tmp++; } + g_strfreev(mime_types); + + GSList *node; + node = formatIter; formatIter = formatIter->next; + g_slist_free1 (node); } - mimeConfidence = new IE_MimeConfidence[n_mime_types + 1]; - - // build list - formatIter = formatList; + mimeConfidence = new IE_MimeConfidence[all_mime_types.size() + 1]; idx = 0; - while (formatIter) { - format = (GdkPixbufFormat *) formatIter->data; - mime_types = gdk_pixbuf_format_get_mime_types (format); - while (*mime_types) { - mimeConfidence[idx].match = IE_MIME_MATCH_FULL; - mimeConfidence[idx].mimetype = *mime_types; - mimeConfidence[idx].confidence = UT_CONFIDENCE_PERFECT; - idx++; - mime_types++; - } - tmp = formatIter; - formatIter = formatIter->next; - g_slist_free1 (tmp); + for(std::vector::iterator iter = all_mime_types.begin(); + iter != all_mime_types.end(); ++iter) + { + mimeConfidence[idx].match = IE_MIME_MATCH_FULL; + mimeConfidence[idx].mimetype = *iter; + mimeConfidence[idx].confidence = UT_CONFIDENCE_PERFECT; + idx++; } // null-terminator mimeConfidence[idx].match = IE_MIME_MATCH_BOGUS; - mimeConfidence[idx].mimetype = NULL; mimeConfidence[idx].confidence = UT_CONFIDENCE_ZILCH; return mimeConfidence; @@ -643,7 +637,6 @@ } // NULL-terminator - suffixConfidence[idx].suffix = NULL; suffixConfidence[idx].confidence = UT_CONFIDENCE_ZILCH; return suffixConfidence; Index: src/wp/impexp/xp/ie_imp.cpp =================================================================== RCS file: /cvsroot/abi/src/wp/impexp/xp/ie_imp.cpp,v retrieving revision 1.101 diff -u -r1.101 ie_imp.cpp --- src/wp/impexp/xp/ie_imp.cpp 16 Jan 2007 23:17:06 -0000 1.101 +++ src/wp/impexp/xp/ie_imp.cpp 17 Jan 2007 02:07:21 -0000 @@ -353,7 +353,7 @@ const IE_SuffixConfidence *sc; for (guint i = 0; i < IE_IMP_Sniffers.size(); i++) { sc = IE_IMP_Sniffers.getNthItem(i)->getSuffixConfidence(); - while (sc && sc->suffix) { + while (sc && !sc->suffix.empty()) { IE_IMP_Suffixes.push_back(sc->suffix); sc++; } @@ -376,11 +376,11 @@ for (guint i = 0; i < IE_IMP_Sniffers.size(); i++) { IE_ImpSniffer *sniffer = IE_IMP_Sniffers.getNthItem(i); sc = sniffer->getSuffixConfidence(); - while (sc && sc->suffix) { - if (0 == UT_stricmp(suffix, sc->suffix)) { + while (sc && !sc->suffix.empty()) { + if (0 == UT_stricmp(suffix, sc->suffix.c_str())) { const IE_MimeConfidence *mc = sniffer->getMimeConfidence(); if (mc) { - return mc->mimetype; + return mc->mimetype.c_str(); } else { return NULL; @@ -462,9 +462,9 @@ IE_ImpSniffer * s = IE_IMP_Sniffers.getNthItem(k); const IE_SuffixConfidence * sc = s->getSuffixConfidence(); UT_Confidence_t confidence = UT_CONFIDENCE_ZILCH; - while (sc && sc->suffix) { + while (sc && !sc->suffix.empty()) { /* suffixes do not have a leading '.' */ - if (0 == UT_stricmp(sc->suffix, szSuffix+1) && + if (0 == UT_stricmp(sc->suffix.c_str(), szSuffix+1) && sc->confidence > confidence) { confidence = sc->confidence; } @@ -520,7 +520,7 @@ UT_Confidence_t confidence = UT_CONFIDENCE_ZILCH; while (mc && mc->match) { if (mc->match == IE_MIME_MATCH_FULL) { - if (0 == UT_stricmp(mc->mimetype, szMimetype) && + if (0 == UT_stricmp(mc->mimetype.c_str(), szMimetype) && mc->confidence > confidence) { confidence = mc->confidence; } @@ -807,9 +807,9 @@ const char * suffix = UT_pathSuffix(gsf_input_name (input)) ; if (suffix) { const IE_SuffixConfidence * sc = s->getSuffixConfidence(); - while (sc && sc->suffix) { + while (sc && !sc->suffix.empty()) { /* suffixes do not have a leading '.' */ - if (0 == UT_stricmp(sc->suffix, suffix+1) && + if (0 == UT_stricmp(sc->suffix.c_str(), suffix+1) && sc->confidence > suffix_confidence) { suffix_confidence = sc->confidence; } Index: src/wp/impexp/xp/ie_impGraphic.cpp =================================================================== RCS file: /cvsroot/abi/src/wp/impexp/xp/ie_impGraphic.cpp,v retrieving revision 1.34 diff -u -r1.34 ie_impGraphic.cpp --- src/wp/impexp/xp/ie_impGraphic.cpp 16 Jan 2007 23:17:06 -0000 1.34 +++ src/wp/impexp/xp/ie_impGraphic.cpp 17 Jan 2007 02:07:21 -0000 @@ -151,7 +151,7 @@ const IE_SuffixConfidence *sc; for (guint i = 0; i < IE_IMP_GraphicSniffers.size(); i++) { sc = IE_IMP_GraphicSniffers.getNthItem(i)->getSuffixConfidence(); - while (sc && sc->suffix) { + while (sc && !sc->suffix.empty()) { IE_IMP_GraphicSuffixes.push_back(sc->suffix); sc++; } @@ -174,11 +174,11 @@ for (guint i = 0; i < IE_IMP_GraphicSniffers.size(); i++) { IE_ImpGraphicSniffer *sniffer = IE_IMP_GraphicSniffers.getNthItem(i); sc = sniffer->getSuffixConfidence(); - while (sc && sc->suffix) { - if (0 == UT_stricmp(suffix, sc->suffix)) { + while (sc && !sc->suffix.empty()) { + if (0 == UT_stricmp(suffix, sc->suffix.c_str())) { const IE_MimeConfidence *mc = sniffer->getMimeConfidence(); if (mc) { - return mc->mimetype; + return mc->mimetype.c_str(); } else { return NULL; @@ -215,7 +215,7 @@ UT_Confidence_t confidence = UT_CONFIDENCE_ZILCH; while (mc && mc->match) { if (mc->match == IE_MIME_MATCH_FULL) { - if (0 == UT_stricmp(mc->mimetype, szMimetype) && + if (0 == UT_stricmp(mc->mimetype.c_str(), szMimetype) && mc->confidence > confidence) { confidence = mc->confidence; } @@ -263,9 +263,9 @@ const IE_SuffixConfidence * sc = s->getSuffixConfidence(); UT_Confidence_t confidence = UT_CONFIDENCE_ZILCH; - while (sc && sc->suffix) { + while (sc && !sc->suffix.empty()) { /* suffixes do not have a leading '.' */ - if (0 == UT_stricmp(sc->suffix, szSuffix+1) && + if (0 == UT_stricmp(sc->suffix.c_str(), szSuffix+1) && sc->confidence > confidence) { confidence = sc->confidence; } @@ -475,9 +475,9 @@ const char * suffix = UT_pathSuffix(gsf_input_name (input)); if (suffix) { const IE_SuffixConfidence * sc = s->getSuffixConfidence(); - while (sc && sc->suffix) { + while (sc && !sc->suffix.empty()) { /* suffixes do not have a leading '.' */ - if (0 == UT_stricmp(sc->suffix, suffix+1) && + if (0 == UT_stricmp(sc->suffix.c_str(), suffix+1) && sc->confidence > suffix_confidence) { suffix_confidence = sc->confidence; } Index: src/wp/impexp/xp/ie_impGraphic_PNG.cpp =================================================================== RCS file: /cvsroot/abi/src/wp/impexp/xp/ie_impGraphic_PNG.cpp,v retrieving revision 1.15 diff -u -r1.15 ie_impGraphic_PNG.cpp --- src/wp/impexp/xp/ie_impGraphic_PNG.cpp 16 Jan 2007 23:17:06 -0000 1.15 +++ src/wp/impexp/xp/ie_impGraphic_PNG.cpp 17 Jan 2007 02:07:21 -0000 @@ -28,7 +28,7 @@ // supported suffixes static IE_SuffixConfidence IE_ImpGraphicPNG_Sniffer__SuffixConfidence[] = { { "png", UT_CONFIDENCE_PERFECT }, - { NULL, UT_CONFIDENCE_ZILCH } + { "", UT_CONFIDENCE_ZILCH } }; const IE_SuffixConfidence * IE_ImpGraphicPNG_Sniffer::getSuffixConfidence () @@ -39,7 +39,7 @@ // supported mimetypes static IE_MimeConfidence IE_ImpGraphicPNG_Sniffer__MimeConfidence[] = { { IE_MIME_MATCH_FULL, "image/png", UT_CONFIDENCE_GOOD }, - { IE_MIME_MATCH_BOGUS, NULL, UT_CONFIDENCE_ZILCH } + { IE_MIME_MATCH_BOGUS, "", UT_CONFIDENCE_ZILCH } }; const IE_MimeConfidence * IE_ImpGraphicPNG_Sniffer::getMimeConfidence () Index: src/wp/impexp/xp/ie_impGraphic_SVG.cpp =================================================================== RCS file: /cvsroot/abi/src/wp/impexp/xp/ie_impGraphic_SVG.cpp,v retrieving revision 1.13 diff -u -r1.13 ie_impGraphic_SVG.cpp --- src/wp/impexp/xp/ie_impGraphic_SVG.cpp 16 Jan 2007 23:17:06 -0000 1.13 +++ src/wp/impexp/xp/ie_impGraphic_SVG.cpp 17 Jan 2007 02:07:21 -0000 @@ -28,7 +28,7 @@ // supported suffixes static IE_SuffixConfidence IE_ImpGraphicSVG_Sniffer__SuffixConfidence[] = { { "svg", UT_CONFIDENCE_PERFECT }, - { NULL, UT_CONFIDENCE_ZILCH } + { "", UT_CONFIDENCE_ZILCH } }; const IE_SuffixConfidence * IE_ImpGraphicSVG_Sniffer::getSuffixConfidence () Index: src/wp/impexp/xp/ie_imp_AbiWord_1.cpp =================================================================== RCS file: /cvsroot/abi/src/wp/impexp/xp/ie_imp_AbiWord_1.cpp,v retrieving revision 1.156 diff -u -r1.156 ie_imp_AbiWord_1.cpp --- src/wp/impexp/xp/ie_imp_AbiWord_1.cpp 16 Jan 2007 23:17:06 -0000 1.156 +++ src/wp/impexp/xp/ie_imp_AbiWord_1.cpp 17 Jan 2007 02:07:21 -0000 @@ -85,7 +85,7 @@ { "abw.gz", UT_CONFIDENCE_PERFECT }, { "bzabw", UT_CONFIDENCE_PERFECT }, { "abw.bz2", UT_CONFIDENCE_PERFECT }, - { NULL, UT_CONFIDENCE_ZILCH } + { "", UT_CONFIDENCE_ZILCH } }; const IE_SuffixConfidence * IE_Imp_AbiWord_1_Sniffer::getSuffixConfidence () @@ -103,7 +103,7 @@ { IE_MIME_MATCH_FULL, "text/abiword", UT_CONFIDENCE_GOOD }, { IE_MIME_MATCH_FULL, "text/x-abiword", UT_CONFIDENCE_GOOD }, { IE_MIME_MATCH_FULL, "application/abiword-compressed", UT_CONFIDENCE_POOR }, - { IE_MIME_MATCH_BOGUS, NULL, UT_CONFIDENCE_ZILCH } + { IE_MIME_MATCH_BOGUS, "", UT_CONFIDENCE_ZILCH } }; const IE_MimeConfidence * IE_Imp_AbiWord_1_Sniffer::getMimeConfidence () Index: src/wp/impexp/xp/ie_imp_MsWord_97.cpp =================================================================== RCS file: /cvsroot/abi/src/wp/impexp/xp/ie_imp_MsWord_97.cpp,v retrieving revision 1.360 diff -u -r1.360 ie_imp_MsWord_97.cpp --- src/wp/impexp/xp/ie_imp_MsWord_97.cpp 16 Jan 2007 23:17:06 -0000 1.360 +++ src/wp/impexp/xp/ie_imp_MsWord_97.cpp 17 Jan 2007 02:07:22 -0000 @@ -664,7 +664,7 @@ static IE_SuffixConfidence IE_Imp_MsWord_97_Sniffer__SuffixConfidence[] = { { "doc", UT_CONFIDENCE_PERFECT }, { "dot", UT_CONFIDENCE_PERFECT }, - { NULL, UT_CONFIDENCE_ZILCH } + { "", UT_CONFIDENCE_ZILCH } }; const IE_SuffixConfidence * IE_Imp_MsWord_97_Sniffer::getSuffixConfidence () @@ -677,7 +677,7 @@ { IE_MIME_MATCH_FULL, IE_MIMETYPE_MSWord, UT_CONFIDENCE_GOOD }, { IE_MIME_MATCH_FULL, "application/vnd.ms-word", UT_CONFIDENCE_GOOD }, { IE_MIME_MATCH_FULL, "text/doc", UT_CONFIDENCE_GOOD }, // or is it? [TODO: check!] - { IE_MIME_MATCH_BOGUS, NULL, UT_CONFIDENCE_ZILCH } + { IE_MIME_MATCH_BOGUS, "", UT_CONFIDENCE_ZILCH } }; const IE_MimeConfidence * IE_Imp_MsWord_97_Sniffer::getMimeConfidence () Index: src/wp/impexp/xp/ie_imp_RTF.cpp =================================================================== RCS file: /cvsroot/abi/src/wp/impexp/xp/ie_imp_RTF.cpp,v retrieving revision 1.412 diff -u -r1.412 ie_imp_RTF.cpp --- src/wp/impexp/xp/ie_imp_RTF.cpp 16 Jan 2007 23:17:07 -0000 1.412 +++ src/wp/impexp/xp/ie_imp_RTF.cpp 17 Jan 2007 02:07:22 -0000 @@ -111,7 +111,7 @@ static IE_SuffixConfidence IE_Imp_RTF_Sniffer__SuffixConfidence[] = { { "rtf", UT_CONFIDENCE_PERFECT }, { "doc", UT_CONFIDENCE_SOSO }, - { NULL, UT_CONFIDENCE_ZILCH } + { "", UT_CONFIDENCE_ZILCH } }; const IE_SuffixConfidence * IE_Imp_RTF_Sniffer::getSuffixConfidence () @@ -126,7 +126,7 @@ { IE_MIME_MATCH_FULL, "application/richtext", UT_CONFIDENCE_GOOD }, { IE_MIME_MATCH_FULL, "text/richtext", UT_CONFIDENCE_GOOD }, { IE_MIME_MATCH_FULL, "text/rtf", UT_CONFIDENCE_GOOD }, - { IE_MIME_MATCH_BOGUS, NULL, UT_CONFIDENCE_ZILCH } + { IE_MIME_MATCH_BOGUS, "", UT_CONFIDENCE_ZILCH } }; const IE_MimeConfidence * IE_Imp_RTF_Sniffer::getMimeConfidence () Index: src/wp/impexp/xp/ie_imp_Text.cpp =================================================================== RCS file: /cvsroot/abi/src/wp/impexp/xp/ie_imp_Text.cpp,v retrieving revision 1.79 diff -u -r1.79 ie_imp_Text.cpp --- src/wp/impexp/xp/ie_imp_Text.cpp 16 Jan 2007 23:17:07 -0000 1.79 +++ src/wp/impexp/xp/ie_imp_Text.cpp 17 Jan 2007 02:07:23 -0000 @@ -328,7 +328,7 @@ { "txt", UT_CONFIDENCE_PERFECT }, { "text", UT_CONFIDENCE_PERFECT }, { "doc", UT_CONFIDENCE_POOR }, - { NULL, UT_CONFIDENCE_ZILCH } + { "", UT_CONFIDENCE_ZILCH } }; const IE_SuffixConfidence * IE_Imp_Text_Sniffer::getSuffixConfidence () @@ -340,7 +340,7 @@ static IE_MimeConfidence IE_Imp_Text_Sniffer__MimeConfidence[] = { { IE_MIME_MATCH_FULL, IE_MIMETYPE_Text, UT_CONFIDENCE_GOOD }, { IE_MIME_MATCH_CLASS, "text", UT_CONFIDENCE_SOSO }, - { IE_MIME_MATCH_BOGUS, NULL, UT_CONFIDENCE_ZILCH } + { IE_MIME_MATCH_BOGUS, "", UT_CONFIDENCE_ZILCH } }; const IE_MimeConfidence * IE_Imp_Text_Sniffer::getMimeConfidence () @@ -572,7 +572,7 @@ static IE_SuffixConfidence IE_Imp_EncodedText_Sniffer__SuffixConfidence[] = { { "txt", UT_CONFIDENCE_POOR }, { "text", UT_CONFIDENCE_POOR }, - { NULL, UT_CONFIDENCE_ZILCH } + { "", UT_CONFIDENCE_ZILCH } }; const IE_SuffixConfidence * IE_Imp_EncodedText_Sniffer::getSuffixConfidence () Index: src/wp/impexp/xp/ie_imp_XHTML.cpp =================================================================== RCS file: /cvsroot/abi/src/wp/impexp/xp/ie_imp_XHTML.cpp,v retrieving revision 1.87 diff -u -r1.87 ie_imp_XHTML.cpp --- src/wp/impexp/xp/ie_imp_XHTML.cpp 16 Jan 2007 23:17:08 -0000 1.87 +++ src/wp/impexp/xp/ie_imp_XHTML.cpp 17 Jan 2007 02:07:23 -0000 @@ -81,7 +81,7 @@ { "xhtml", UT_CONFIDENCE_PERFECT }, { "html", UT_CONFIDENCE_PERFECT }, { "htm", UT_CONFIDENCE_PERFECT }, - { NULL, UT_CONFIDENCE_ZILCH } + { "", UT_CONFIDENCE_ZILCH } }; const IE_SuffixConfidence * IE_Imp_XHTML_Sniffer::getSuffixConfidence () @@ -96,7 +96,7 @@ { IE_MIME_MATCH_FULL, IE_MIMETYPE_XHTML, UT_CONFIDENCE_PERFECT }, { IE_MIME_MATCH_FULL, "application/xhtml", UT_CONFIDENCE_PERFECT }, { IE_MIME_MATCH_FULL, "text/html", UT_CONFIDENCE_PERFECT }, - { IE_MIME_MATCH_BOGUS, NULL, UT_CONFIDENCE_ZILCH } + { IE_MIME_MATCH_BOGUS, "", UT_CONFIDENCE_ZILCH } }; const IE_MimeConfidence * IE_Imp_XHTML_Sniffer::getMimeConfidence () Index: src/wp/impexp/xp/ie_types.h =================================================================== RCS file: /cvsroot/abi/src/wp/impexp/xp/ie_types.h,v retrieving revision 1.34 diff -u -r1.34 ie_types.h --- src/wp/impexp/xp/ie_types.h 16 Jan 2007 23:17:09 -0000 1.34 +++ src/wp/impexp/xp/ie_types.h 17 Jan 2007 02:07:23 -0000 @@ -30,6 +30,7 @@ NOTE: to (or less than) the number below. */ +#include #include #include "ut_types.h" @@ -84,7 +85,7 @@ */ struct IE_MimeConfidence { IE_MimeMatch match; /*!< Match class or full mimetype. */ - const gchar *mimetype; /*!< Mimetype string itself. */ + std::string mimetype; /*!< Mimetype string itself. */ UT_Confidence_t confidence; /*!< Confidence for supporting that mimetype. */ }; @@ -92,7 +93,7 @@ * Entry for filename suffixes supported by a filter. */ struct IE_SuffixConfidence { - const gchar *suffix; /*!< Filename suffix to match. */ + std::string suffix; /*!< Filename suffix to match. */ UT_Confidence_t confidence; /*!< Confidence for supporting that mimetype. */ };