Mercurial > ~mikael > mcabber > hg
comparison mcabber/libjabber/snprintf.c @ 414:ec86d759ed54
Trailing whitespace cleanup
No real change.
author | Mikael Berthe <mikael@lilotux.net> |
---|---|
date | Tue, 30 Aug 2005 22:26:19 +0200 |
parents | bf3d6e241714 |
children | c3ae9251c197 |
comparison
equal
deleted
inserted
replaced
413:f7e4b0424081 | 414:ec86d759ed54 |
---|---|
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * | 10 * |
11 * 2. Redistributions in binary form must reproduce the above copyright | 11 * 2. Redistributions in binary form must reproduce the above copyright |
12 * notice, this list of conditions and the following disclaimer in | 12 * notice, this list of conditions and the following disclaimer in |
13 * the documentation and/or other materials provided with the | 13 * the documentation and/or other materials provided with the |
14 * distribution. | 14 * distribution. |
362 *is_negative = FALSE; | 362 *is_negative = FALSE; |
363 } else { | 363 } else { |
364 *is_negative = (num < 0); | 364 *is_negative = (num < 0); |
365 | 365 |
366 /* | 366 /* |
367 * On a 2's complement machine, negating the most negative integer | 367 * On a 2's complement machine, negating the most negative integer |
368 * results in a number that cannot be represented as a signed integer. | 368 * results in a number that cannot be represented as a signed integer. |
369 * Here is what we do to obtain the number's magnitude: | 369 * Here is what we do to obtain the number's magnitude: |
370 * a. add 1 to the number | 370 * a. add 1 to the number |
371 * b. negate it (becomes positive) | 371 * b. negate it (becomes positive) |
372 * c. convert it to unsigned | 372 * c. convert it to unsigned |
379 } else | 379 } else |
380 magnitude = (u_wide_int) num; | 380 magnitude = (u_wide_int) num; |
381 } | 381 } |
382 | 382 |
383 /* | 383 /* |
384 * We use a do-while loop so that we write at least 1 digit | 384 * We use a do-while loop so that we write at least 1 digit |
385 */ | 385 */ |
386 do { | 386 do { |
387 register u_wide_int new_magnitude = magnitude / 10; | 387 register u_wide_int new_magnitude = magnitude / 10; |
388 | 388 |
389 *--p = magnitude - new_magnitude * 10 + '0'; | 389 *--p = magnitude - new_magnitude * 10 + '0'; |
800 case 'n': | 800 case 'n': |
801 *(va_arg(ap, int *)) = cc; | 801 *(va_arg(ap, int *)) = cc; |
802 break; | 802 break; |
803 | 803 |
804 /* | 804 /* |
805 * Always extract the argument as a "char *" pointer. We | 805 * Always extract the argument as a "char *" pointer. We |
806 * should be using "void *" but there are still machines | 806 * should be using "void *" but there are still machines |
807 * that don't understand it. | 807 * that don't understand it. |
808 * If the pointer size is equal to the size of an unsigned | 808 * If the pointer size is equal to the size of an unsigned |
809 * integer we convert the pointer to a hex number, otherwise | 809 * integer we convert the pointer to a hex number, otherwise |
810 * we print "%p" to indicate that we don't handle "%p". | 810 * we print "%p" to indicate that we don't handle "%p". |
811 */ | 811 */ |
812 case 'p': | 812 case 'p': |
813 ui_num = (u_wide_int) va_arg(ap, char *); | 813 ui_num = (u_wide_int) va_arg(ap, char *); |
814 | 814 |
862 min_width--; | 862 min_width--; |
863 } | 863 } |
864 PAD(min_width, s_len, pad_char); | 864 PAD(min_width, s_len, pad_char); |
865 } | 865 } |
866 /* | 866 /* |
867 * Print the string s. | 867 * Print the string s. |
868 */ | 868 */ |
869 for (i = s_len; i != 0; i--) { | 869 for (i = s_len; i != 0; i--) { |
870 INS_CHAR(*s, sp, bep, cc); | 870 INS_CHAR(*s, sp, bep, cc); |
871 s++; | 871 s++; |
872 } | 872 } |