Am 12.04.2013 21:27, schrieb Pascal de Bruijn:
Ulrich,
Would you mind taking a look? Although my sample code seems to work,
I'm not sure what the best approach is to integrate it into lens.c
Hi Pascal,
attached is a revised version. The original code would copy the first
space character in " or " to the output string which seems problematic.
Best wishes
Ulrich
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
char *lens_sanitize(char *orig_lens)
{
char *found_or = strstr(orig_lens, " or ");
if (found_or)
{
size_t pos = (size_t)(found_or - orig_lens);
char *new_lens = (char*) malloc(pos+1);
strncpy(new_lens, orig_lens, pos);
new_lens[pos] = '\0';
return new_lens;
}
else
{
return orig_lens;
}
}
int main(int argc, char *argv[])
{
printf("|%s|\n", lens_sanatize("Canon EF 100-300mm f/5.6L"));
printf("|%s|\n", lens_sanatize("Canon EF 20-35mm f/2.8L or Tokina Lens"));
printf("|%s|\n", lens_sanatize("Canon EF 100-300mm f/5.6 or Sigma or Tokina Lens"));
printf("|%s|\n", lens_sanatize("smc PENTAX-F 50mm F1.4"));
printf("|%s|\n", lens_sanatize("smc PENTAX-F 28-80mm F3.5-4.5 or Tokina Lens"));
printf("|%s|\n", lens_sanatize("smc PENTAX-FA 28-200mm F3.8-5.6 AL[IF] or Tamron Lens"));
printf("|%s|\n", lens_sanatize("AF Zoom-Micro Nikkor 70-180mm f/4.5-5.6D ED"));
return 0;
}
------------------------------------------------------------------------------
Precog is a next-generation analytics platform capable of advanced
analytics on semi-structured data. The platform includes APIs for building
apps and a phenomenal toolset for data science. Developers can use
our toolset for easy data analysis & visualization. Get a free account!
http://www2.precog.com/precogplatform/slashdotnewsletter
_______________________________________________
darktable-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/darktable-devel