From c4ac061b21cdafcbff69d0666bf91c8fc42adf15 Mon Sep 17 00:00:00 2001 From: Marcus Meissner Date: Tue, 9 Nov 2010 08:52:37 +0000 Subject: [PATCH] fixed fnumber float-decimal conversion issue git-svn-id: https://svn.code.sf.net/p/gphoto/code/trunk/libgphoto2@13387 67ed7778-7388-44ab-90cf-0a291f65f57c --- camlibs/ptp2/config.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/camlibs/ptp2/config.c b/camlibs/ptp2/config.c index f8f1c8f04..81a941a74 100644 --- a/camlibs/ptp2/config.c +++ b/camlibs/ptp2/config.c @@ -2113,15 +2113,26 @@ _get_FNumber(CONFIG_GET_ARGS) { static int _put_FNumber(CONFIG_PUT_ARGS) { - int ret; + int ret, i; char *value; float f; ret = gp_widget_get_value (widget, &value); if (ret != GP_OK) return ret; + if (strstr (value, "f/") == value) + value += strlen("f/"); - if (sscanf(value, "f/%g", &f)) { + for (i=0;iFORM.Enum.NumberOfValues; i++) { + char buf[20]; + + sprintf(buf,"%g",(dpd->FORM.Enum.SupportedValue[i].u16*1.0)/100.0); + if (!strcmp (buf, value)) { + propval->u16 = dpd->FORM.Enum.SupportedValue[i].u16; + return GP_OK; + } + } + if (sscanf(value, "%g", &f)) { propval->u16 = f*100; return GP_OK; }