diff options
author | Martin Schanzenbach <mschanzenbach@posteo.de> | 2020-10-02 12:04:42 +0200 |
---|---|---|
committer | Martin Schanzenbach <mschanzenbach@posteo.de> | 2020-10-02 12:04:42 +0200 |
commit | 400f527fbd5cb6d9523374f6f8d1320339c5b71a (patch) | |
tree | 48bef37cbee57b3b4dc56f0e23095bb620e3f39e /src/util | |
parent | 02fb94bd4caa614cfd2327580e91e5e1bc822ebd (diff) | |
download | gnunet-400f527fbd5cb6d9523374f6f8d1320339c5b71a.tar.gz gnunet-400f527fbd5cb6d9523374f6f8d1320339c5b71a.zip |
UTIL: Never localize fancy strings in to_string to prevent breaking from_string parser
Diffstat (limited to 'src/util')
-rw-r--r-- | src/util/strings.c | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/src/util/strings.c b/src/util/strings.c index 9d6f4039e..381b66e1e 100644 --- a/src/util/strings.c +++ b/src/util/strings.c | |||
@@ -176,7 +176,7 @@ GNUNET_STRINGS_buffer_tokenize (const char *buffer, | |||
176 | char * | 176 | char * |
177 | GNUNET_STRINGS_byte_size_fancy (unsigned long long size) | 177 | GNUNET_STRINGS_byte_size_fancy (unsigned long long size) |
178 | { | 178 | { |
179 | const char *unit = _ (/* size unit */ "b"); | 179 | const char *unit = /* size unit */ "b"; |
180 | char *ret; | 180 | char *ret; |
181 | 181 | ||
182 | if (size > 5 * 1024) | 182 | if (size > 5 * 1024) |
@@ -703,37 +703,37 @@ GNUNET_STRINGS_relative_time_to_string (struct GNUNET_TIME_Relative delta, | |||
703 | int do_round) | 703 | int do_round) |
704 | { | 704 | { |
705 | static GNUNET_THREAD_LOCAL char buf[128]; | 705 | static GNUNET_THREAD_LOCAL char buf[128]; |
706 | const char *unit = _ (/* time unit */ "µs"); | 706 | const char *unit = /* time unit */ "µs"; |
707 | uint64_t dval = delta.rel_value_us; | 707 | uint64_t dval = delta.rel_value_us; |
708 | 708 | ||
709 | if (GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us == delta.rel_value_us) | 709 | if (GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us == delta.rel_value_us) |
710 | return _ ("forever"); | 710 | return "forever"; |
711 | if (0 == delta.rel_value_us) | 711 | if (0 == delta.rel_value_us) |
712 | return _ ("0 ms"); | 712 | return "0 ms"; |
713 | if (((GNUNET_YES == do_round) && (dval > 5 * 1000)) || (0 == (dval % 1000))) | 713 | if (((GNUNET_YES == do_round) && (dval > 5 * 1000)) || (0 == (dval % 1000))) |
714 | { | 714 | { |
715 | dval = dval / 1000; | 715 | dval = dval / 1000; |
716 | unit = _ (/* time unit */ "ms"); | 716 | unit = /* time unit */ "ms"; |
717 | if (((GNUNET_YES == do_round) && (dval > 5 * 1000)) || (0 == (dval % 1000))) | 717 | if (((GNUNET_YES == do_round) && (dval > 5 * 1000)) || (0 == (dval % 1000))) |
718 | { | 718 | { |
719 | dval = dval / 1000; | 719 | dval = dval / 1000; |
720 | unit = _ (/* time unit */ "s"); | 720 | unit = /* time unit */ "s"; |
721 | if (((GNUNET_YES == do_round) && (dval > 5 * 60)) || (0 == (dval % 60))) | 721 | if (((GNUNET_YES == do_round) && (dval > 5 * 60)) || (0 == (dval % 60))) |
722 | { | 722 | { |
723 | dval = dval / 60; | 723 | dval = dval / 60; |
724 | unit = _ (/* time unit */ "m"); | 724 | unit = /* time unit */ "m"; |
725 | if (((GNUNET_YES == do_round) && (dval > 5 * 60)) || (0 == (dval % 60))) | 725 | if (((GNUNET_YES == do_round) && (dval > 5 * 60)) || (0 == (dval % 60))) |
726 | { | 726 | { |
727 | dval = dval / 60; | 727 | dval = dval / 60; |
728 | unit = _ (/* time unit */ "h"); | 728 | unit = /* time unit */ "h"; |
729 | if (((GNUNET_YES == do_round) && (dval > 5 * 24)) || | 729 | if (((GNUNET_YES == do_round) && (dval > 5 * 24)) || |
730 | (0 == (dval % 24))) | 730 | (0 == (dval % 24))) |
731 | { | 731 | { |
732 | dval = dval / 24; | 732 | dval = dval / 24; |
733 | if (1 == dval) | 733 | if (1 == dval) |
734 | unit = _ (/* time unit */ "day"); | 734 | unit = /* time unit */ "day"; |
735 | else | 735 | else |
736 | unit = _ (/* time unit */ "days"); | 736 | unit = /* time unit */ "days"; |
737 | } | 737 | } |
738 | } | 738 | } |
739 | } | 739 | } |
@@ -761,7 +761,7 @@ GNUNET_STRINGS_absolute_time_to_string (struct GNUNET_TIME_Absolute t) | |||
761 | struct tm *tp; | 761 | struct tm *tp; |
762 | 762 | ||
763 | if (t.abs_value_us == GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us) | 763 | if (t.abs_value_us == GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us) |
764 | return _ ("end of time"); | 764 | return "end of time"; |
765 | tt = t.abs_value_us / 1000LL / 1000LL; | 765 | tt = t.abs_value_us / 1000LL / 1000LL; |
766 | tp = localtime (&tt); | 766 | tp = localtime (&tt); |
767 | /* This is hacky, but i don't know a way to detect libc character encoding. | 767 | /* This is hacky, but i don't know a way to detect libc character encoding. |