From: Roberto C. <rob...@en...> - 2003-08-16 12:41:01
|
Lutz Müller wrote: > > On Wed, 2003-08-13 at 22:13, Roberto Costa wrote: > > The quickest patch I can think of is to comment lines 539 and 540 of > > exif/main.c (the one released with exif 0.6). > > I only wonder why they have been put there... is there any kind of value > > set through "--set-value" that needs to be similarly truncated? > > I guess it has been done to separate values like "1 2 3 4" for entries > that have 4 components (like coordinates). If this is the case, we need > proper escaping. For example > > "1|2|3|4" would result in "1", "2", "3", "4" > > "(\|\\)" would result in "(|\)" > > If I am right, could you supply a patch? Hello, ok, now that I understand the concept of "component", I see why a command-line argument provided for --set-value might be divided in sub-strings. In this respect, I think that an ascii string substantially differs from the other formats, because its value can be directly expressed on the command line (an integer for instance is represented as a string which is then converted into an int) and its components don't need to be separated by any special character. This is why in my opinion the best solution is to handle ascii strings differently than any other format. I attach two modified versions of main.c to this message (main.patched1.c and main.patched2.c). The second patch contains all the changes included in the first, the reason why I'm providing two patches is that those added by the second go beyond the problem we're discussing and hence I thought might be accepted after some discussions. Of course I definitely recommend the second patch! Here is a summary of the changes of main.patched1.c: -) The conversion of the cmd-line argument of --set-value into the exif entry is moved into a separate static function (it was already in a new scope, indented like a function!). -) ASCII strings are handled separately, in a way that is faster and straightforward. In addition, main.patched2.c also includes: -) The handler of the other formats is cleaner and shorter, string.h provides a lot of useful functions, why not to use them? By the way, this handler no longer does stuff that is a duty of the shell and absolutely not of the other applications... -) Added check that the right number of components are specified. -) buf no longer statically allocated, in order to prevent buffer overflow. -) The component separator is now ',', this can be easily changed (by modifying the assignment of comp_separ). Cheers, Roberto |