OLD | NEW |
1 /////////////////////////////////////////////////////////////////////////////// | 1 /////////////////////////////////////////////////////////////////////////////// |
2 // | 2 // |
3 /// \file message.c | 3 /// \file message.c |
4 /// \brief Printing messages | 4 /// \brief Printing messages |
5 // | 5 // |
6 // Author: Lasse Collin | 6 // Author: Lasse Collin |
7 // | 7 // |
8 // This file has been put into the public domain. | 8 // This file has been put into the public domain. |
9 // You can do whatever you want with this file. | 9 // You can do whatever you want with this file. |
10 // | 10 // |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 } | 204 } |
205 | 205 |
206 | 206 |
207 /// Prints the name of the current file if it hasn't been printed already, | 207 /// Prints the name of the current file if it hasn't been printed already, |
208 /// except if we are processing exactly one stream from stdin to stdout. | 208 /// except if we are processing exactly one stream from stdin to stdout. |
209 /// I think it looks nicer to not print "(stdin)" when --verbose is used | 209 /// I think it looks nicer to not print "(stdin)" when --verbose is used |
210 /// in a pipe and no other files are processed. | 210 /// in a pipe and no other files are processed. |
211 static void | 211 static void |
212 print_filename(void) | 212 print_filename(void) |
213 { | 213 { |
214 » if (files_total != 1 || filename != stdin_filename) { | 214 » if (!opt_robot && (files_total != 1 || filename != stdin_filename)) { |
215 signals_block(); | 215 signals_block(); |
216 | 216 |
217 FILE *file = opt_mode == MODE_LIST ? stdout : stderr; | 217 FILE *file = opt_mode == MODE_LIST ? stdout : stderr; |
218 | 218 |
219 // If a file was already processed, put an empty line | 219 // If a file was already processed, put an empty line |
220 // before the next filename to improve readability. | 220 // before the next filename to improve readability. |
221 if (first_filename_printed) | 221 if (first_filename_printed) |
222 fputc('\n', file); | 222 fputc('\n', file); |
223 | 223 |
224 first_filename_printed = true; | 224 first_filename_printed = true; |
(...skipping 627 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
852 { | 852 { |
853 if (v > verbosity) | 853 if (v > verbosity) |
854 return; | 854 return; |
855 | 855 |
856 // Convert memusage to MiB, rounding up to the next full MiB. | 856 // Convert memusage to MiB, rounding up to the next full MiB. |
857 // This way the user can always use the displayed usage as | 857 // This way the user can always use the displayed usage as |
858 // the new memory usage limit. (If we rounded to the nearest, | 858 // the new memory usage limit. (If we rounded to the nearest, |
859 // the user might need to +1 MiB to get high enough limit.) | 859 // the user might need to +1 MiB to get high enough limit.) |
860 memusage = round_up_to_mib(memusage); | 860 memusage = round_up_to_mib(memusage); |
861 | 861 |
| 862 uint64_t memlimit = hardware_memlimit_get(opt_mode); |
| 863 |
| 864 // Handle the case when there is no memory usage limit. |
| 865 // This way we don't print a weird message with a huge number. |
| 866 if (memlimit == UINT64_MAX) { |
| 867 message(v, _("%s MiB of memory is required. " |
| 868 "The limiter is disabled."), |
| 869 uint64_to_str(memusage, 0)); |
| 870 return; |
| 871 } |
| 872 |
862 // With US-ASCII: | 873 // With US-ASCII: |
863 // 2^64 with thousand separators + " MiB" suffix + '\0' = 26 + 4 + 1 | 874 // 2^64 with thousand separators + " MiB" suffix + '\0' = 26 + 4 + 1 |
864 // But there may be multibyte chars so reserve enough space. | 875 // But there may be multibyte chars so reserve enough space. |
865 char memlimitstr[128]; | 876 char memlimitstr[128]; |
866 | 877 |
867 // Show the memory usage limit as MiB unless it is less than 1 MiB. | 878 // Show the memory usage limit as MiB unless it is less than 1 MiB. |
868 // This way it's easy to notice errors where one has typed | 879 // This way it's easy to notice errors where one has typed |
869 // --memory=123 instead of --memory=123MiB. | 880 // --memory=123 instead of --memory=123MiB. |
870 uint64_t memlimit = hardware_memlimit_get(opt_mode); | |
871 if (memlimit < (UINT32_C(1) << 20)) { | 881 if (memlimit < (UINT32_C(1) << 20)) { |
872 snprintf(memlimitstr, sizeof(memlimitstr), "%s B", | 882 snprintf(memlimitstr, sizeof(memlimitstr), "%s B", |
873 uint64_to_str(memlimit, 1)); | 883 uint64_to_str(memlimit, 1)); |
874 } else { | 884 } else { |
875 // Round up just like with memusage. If this function is | 885 // Round up just like with memusage. If this function is |
876 // called for informational purposes (to just show the | 886 // called for informational purposes (to just show the |
877 // current usage and limit), we should never show that | 887 // current usage and limit), we should never show that |
878 // the usage is higher than the limit, which would give | 888 // the usage is higher than the limit, which would give |
879 // a false impression that the memory usage limit isn't | 889 // a false impression that the memory usage limit isn't |
880 // properly enforced. | 890 // properly enforced. |
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1229 // TRANSLATORS: This message indicates the bug reporting address | 1239 // TRANSLATORS: This message indicates the bug reporting address |
1230 // for this package. Please add _another line_ saying | 1240 // for this package. Please add _another line_ saying |
1231 // "Report translation bugs to <...>\n" with the email or WWW | 1241 // "Report translation bugs to <...>\n" with the email or WWW |
1232 // address for translation bugs. Thanks. | 1242 // address for translation bugs. Thanks. |
1233 printf(_("Report bugs to <%s> (in English or Finnish).\n"), | 1243 printf(_("Report bugs to <%s> (in English or Finnish).\n"), |
1234 PACKAGE_BUGREPORT); | 1244 PACKAGE_BUGREPORT); |
1235 printf(_("%s home page: <%s>\n"), PACKAGE_NAME, PACKAGE_URL); | 1245 printf(_("%s home page: <%s>\n"), PACKAGE_NAME, PACKAGE_URL); |
1236 | 1246 |
1237 tuklib_exit(E_SUCCESS, E_ERROR, verbosity != V_SILENT); | 1247 tuklib_exit(E_SUCCESS, E_ERROR, verbosity != V_SILENT); |
1238 } | 1248 } |
OLD | NEW |