[recipes] Parse unit names better



commit 37337e5750eb98f0225065260fc0ca117c595b16
Author: Matthias Clasen <mclasen redhat com>
Date:   Fri Dec 30 16:01:39 2016 -0500

    Parse unit names better
    
    When parsing units, also look for the unit name, apart from the
    translated abbreviation and name.

 src/gr-unit.c |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)
---
diff --git a/src/gr-unit.c b/src/gr-unit.c
index 160b865..2b9d323 100644
--- a/src/gr-unit.c
+++ b/src/gr-unit.c
@@ -113,6 +113,14 @@ gr_unit_parse (char   **input,
                 }
         }
 
+        for (i = 0; i < G_N_ELEMENTS (units); i++) {
+                nu = units[i].unit;
+                if (g_str_has_prefix (*input, nu) && space_or_nul ((*input)[strlen (nu)])) {
+                        *input += strlen (nu);
+                        return units[i].unit;
+                }
+        }
+
         g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
                      _("I don’t know this unit: %s"), *input);
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]