libextractor

GNU libextractor
Log | Files | Refs | Submodules | README | LICENSE

commit b1adb567e5a9c3c6b26c5989c39817eb6f4cb3f7
parent eb5153c6b99a84c5e35dd642ea1fd31ae2715d6f
Author: Christian Grothoff <christian@grothoff.org>
Date:   Tue,  3 Feb 2009 05:06:41 +0000

fixing #1430

Diffstat:
Mdoc/version.texi | 4++--
Msrc/main/extractor.c | 2+-
Msrc/plugins/filenameextractor.c | 72++++++++++++++++++++++++++++++++++--------------------------------------
Msrc/test/mt_plugintest2.c | 20+++++++++++++++++++-
4 files changed, 56 insertions(+), 42 deletions(-)

diff --git a/doc/version.texi b/doc/version.texi @@ -1,4 +1,4 @@ -@set UPDATED 26 November 2008 -@set UPDATED-MONTH November 2008 +@set UPDATED 30 December 2008 +@set UPDATED-MONTH December 2008 @set EDITION 0.5.21 @set VERSION 0.5.21 diff --git a/src/main/extractor.c b/src/main/extractor.c @@ -1311,7 +1311,7 @@ EXTRACTOR_getKeywords (EXTRACTOR_ExtractorList * extractor, if (-1 == file) return NULL; - size = fstatbuf.st_size; + size = (fstatbuf.st_size > 0xFFFFFFFF) ? 0xFFFFFFFF : fstatbuf.st_size; if (size == 0) { close(file); return NULL; diff --git a/src/plugins/filenameextractor.c b/src/plugins/filenameextractor.c @@ -30,47 +30,43 @@ libextractor_filename_extract (const char *filename, size_t size, struct EXTRACTOR_Keywords *prev) { EXTRACTOR_KeywordList *keyword; + struct stat fstatbuf; const char *filenameRoot = filename; int res; /* get filename */ - if (filename != NULL) - { - for (res = strlen (filename) - 1; res >= 0; res--) - if (filename[res] == DIR_SEPARATOR) - { - filenameRoot = &filename[res + 1]; - break; - } - keyword = malloc (sizeof (EXTRACTOR_KeywordList)); - keyword->next = prev; - keyword->keyword = EXTRACTOR_common_convert_to_utf8 (filenameRoot, - strlen (filenameRoot), - nl_langinfo (CODESET)); - keyword->keywordType = EXTRACTOR_FILENAME; - prev = keyword; - } - - /* get file size */ - if (size > 0) - { - keyword = malloc (sizeof (EXTRACTOR_KeywordList)); - keyword->next = prev; - keyword->keyword = malloc (14); - keyword->keywordType = EXTRACTOR_FILE_SIZE; - - if (size >= 1000000000) - snprintf (keyword->keyword, 13, "%.2f %s", size / 1000000000.0, - _("GB")); - else if (size >= 1000000) - snprintf (keyword->keyword, 13, "%.2f %s", size / 1000000.0, _("MB")); - else if (size >= 1000) - snprintf (keyword->keyword, 13, "%.2f %s", size / 1000.0, _("KB")); - else - snprintf (keyword->keyword, 13, "%.2f %s", (double) size, _("Bytes")); - - prev = keyword; - } - + if (filename == NULL) + return prev; + for (res = strlen (filename) - 1; res >= 0; res--) + if (filename[res] == DIR_SEPARATOR) + { + filenameRoot = &filename[res + 1]; + break; + } + keyword = malloc (sizeof (EXTRACTOR_KeywordList)); + keyword->next = prev; + keyword->keyword = EXTRACTOR_common_convert_to_utf8 (filenameRoot, + strlen (filenameRoot), + nl_langinfo (CODESET)); + keyword->keywordType = EXTRACTOR_FILENAME; + prev = keyword; + if (-1 == STAT(filename, &fstatbuf)) + return prev; + keyword = malloc (sizeof (EXTRACTOR_KeywordList)); + keyword->next = prev; + keyword->keyword = malloc (14); + keyword->keywordType = EXTRACTOR_FILE_SIZE; + + if (size >= 1000000000) + snprintf (keyword->keyword, 14, "%.2f %s", fstatbuf.st_size / 1000000000.0, + _("GB")); + else if (size >= 1000000) + snprintf (keyword->keyword, 14, "%.2f %s", fstatbuf.st_size / 1000000.0, _("MB")); + else if (size >= 1000) + snprintf (keyword->keyword, 14, "%.2f %s", fstatbuf.st_size / 1000.0, _("KB")); + else + snprintf (keyword->keyword, 14, "%.2f %s", (double) fstatbuf.st_size, _("Bytes")); + + prev = keyword; return prev; } diff --git a/src/test/mt_plugintest2.c b/src/test/mt_plugintest2.c @@ -1,3 +1,22 @@ +/* + This file is part of libextractor. + (C) 2007, 2008, 2009 Vidyut Samanta and Christian Grothoff + + libextractor is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published + by the Free Software Foundation; either version 2, or (at your + option) any later version. + + libextractor is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with libextractor; see the file COPYING. If not, write to the + Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. + */ /** * @file test/mt-plugintest1.c * @brief test extractor plugin load/unload from multiple threads @@ -22,7 +41,6 @@ test_plugins (void *arg) { struct TaskData *td = (struct TaskData *) arg; EXTRACTOR_ExtractorList *el; - int i; while (!done) {