~libecbufr-dev/libecbufr/trunk

« back to all changes in this revision

Viewing changes to API/Sources/bufr_ieee754.c

  • Committer: Michel Van Eeckhout
  • Date: 2010-03-12 16:37:56 UTC
  • mto: This revision was merged to the branch mainline in revision 109.
  • Revision ID: afsmmve@corbeau-20100312163756-n9fpy2r26y19ttxr
Modified sources for internationalisation + added m4 and po directories.

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
 
25
25
#include "bufr_io.h"
26
26
#include "bufr_ieee754.h"
 
27
#include "bufr_i18n.h"
27
28
 
28
29
#define  USE_C_IEEE754_LAYOUT   0
29
30
 
149
150
      {
150
151
      char errmsg[256];
151
152
 
152
 
      sprintf( errmsg, "### Decoded double: %llx ->  %E  (sign=%d exponent=%llx signific=%llx)\n", 
 
153
      sprintf( errmsg, _("### Decoded double: %llx ->  %E  (sign=%d exponent=%llx signific=%llx)\n"), 
153
154
               lval, dval, (sign<0)?1:0, exponent, signific );
154
155
      bufr_print_debug( errmsg );
155
156
      }
217
218
      {
218
219
      char errmsg[256];
219
220
 
220
 
      sprintf( errmsg, "### Decoded single: %x ->  %E  (sign=%d exponent=%x signific=%x)\n", 
 
221
      sprintf( errmsg, _("### Decoded single: %x ->  %E  (sign=%d exponent=%x signific=%x)\n"), 
221
222
         ival, fval, (sign<0)?1:0, exponent, signific );
222
223
      bufr_print_debug( errmsg );
223
224
      }
487
488
   i32 = bufr_ieee_encode_single( flmax );
488
489
   if (i32 != MAX_BITS_32)
489
490
      {
490
 
      sprintf( errmsg, "Warning: IEEE 754 encoding/decoding mismatch F32: %x -> %E -> %x\n",
 
491
      sprintf( errmsg, _("Warning: IEEE 754 encoding/decoding mismatch F32: %x -> %E -> %x\n"),
491
492
            MAX_BITS_32, flmax, i32 );
492
493
      bufr_print_debug( errmsg );
493
494
      error = -1;
495
496
#if DEBUG
496
497
   else if (bufr_is_debug())
497
498
      {
498
 
      sprintf( errmsg, "### IEEE 754 encoding/decoding matched F32: %x -> %E -> %x\n",
 
499
      sprintf( errmsg, _("### IEEE 754 encoding/decoding matched F32: %x -> %E -> %x\n"),
499
500
            MAX_BITS_32, flmax, i32 );
500
501
      bufr_print_debug( errmsg );
501
502
      }
505
506
   i64 = bufr_ieee_encode_double( dmax );
506
507
   if (i64 != MAX_BITS_64)
507
508
      {
508
 
      sprintf( errmsg, "Warning: IEEE 754 encoding/decoding mismatch F64: %llx -> %E -> %llx\n",
 
509
      sprintf( errmsg, _("Warning: IEEE 754 encoding/decoding mismatch F64: %llx -> %E -> %llx\n"),
509
510
            MAX_BITS_64, dmax, i64 );
510
511
      bufr_print_debug( errmsg );
511
512
      error = -1;
513
514
#if DEBUG
514
515
   else if (bufr_is_debug())
515
516
      {
516
 
      sprintf( errmsg, "### IEEE 754 encoding/decoding matched F64: %llx -> %E -> %llx\n",
 
517
      sprintf( errmsg, _("### IEEE 754 encoding/decoding matched F64: %llx -> %E -> %llx\n"),
517
518
            MAX_BITS_64, dmax, i64 );
518
519
      bufr_print_debug( errmsg );
519
520
      }
539
540
 
540
541
   if (debug)
541
542
      {
542
 
      sprintf( errmsg, "### Checking: %s size is %d bytes:", string, size );
 
543
      sprintf( errmsg, _("### Checking: %s size is %d bytes:"), string, size );
543
544
      bufr_print_debug( errmsg );
544
545
      }
545
546
 
546
547
   if (size == expected)
547
548
      {
548
549
      if (debug) 
549
 
         bufr_print_debug( "Ok\n" );
 
550
         bufr_print_debug( _("Ok\n") );
550
551
      }
551
552
   else
552
553
      {
553
554
      if (debug) 
554
555
         {
555
 
         sprintf( errmsg, "Failed: should be %d bytes\n", expected );
 
556
         sprintf( errmsg, _("Failed: should be %d bytes\n"), expected );
556
557
         bufr_print_debug( errmsg );
557
558
         }
558
559
      *failed = 1;
614
615
   ival = *ptrInt;
615
616
   if ((ival & SIGN_BIT_32)==0)
616
617
      {
617
 
      bufr_print_debug( "Failed: sign bit is not 1 on negative float value\n" );
 
618
      bufr_print_debug( _("Failed: sign bit is not 1 on negative float value\n") );
618
619
      return -1;
619
620
      }
620
621
 
622
623
   ival = *ptrInt;
623
624
   if ((ival & SIGN_BIT_32)!=0)
624
625
      {
625
 
      bufr_print_debug( "Failed: sign bit is not 0 on positive float value\n" );
 
626
      bufr_print_debug( _("Failed: sign bit is not 0 on positive float value\n") );
626
627
      return -1;
627
628
      }
628
629
 
630
631
   lval = *ptrLong;
631
632
   if ((lval & SIGN_BIT_64)==0)
632
633
      {
633
 
      bufr_print_debug( "Failed: sign bit is not 1 on double negative value\n" );
 
634
      bufr_print_debug( _("Failed: sign bit is not 1 on double negative value\n") );
634
635
      return 0;
635
636
      }
636
637
 
638
639
   lval = *ptrLong;
639
640
   if ((lval & SIGN_BIT_64)!=0)
640
641
      {
641
 
      bufr_print_debug( "Failed: sign bit is not 0 on double positive value\n" );
 
642
      bufr_print_debug( _("Failed: sign bit is not 0 on double positive value\n") );
642
643
      return 0;
643
644
      }
644
645
 
870
871
static int check_C_ieee754_compliance(void)
871
872
   {
872
873
   if (bufr_is_debug())
873
 
      bufr_print_debug( "### Checking Memory Layout of float and double for IEEE 754 ...\n" );
 
874
      bufr_print_debug( _("### Checking Memory Layout of float and double for IEEE 754 ...\n") );
874
875
 
875
876
   if (!check_type_size()) return 0;
876
877
   if (check_sign_bit() < 0) return 0;
880
881
   if (check_match_encoding2decoding() < 0) return 0;
881
882
 
882
883
   if (bufr_is_debug())
883
 
      bufr_print_debug( "### Checked: good, C float and double use IEEE 754\n" );
 
884
      bufr_print_debug( _("### Checked: good, C float and double use IEEE 754\n") );
884
885
 
885
886
   return 1;
886
887
   }
966
967
#if DEBUG
967
968
      if (bufr_is_debug())
968
969
         {
969
 
         sprintf( errmsg, "### Decoding double OK for value %E\n", dval );
 
970
         sprintf( errmsg, _("### Decoding double OK for value %E\n"), dval );
970
971
         bufr_print_debug( errmsg );
971
972
         }
972
973
#endif
974
975
      }
975
976
   else
976
977
      {
977
 
      sprintf( errmsg, "Warning: decoding of double differ with value %E != %E\n", 
 
978
      sprintf( errmsg, _("Warning: decoding of double differ with value %E != %E\n"), 
978
979
               dval, dval2 );
979
980
      bufr_print_debug( errmsg );
980
981
      return -1;
1008
1009
#if DEBUG
1009
1010
      if (bufr_is_debug())
1010
1011
         {
1011
 
         sprintf( errmsg, "### Decoding float OK for value %E\n", fval );
 
1012
         sprintf( errmsg, _("### Decoding float OK for value %E\n"), fval );
1012
1013
         bufr_print_debug( errmsg );
1013
1014
         }
1014
1015
#endif
1016
1017
      }
1017
1018
   else
1018
1019
      {
1019
 
      sprintf( errmsg, "Warning: decoding of float differ with value %E != %E\n", 
 
1020
      sprintf( errmsg, _("Warning: decoding of float differ with value %E != %E\n"), 
1020
1021
               fval, fval2 );
1021
1022
      bufr_print_debug( errmsg );
1022
1023
      return -1;
1046
1047
#if DEBUG
1047
1048
      if (bufr_is_debug())
1048
1049
         {
1049
 
         sprintf( errmsg, "### Encoding float OK for value %E\n", fval );
 
1050
         sprintf( errmsg, _("### Encoding float OK for value %E\n"), fval );
1050
1051
         bufr_print_debug( errmsg );
1051
1052
         }
1052
1053
#endif
1054
1055
      }
1055
1056
   else
1056
1057
      {
1057
 
      sprintf( errmsg, "Warning: encoding of float differ with value %E != %E\n", 
 
1058
      sprintf( errmsg, _("Warning: encoding of float differ with value %E != %E\n"), 
1058
1059
               fval, fval2 );
1059
1060
      bufr_print_debug( errmsg );
1060
1061
      return -1;
1084
1085
#if DEBUG
1085
1086
      if (bufr_is_debug())
1086
1087
         {
1087
 
         sprintf( errmsg, "### Encoding double OK for value %E\n", fval );
 
1088
         sprintf( errmsg, _("### Encoding double OK for value %E\n"), fval );
1088
1089
         bufr_print_debug( errmsg );
1089
1090
         }
1090
1091
#endif
1092
1093
      }
1093
1094
   else
1094
1095
      {
1095
 
      sprintf( errmsg, "Warning: encoding of double differ with value %E != %E\n", 
 
1096
      sprintf( errmsg, _("Warning: encoding of double differ with value %E != %E\n"), 
1096
1097
               fval, fval2 );
1097
1098
      bufr_print_debug( errmsg );
1098
1099
      return -1;