index debda4378d5fcdf38584128b84471592723ffe45..009ff1c6e1560481f59547b061a7122c4508739b 100644 (file)
@@ -24,6 +24,7 @@ void make_field(struct tic_field *field, const struct tic_etiquette *etiq, char 
 {
    // args come from the bison stack
    int base;
+    char *rem;
    field->horodate = horodate;
    memcpy(&field->etiq, etiq, sizeof(field->etiq));
@@ -41,7 +42,24 @@ void make_field(struct tic_field *field, const struct tic_etiquette *etiq, char 
            base = 10;
            break;
    }
-    field->data.i = (int)strtol(data, NULL, base);
+    field->data.i = (int)strtol(data, &rem, base);
+
+#ifdef TICV01pme
+    if (U_SANS == etiq->unittype && *data != '0円' && *rem != '0円') {
+        // int sans unit but with a suffix: either kVA or kW - try to disambiguate
+        switch (rem[strlen(rem)-1]) {
+            case 'A':
+                field->etiq.unittype = U_KVA;
+                break;
+            case 'W':
+                field->etiq.unittype = U_KW;
+                break;
+            default:
+                break;
+        }
+    }
+#endif
+
    free(data);
 }