~ubuntu-branches/ubuntu/precise/evolution/precise

« back to all changes in this revision

Viewing changes to e-util/e-util.c

  • Committer: Package Import Robot
  • Author(s): Mathieu Trudel-Lapierre
  • Date: 2011-09-08 09:38:57 UTC
  • mfrom: (1.1.84 upstream)
  • Revision ID: package-import@ubuntu.com-20110908093857-6lfl04ke2ns3kx2o
Tags: 3.1.91-0ubuntu1
* New upstream release. (LP: #843769)
* debian/control: bump e-d-s Build-Depends to 3.1.91. 

Show diffs side-by-side

added added

removed removed

Lines of Context:
566
566
}
567
567
 
568
568
gint
569
 
e_str_compare (gconstpointer x, gconstpointer y)
 
569
e_str_compare (gconstpointer x,
 
570
               gconstpointer y)
570
571
{
571
572
        if (x == NULL || y == NULL) {
572
573
                if (x == y)
579
580
}
580
581
 
581
582
gint
582
 
e_str_case_compare (gconstpointer x, gconstpointer y)
 
583
e_str_case_compare (gconstpointer x,
 
584
                    gconstpointer y)
583
585
{
584
586
        gchar *cx, *cy;
585
587
        gint res;
603
605
}
604
606
 
605
607
gint
606
 
e_collate_compare (gconstpointer x, gconstpointer y)
 
608
e_collate_compare (gconstpointer x,
 
609
                   gconstpointer y)
607
610
{
608
611
        if (x == NULL || y == NULL) {
609
612
                if (x == y)
616
619
}
617
620
 
618
621
gint
619
 
e_int_compare (gconstpointer x, gconstpointer y)
 
622
e_int_compare (gconstpointer x,
 
623
               gconstpointer y)
620
624
{
621
625
        gint nx = GPOINTER_TO_INT (x);
622
626
        gint ny = GPOINTER_TO_INT (y);
727
731
}
728
732
 
729
733
/* Perform a binary search for key in base which has nmemb elements
730
 
   of size bytes each.  The comparisons are done by (*compare)().  */
 
734
 * of size bytes each.  The comparisons are done by (*compare)().  */
731
735
void
732
736
e_bsearch (gconstpointer key,
733
737
           gconstpointer base,
734
738
           gsize nmemb,
735
739
           gsize size,
736
 
           ESortCompareFunc compare,
 
740
           ESortCompareFunc compare,
737
741
           gpointer closure,
738
742
           gsize *start,
739
743
           gsize *end)
813
817
 */
814
818
 
815
819
gsize
816
 
e_strftime_fix_am_pm (gchar *str, gsize max, const gchar *fmt,
 
820
e_strftime_fix_am_pm (gchar *str,
 
821
                      gsize max,
 
822
                      const gchar *fmt,
817
823
                      const struct tm *tm)
818
824
{
819
825
        gchar buf[10];
823
829
 
824
830
        if (strstr(fmt, "%p")==NULL && strstr(fmt, "%P")==NULL) {
825
831
                /* No AM/PM involved - can use the fmt string directly */
826
 
                ret=e_strftime (str, max, fmt, tm);
 
832
                ret = e_strftime (str, max, fmt, tm);
827
833
        } else {
828
834
                /* Get the AM/PM symbol from the locale */
829
835
                e_strftime (buf, 10, "%p", tm);
831
837
                if (buf[0]) {
832
838
                        /* AM/PM have been defined in the locale
833
839
                         * so we can use the fmt string directly. */
834
 
                        ret=e_strftime (str, max, fmt, tm);
 
840
                        ret = e_strftime (str, max, fmt, tm);
835
841
                } else {
836
842
                        /* No AM/PM defined by locale
837
843
                         * must change to 24 hour clock. */
838
 
                        ffmt=g_strdup (fmt);
 
844
                        ffmt = g_strdup (fmt);
839
845
                        for (sp=ffmt; (sp=strstr(sp, "%l")); sp++) {
840
846
                                /* Maybe this should be 'k', but I have never
841
847
                                 * seen a 24 clock actually use that format. */
844
850
                        for (sp=ffmt; (sp=strstr(sp, "%I")); sp++) {
845
851
                                sp[1]='H';
846
852
                        }
847
 
                        ret=e_strftime (str, max, ffmt, tm);
 
853
                        ret = e_strftime (str, max, ffmt, tm);
848
854
                        g_free (ffmt);
849
855
                }
850
856
        }
853
859
}
854
860
 
855
861
gsize
856
 
e_utf8_strftime_fix_am_pm (gchar *str, gsize max, const gchar *fmt,
 
862
e_utf8_strftime_fix_am_pm (gchar *str,
 
863
                           gsize max,
 
864
                           const gchar *fmt,
857
865
                           const struct tm *tm)
858
866
{
859
867
        gsize sz, ret;
1004
1012
 * Returns: the gdouble value
1005
1013
 **/
1006
1014
gdouble
1007
 
e_flexible_strtod (const gchar *nptr, gchar **endptr)
 
1015
e_flexible_strtod (const gchar *nptr,
 
1016
                   gchar **endptr)
1008
1017
{
1009
1018
        gchar *fail_pos;
1010
1019
        gdouble val;
1032
1041
        p = nptr;
1033
1042
 
1034
1043
        /* Skip leading space */
1035
 
        while (isspace ((guchar)*p))
 
1044
        while (isspace ((guchar) * p))
1036
1045
                p++;
1037
1046
 
1038
1047
        /* Skip leading optional sign */
1044
1053
                p += 2;
1045
1054
                /* HEX - find the (optional) decimal point */
1046
1055
 
1047
 
                while (isxdigit ((guchar)*p))
 
1056
                while (isxdigit ((guchar) * p))
1048
1057
                        p++;
1049
1058
 
1050
1059
                if (*p == '.') {
1051
1060
                        decimal_point_pos = p++;
1052
1061
 
1053
 
                        while (isxdigit ((guchar)*p))
 
1062
                        while (isxdigit ((guchar) * p))
1054
1063
                                p++;
1055
1064
 
1056
1065
                        if (*p == 'p' || *p == 'P')
1057
1066
                                p++;
1058
1067
                        if (*p == '+' || *p == '-')
1059
1068
                                p++;
1060
 
                        while (isdigit ((guchar)*p))
 
1069
                        while (isdigit ((guchar) * p))
1061
1070
                                p++;
1062
1071
                        end = p;
1063
1072
                } else if (strncmp (p, decimal_point, decimal_point_len) == 0) {
1064
1073
                        return strtod (nptr, endptr);
1065
1074
                }
1066
1075
        } else {
1067
 
                while (isdigit ((guchar)*p))
 
1076
                while (isdigit ((guchar) * p))
1068
1077
                        p++;
1069
1078
 
1070
1079
                if (*p == '.') {
1071
1080
                        decimal_point_pos = p++;
1072
1081
 
1073
 
                        while (isdigit ((guchar)*p))
 
1082
                        while (isdigit ((guchar) * p))
1074
1083
                                p++;
1075
1084
 
1076
1085
                        if (*p == 'e' || *p == 'E')
1077
1086
                                p++;
1078
1087
                        if (*p == '+' || *p == '-')
1079
1088
                                p++;
1080
 
                        while (isdigit ((guchar)*p))
 
1089
                        while (isdigit ((guchar) * p))
1081
1090
                                p++;
1082
1091
                        end = p;
1083
1092
                } else if (strncmp (p, decimal_point, decimal_point_len) == 0) {
1143
1152
 * Returns: the pointer to the buffer with the converted string
1144
1153
 **/
1145
1154
gchar *
1146
 
e_ascii_dtostr (gchar *buffer, gint buf_len, const gchar *format, gdouble d)
 
1155
e_ascii_dtostr (gchar *buffer,
 
1156
                gint buf_len,
 
1157
                const gchar *format,
 
1158
                gdouble d)
1147
1159
{
1148
1160
        struct lconv *locale_data;
1149
1161
        const gchar *decimal_point;
1188
1200
                if (*p == '+' || *p == '-')
1189
1201
                        p++;
1190
1202
 
1191
 
                while (isdigit ((guchar)*p))
 
1203
                while (isdigit ((guchar) * p))
1192
1204
                        p++;
1193
1205
 
1194
1206
                if (strncmp (p, decimal_point, decimal_point_len) == 0) {
1195
1207
                        *p = '.';
1196
1208
                        p++;
1197
1209
                        if (decimal_point_len > 1) {
1198
 
                                rest_len = strlen (p + (decimal_point_len-1));
1199
 
                                memmove (p, p + (decimal_point_len-1),
 
1210
                                rest_len = strlen (p + (decimal_point_len - 1));
 
1211
                                memmove (p, p + (decimal_point_len - 1),
1200
1212
                                         rest_len);
1201
1213
                                p[rest_len] = 0;
1202
1214
                        }
1274
1286
 *          not be determined
1275
1287
 **/
1276
1288
gchar *
1277
 
e_util_guess_mime_type (const gchar *filename, gboolean localfile)
 
1289
e_util_guess_mime_type (const gchar *filename,
 
1290
                        gboolean localfile)
1278
1291
{
1279
1292
        gchar *mime_type = NULL;
1280
1293