commit 21ca135e01d859bdbc8197072f388edffbbba0cc
parent b0cab4e85aed43031a0210f2a31742bbcef7e734
Author: Christian Grothoff <christian@grothoff.org>
Date: Sat, 12 Jun 2010 14:41:25 +0000
pass unsigned chars only to isXXXX functions and simplify code
Diffstat:
3 files changed, 9 insertions(+), 37 deletions(-)
diff --git a/src/common/pack.c b/src/common/pack.c
@@ -79,7 +79,7 @@ EXTRACTOR_common_cat_pack (void *buf, const char *fmt, ...)
{
nreps = 0;
- if (isdigit (*fmt))
+ if (isdigit ( (unsigned char) *fmt))
{
/* We use cp instead of fmt to keep the 'const' qualifier of fmt */
nreps = strtoul (fmt, &cp, 0);
@@ -274,7 +274,7 @@ EXTRACTOR_common_cat_unpack (const void *buf, const char *fmt, ...)
{
nreps = 1;
- if (isdigit (*fmt))
+ if (isdigit ( (unsigned char) *fmt))
{
/* We use cp instead of format to keep the 'const' qualifier of fmt */
nreps = strtoul (fmt, &cp, 0);
diff --git a/src/main/extract.c b/src/main/extract.c
@@ -353,32 +353,6 @@ print_selected_keywords_grep_friendly (void *cls,
/**
- * Take title, auth, year and return a string
- */
-static char *
-str_splice(const char * title,
- const char * year,
- const char * auth) {
- char * temp = malloc(16);
- int i = 0;
-
- snprintf(temp,
- 15,
- "%.5s%.5s%.5s",
- auth,
- year,
- title);
- for (i=0;i<strlen(temp);i++ ) {
- if (! isalnum(temp[i]) )
- temp[i] = '_';
- else
- temp[i] = tolower( (unsigned int) temp[i]);
- }
- return temp;
-}
-
-
-/**
* Entry in the map we construct for each file.
*/
struct BibTexMap
@@ -513,14 +487,12 @@ finish_bibtex (const char *fn)
fn);
else
{
- tya = str_splice (btm[0].value,
- btm[1].value,
- btm[2].value);
fprintf (stdout,
- "@%s %s { ",
+ "@%s %.5s%.5s%.5s { ",
et,
- tya);
- free (tya);
+ btm[2].value,
+ btm[1].value,
+ btm[0].value);
}
diff --git a/src/plugins/exiv2_extractor.cc b/src/plugins/exiv2_extractor.cc
@@ -54,7 +54,7 @@ addExiv2Tag(const Exiv2::ExifData& exifData,
if (md != exifData.end()) {
std::string ccstr = Exiv2::toString(*md);
str = ccstr.c_str();
- while ( (strlen(str) > 0) && isspace(str[0])) str++;
+ while ( (strlen(str) > 0) && isspace((unsigned char) str[0])) str++;
if (strlen(str) > 0)
ADD (str, type);
md++;
@@ -80,7 +80,7 @@ addIptcData(const Exiv2::IptcData& iptcData,
break;
std::string ccstr = Exiv2::toString(*md);
str = ccstr.c_str();
- while ( (strlen(str) > 0) && isspace(str[0])) str++;
+ while ( (strlen(str) > 0) && isspace( (unsigned char) str[0])) str++;
if (strlen(str) > 0)
ADD (str, type);
md++;
@@ -106,7 +106,7 @@ addXmpData(const Exiv2::XmpData& xmpData,
break;
std::string ccstr = Exiv2::toString(*md);
str = ccstr.c_str();
- while ( (strlen(str) > 0) && isspace(str[0])) str++;
+ while ( (strlen(str) > 0) && isspace( (unsigned char) str[0])) str++;
if (strlen(str) > 0)
ADD (str, type);
md++;