Mercurial > pidgin
comparison src/util.c @ 970:9eb07b383df4
[gaim-migrate @ 980]
Bleat.
committer: Tailor Script <tailor@pidgin.im>
| author | Rob Flynn <gaim@robflynn.com> |
|---|---|
| date | Wed, 11 Oct 2000 00:31:15 +0000 |
| parents | 17ff662183b2 |
| children | 2586b2a3725e |
comparison
equal
deleted
inserted
replaced
| 969:eb5a82d64ce5 | 970:9eb07b383df4 |
|---|---|
| 49 return date; | 49 return date; |
| 50 } | 50 } |
| 51 | 51 |
| 52 gint badchar(char c) | 52 gint badchar(char c) |
| 53 { | 53 { |
| 54 if (c == ' ') | 54 switch(c) { |
| 55 return 1; | 55 case ' ': |
| 56 if (c == ',') | 56 case ',': |
| 57 return 1; | 57 case '(': |
| 58 if (c == ')') | 58 case ')': |
| 59 return 1; | 59 case '\0': |
| 60 if (c == '(') | 60 case '\n ': |
| 61 return 1; | 61 case '<': |
| 62 if (c == 0) | 62 case '>': |
| 63 return 1; | |
| 64 if (c == '\n') | |
| 65 return 1; | |
| 66 if (c == '<') | |
| 67 return 1; | 63 return 1; |
| 68 if (c == '>') | 64 default: |
| 69 return 1; | 65 return 0; |
| 70 return 0; | 66 } |
| 71 | 67 } |
| 72 | 68 |
| 73 } | 69 |
| 74 | 70 gchar *sec_to_text(gint sec) |
| 75 | |
| 76 char *sec_to_text(int sec) | |
| 77 { | 71 { |
| 78 int hrs, min; | 72 int hrs, min; |
| 79 char minutes[64]; | 73 char minutes[64]; |
| 80 char hours[64]; | 74 char hours[64]; |
| 81 char sep[16]; | 75 char *sep; |
| 82 char *ret = g_malloc(256); | 76 char *ret = g_malloc(256); |
| 83 | 77 |
| 84 hrs = sec / 3600; | 78 hrs = sec / 3600; |
| 85 min = sec % 3600; | 79 min = sec % 3600; |
| 86 | 80 |
| 90 if (min) { | 84 if (min) { |
| 91 if (min == 1) | 85 if (min == 1) |
| 92 g_snprintf(minutes, sizeof(minutes), "%d minute.", min); | 86 g_snprintf(minutes, sizeof(minutes), "%d minute.", min); |
| 93 else | 87 else |
| 94 g_snprintf(minutes, sizeof(minutes), "%d minutes.", min); | 88 g_snprintf(minutes, sizeof(minutes), "%d minutes.", min); |
| 95 sprintf(sep, ", "); | 89 sep = ", "; |
| 96 } else { | 90 } else { |
| 97 if (!hrs) | 91 if (!hrs) |
| 98 g_snprintf(minutes, sizeof(minutes), "%d minutes.", min); | 92 g_snprintf(minutes, sizeof(minutes), "%d minutes.", min); |
| 99 else { | 93 else { |
| 100 minutes[0] = '.'; | 94 minutes[0] = '.'; |
| 101 minutes[1] = '\0'; | 95 minutes[1] = '\0'; |
| 102 } | 96 } |
| 103 sep[0] = '\0'; | 97 sep = ""; |
| 104 } | 98 } |
| 105 | 99 |
| 106 if (hrs) { | 100 if (hrs) { |
| 107 if (hrs == 1) | 101 if (hrs == 1) |
| 108 g_snprintf(hours, sizeof(hours), "%d hour%s", hrs, sep); | 102 g_snprintf(hours, sizeof(hours), "%d hour%s", hrs, sep); |
