Mercurial > pidgin.yaz
comparison libpurple/protocols/myspace/myspace.c @ 18892:138e9be2f917
Always use our own msim_round() instead of checking for C99's round and using
it, for consistency.
author | Jeffrey Connelly <jaconnel@calpoly.edu> |
---|---|
date | Sat, 11 Aug 2007 04:40:39 +0000 |
parents | 00499df91ffe |
children | cd90423c0a88 |
comparison
equal
deleted
inserted
replaced
18891:7db556e97dd1 | 18892:138e9be2f917 |
---|---|
170 static gboolean msim_is_email(const gchar *user); | 170 static gboolean msim_is_email(const gchar *user); |
171 | 171 |
172 static void msim_lookup_user(MsimSession *session, const gchar *user, | 172 static void msim_lookup_user(MsimSession *session, const gchar *user, |
173 MSIM_USER_LOOKUP_CB cb, gpointer data); | 173 MSIM_USER_LOOKUP_CB cb, gpointer data); |
174 | 174 |
175 #ifndef round | 175 double msim_round(double round); |
176 double round(double round); | |
177 | 176 |
178 /* round is part of C99, but sometimes is unavailable before then. | 177 /* round is part of C99, but sometimes is unavailable before then. |
179 * Based on http://forums.belution.com/en/cpp/000/050/13.shtml | 178 * Based on http://forums.belution.com/en/cpp/000/050/13.shtml |
180 */ | 179 */ |
181 double round(double value) | 180 double msim_round(double value) |
182 { | 181 { |
183 if (value < 0) { | 182 if (value < 0) { |
184 return -(floor(-value + 0.5)); | 183 return -(floor(-value + 0.5)); |
185 } else { | 184 } else { |
186 return floor( value + 0.5); | 185 return floor( value + 0.5); |
187 } | 186 } |
188 } | 187 } |
189 #endif | |
190 | 188 |
191 /** | 189 /** |
192 * Load the plugin. | 190 * Load the plugin. |
193 */ | 191 */ |
194 gboolean | 192 gboolean |
840 | 838 |
841 for (size = 0; | 839 for (size = 0; |
842 size < sizeof(_font_scale) / sizeof(_font_scale[0]); | 840 size < sizeof(_font_scale) / sizeof(_font_scale[0]); |
843 ++size) { | 841 ++size) { |
844 scale = _font_scale[CLAMP(size, 1, MAX_FONT_SIZE) - 1]; | 842 scale = _font_scale[CLAMP(size, 1, MAX_FONT_SIZE) - 1]; |
845 this_point = (guint)round(scale * base); | 843 this_point = (guint)msim_round(scale * base); |
846 | 844 |
847 if (this_point >= point) { | 845 if (this_point >= point) { |
848 purple_debug_info("msim", "msim_point_to_purple_size: %d pt -> size=%d\n", | 846 purple_debug_info("msim", "msim_point_to_purple_size: %d pt -> size=%d\n", |
849 point, size); | 847 point, size); |
850 return size; | 848 return size; |
865 | 863 |
866 scale = _font_scale[CLAMP(size, 1, MAX_FONT_SIZE) - 1]; | 864 scale = _font_scale[CLAMP(size, 1, MAX_FONT_SIZE) - 1]; |
867 | 865 |
868 base = purple_account_get_int(session->account, "base_font_size", MSIM_BASE_FONT_POINT_SIZE); | 866 base = purple_account_get_int(session->account, "base_font_size", MSIM_BASE_FONT_POINT_SIZE); |
869 | 867 |
870 point = (guint)round(scale * base); | 868 point = (guint)msim_round(scale * base); |
871 | 869 |
872 purple_debug_info("msim", "msim_purple_size_to_point: size=%d -> %d pt\n", | 870 purple_debug_info("msim", "msim_purple_size_to_point: size=%d -> %d pt\n", |
873 size, point); | 871 size, point); |
874 | 872 |
875 return point; | 873 return point; |
881 { | 879 { |
882 guint dpi; | 880 guint dpi; |
883 | 881 |
884 dpi = purple_account_get_int(session->account, "port", MSIM_DEFAULT_DPI); | 882 dpi = purple_account_get_int(session->account, "port", MSIM_DEFAULT_DPI); |
885 | 883 |
886 return (guint)round((POINTS_PER_INCH * 1. / dpi) * height); | 884 return (guint)msim_round((POINTS_PER_INCH * 1. / dpi) * height); |
887 | 885 |
888 /* See also: libpurple/protocols/bonjour/jabber.c | 886 /* See also: libpurple/protocols/bonjour/jabber.c |
889 * _font_size_ichat_to_purple */ | 887 * _font_size_ichat_to_purple */ |
890 } | 888 } |
891 | 889 |
895 { | 893 { |
896 guint dpi; | 894 guint dpi; |
897 | 895 |
898 dpi = purple_account_get_int(session->account, "port", MSIM_DEFAULT_DPI); | 896 dpi = purple_account_get_int(session->account, "port", MSIM_DEFAULT_DPI); |
899 | 897 |
900 return (guint)round((dpi * 1. / POINTS_PER_INCH) * point); | 898 return (guint)msim_round((dpi * 1. / POINTS_PER_INCH) * point); |
901 } | 899 } |
902 | 900 |
903 /** Convert the msim markup <f> (font) tag into HTML. */ | 901 /** Convert the msim markup <f> (font) tag into HTML. */ |
904 static void | 902 static void |
905 msim_markup_f_to_html(MsimSession *session, xmlnode *root, gchar **begin, gchar **end) | 903 msim_markup_f_to_html(MsimSession *session, xmlnode *root, gchar **begin, gchar **end) |