add time functions
@@ -1,6 +1,6 @@ | ||
1 | 1 | /* |
2 | 2 | Text maid |
3 | - copyright (c) 1998-2011 Kazuki Iwamoto http://www.maid.org/ iwm@maid.org | |
3 | + copyright (c) 1998-2012 Kazuki Iwamoto http://www.maid.org/ iwm@maid.org | |
4 | 4 | |
5 | 5 | This program is free software: you can redistribute it and/or modify |
6 | 6 | it under the terms of the GNU General Public License as published by |
@@ -131,7 +131,7 @@ | ||
131 | 131 | gssize bytes_read_prev = -1; |
132 | 132 | |
133 | 133 | buffer = g_memdup (inbuf, length); |
134 | - while ((g_clear_error (&error), | |
134 | + while (abort_break && (g_clear_error (&error), | |
135 | 135 | !(outbuf = g_convert (buffer, length, "UTF-8", charset[i], |
136 | 136 | &bytes_read, &bytes_written, &error))) |
137 | 137 | && bytes_read_prev != bytes_read && error |
@@ -253,12 +253,12 @@ | ||
253 | 253 | g_free (outbuf); |
254 | 254 | /* ja:変換 */ |
255 | 255 | if (tmaid->ft.html) |
256 | - for (p = tmaid->start; p; p = p->next) | |
256 | + for (p = tmaid->start; abort_break && p; p = p->next) | |
257 | 257 | { |
258 | 258 | while (gtk_events_pending ()) |
259 | 259 | gtk_main_iteration (); |
260 | 260 | i = 0; |
261 | - while (i + 4 <= p->length) | |
261 | + while (abort_break && i + 4 <= p->length) | |
262 | 262 | if (p->text[i++] == '&' && p->text[i++] == '#') |
263 | 263 | { |
264 | 264 | c = 0; |
@@ -265,7 +265,7 @@ | ||
265 | 265 | if (g_ascii_tolower (p->text[i]) == 'x') |
266 | 266 | { |
267 | 267 | /* ja:16進数 */ |
268 | - for (j = i + 1; j < p->length; j++) | |
268 | + for (j = i + 1; abort_break && j < p->length; j++) | |
269 | 269 | if (g_ascii_isxdigit (p->text[j])) |
270 | 270 | c = c * 16 + g_ascii_xdigit_value (p->text[j]); |
271 | 271 | else |
@@ -274,7 +274,7 @@ | ||
274 | 274 | else |
275 | 275 | { |
276 | 276 | /* ja:10進数 */ |
277 | - for (j = i; j < p->length; j++) | |
277 | + for (j = i; abort_break && j < p->length; j++) | |
278 | 278 | if (g_ascii_isdigit (p->text[j])) |
279 | 279 | c = c * 10 + g_ascii_digit_value (p->text[j]); |
280 | 280 | else |
@@ -294,7 +294,7 @@ | ||
294 | 294 | } |
295 | 295 | } |
296 | 296 | else if (tmaid->ft.esc) |
297 | - for (p = tmaid->start; p; p = p->next) | |
297 | + for (p = tmaid->start; abort_break && p; p = p->next) | |
298 | 298 | { |
299 | 299 | while (gtk_events_pending ()) |
300 | 300 | gtk_main_iteration (); |
@@ -303,7 +303,7 @@ | ||
303 | 303 | if (p->text[i++] == '\\' && p->text[i++] == 'u') |
304 | 304 | { |
305 | 305 | c = 0; |
306 | - for (j = i; j < p->length; j++) | |
306 | + for (j = i; abort_break && j < p->length; j++) | |
307 | 307 | if (g_ascii_isxdigit (p->text[j])) |
308 | 308 | c = c * 16 + g_ascii_xdigit_value (p->text[j]); |
309 | 309 | else |
@@ -1,3 +1,23 @@ | ||
1 | +2012-08-29 Kazuki Iwamoto <iwm@maid.org> | |
2 | + | |
3 | + * version 2.7.3 | |
4 | + | |
5 | +2012-08-16 Kazuki Iwamoto <iwm@maid.org> | |
6 | + | |
7 | + * src/file.c: modify loop in file_open_text | |
8 | + | |
9 | +2012-08-14 Kazuki Iwamoto <iwm@maid.org> | |
10 | + | |
11 | + * misc/misc.[ch]: add time functions | |
12 | + | |
13 | +2012-06-02 Kazuki Iwamoto <iwm@maid.org> | |
14 | + | |
15 | + * misc/gcommon.c: modify g_strcmp/g_strncmp | |
16 | + | |
17 | +2012-05-20 Kazuki Iwamoto <iwm@maid.org> | |
18 | + | |
19 | + * misc/fileio.c: modify fileio_remove | |
20 | + | |
1 | 21 | 2012-03-29 Kazuki Iwamoto <iwm@maid.org> |
2 | 22 | |
3 | 23 | * version 2.7.2 |
@@ -2244,7 +2244,7 @@ | ||
2244 | 2244 | gboolean overwrite) |
2245 | 2245 | { |
2246 | 2246 | # ifdef G_OS_WIN32 |
2247 | - gboolean result = FALSE; | |
2247 | + gboolean ret = FALSE; | |
2248 | 2248 | |
2249 | 2249 | if (variable) |
2250 | 2250 | { |
@@ -2260,11 +2260,11 @@ | ||
2260 | 2260 | utf8str = g_locale_to_utf8 (value, -1, NULL, NULL, NULL); |
2261 | 2261 | lpszValue = g_utf8_to_utf16 (utf8str, -1, NULL, NULL, NULL); |
2262 | 2262 | g_free (utf8str); |
2263 | - result = SetEnvironmentVariableW (lpszName, lpzaValue); | |
2263 | + ret = SetEnvironmentVariableW (lpszName, lpzaValue); | |
2264 | 2264 | g_free (lpszName); |
2265 | 2265 | g_free (lpzaValue); |
2266 | 2266 | # else /* not UNICODE */ |
2267 | - result = SetEnvironmentVariableA (variable, value); | |
2267 | + ret = SetEnvironmentVariableA (variable, value); | |
2268 | 2268 | # endif /* not UNICODE */ |
2269 | 2269 | if (ghash_env) |
2270 | 2270 | g_hash_table_remove (ghash_env, variable); |
@@ -2271,15 +2271,15 @@ | ||
2271 | 2271 | } |
2272 | 2272 | else |
2273 | 2273 | { |
2274 | - result = TRUE; | |
2274 | + ret = TRUE; | |
2275 | 2275 | } |
2276 | 2276 | } |
2277 | - return result; | |
2277 | + return ret; | |
2278 | 2278 | # else /* not G_OS_WIN32 */ |
2279 | 2279 | # ifdef HAVE_SETENV |
2280 | 2280 | return variable ? setenv (variable, value, overwrite) : FALSE; |
2281 | 2281 | # else /* not HAVE_SETENV */ |
2282 | - gboolean result = FALSE; | |
2282 | + gboolean ret = FALSE; | |
2283 | 2283 | |
2284 | 2284 | if (variable) |
2285 | 2285 | { |
@@ -2288,15 +2288,15 @@ | ||
2288 | 2288 | gchar *string; |
2289 | 2289 | |
2290 | 2290 | string = g_strconcat (variable, "=", value, NULL); |
2291 | - result = putenv (string); | |
2291 | + ret = putenv (string); | |
2292 | 2292 | g_free (string); |
2293 | 2293 | } |
2294 | 2294 | else |
2295 | 2295 | { |
2296 | - result = TRUE; | |
2296 | + ret = TRUE; | |
2297 | 2297 | } |
2298 | 2298 | } |
2299 | - return result; | |
2299 | + return ret; | |
2300 | 2300 | # endif /* not HAVE_SETENV */ |
2301 | 2301 | # endif /* not G_OS_WIN32 */ |
2302 | 2302 | } |
@@ -2875,7 +2875,7 @@ | ||
2875 | 2875 | # ifndef FILE_ATTRIBUTE_DEVICE |
2876 | 2876 | # define FILE_ATTRIBUTE_DEVICE 64 |
2877 | 2877 | # endif /* not FILE_ATTRIBUTE_DEVICE */ |
2878 | - gboolean result = FALSE; | |
2878 | + gboolean ret = FALSE; | |
2879 | 2879 | DWORD dwAttributes; |
2880 | 2880 | # ifdef UNICODE |
2881 | 2881 | gchar *utf8str; |
@@ -2892,7 +2892,7 @@ | ||
2892 | 2892 | & (FILE_ATTRIBUTE_DIRECTORY | FILE_ATTRIBUTE_DEVICE)) == 0) |
2893 | 2893 | || ((test & G_FILE_TEST_IS_DIR) |
2894 | 2894 | && (dwAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0)) |
2895 | - result = TRUE; | |
2895 | + ret = TRUE; | |
2896 | 2896 | if (test & G_FILE_TEST_IS_EXECUTABLE) |
2897 | 2897 | { |
2898 | 2898 | INT nLength; |
@@ -2900,7 +2900,7 @@ | ||
2900 | 2900 | nLength = lstrlenW (lpszFile); |
2901 | 2901 | if (nLength > 4 |
2902 | 2902 | && lstrcmpiW (lpszFile + nLength - 4, L".exe") == 0) |
2903 | - result = TRUE; | |
2903 | + ret = TRUE; | |
2904 | 2904 | } |
2905 | 2905 | } |
2906 | 2906 | g_free (lpszFile); |
@@ -2913,7 +2913,7 @@ | ||
2913 | 2913 | & (FILE_ATTRIBUTE_DIRECTORY | FILE_ATTRIBUTE_DEVICE)) == 0) |
2914 | 2914 | || ((test & G_FILE_TEST_IS_DIR) |
2915 | 2915 | && (dwAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0)) |
2916 | - result = TRUE; | |
2916 | + ret = TRUE; | |
2917 | 2917 | if (test & G_FILE_TEST_IS_EXECUTABLE) |
2918 | 2918 | { |
2919 | 2919 | gsize len; |
@@ -2920,11 +2920,11 @@ | ||
2920 | 2920 | |
2921 | 2921 | len = g_strlen (file); |
2922 | 2922 | if (len > 4 && g_ascii_strcasecmp (file + len - 4, ".exe") == 0) |
2923 | - result = TRUE; | |
2923 | + ret = TRUE; | |
2924 | 2924 | } |
2925 | 2925 | } |
2926 | 2926 | # endif /* not UNICODE */ |
2927 | - return result; | |
2927 | + return ret; | |
2928 | 2928 | # else /* not G_OS_WIN32 */ |
2929 | 2929 | if ((test & G_FILE_TEST_EXISTS) && (g_access (file, F_OK) == 0)) |
2930 | 2930 | return TRUE; |
@@ -2967,17 +2967,17 @@ | ||
2967 | 2967 | { |
2968 | 2968 | # ifdef UNICODE |
2969 | 2969 | gchar *utf8str; |
2970 | - gint result; | |
2970 | + gint ret; | |
2971 | 2971 | LPWSTR lpszFile; |
2972 | 2972 | |
2973 | 2973 | utf8str = g_filename_to_utf8 (filename, -1, NULL, NULL, NULL); |
2974 | 2974 | lpszFile = g_utf8_to_utf16 (utf8str, -1, NULL, NULL, NULL); |
2975 | 2975 | g_free (utf8str); |
2976 | - result = CreateDirectoryW (lpszFile, NULL); | |
2976 | + ret = CreateDirectoryW (lpszFile, NULL); | |
2977 | 2977 | g_free (lpszFile); |
2978 | - return result; | |
2978 | + return ret ? 0 : -1; | |
2979 | 2979 | # else /* UNICODE */ |
2980 | - return CreateDirectoryA (filename, NULL); | |
2980 | + return CreateDirectoryA (filename, NULL) ? 0 : -1; | |
2981 | 2981 | # endif /* UNICODE */ |
2982 | 2982 | } |
2983 | 2983 | #endif /* ! GLIB_CHECK_VERSION(2,6,0) && defined (G_OS_WIN32) */ |
@@ -2989,7 +2989,7 @@ | ||
2989 | 2989 | gint mode) |
2990 | 2990 | { |
2991 | 2991 | #ifdef G_OS_WIN32 |
2992 | - gint result; | |
2992 | + gint ret; | |
2993 | 2993 | LPTSTR lpszFile; |
2994 | 2994 | # ifdef UNICODE |
2995 | 2995 | gchar *utf8str; |
@@ -3000,7 +3000,7 @@ | ||
3000 | 3000 | if (!utf8str) |
3001 | 3001 | { |
3002 | 3002 | g_free (path); |
3003 | - return NULL; | |
3003 | + return -1; | |
3004 | 3004 | } |
3005 | 3005 | lpszFile = g_utf8_to_utf16 (utf8str, -1, NULL, NULL, NULL); |
3006 | 3006 | g_free (utf8str); |
@@ -3012,9 +3012,9 @@ | ||
3012 | 3012 | errno = EINVAL; |
3013 | 3013 | return -1; |
3014 | 3014 | } |
3015 | - result = _tchmod (lpszFile, mode); | |
3015 | + ret = _tchmod (lpszFile, mode); | |
3016 | 3016 | g_free (lpszFile); |
3017 | - return result; | |
3017 | + return ret; | |
3018 | 3018 | #else /* not G_OS_WIN32 */ |
3019 | 3019 | return chmod (filename, mode); |
3020 | 3020 | #endif /* not G_OS_WIN32 */ |
@@ -3026,7 +3026,7 @@ | ||
3026 | 3026 | gint mode) |
3027 | 3027 | { |
3028 | 3028 | #ifdef G_OS_WIN32 |
3029 | - gint result; | |
3029 | + gint ret; | |
3030 | 3030 | LPTSTR lpszFile; |
3031 | 3031 | # ifdef UNICODE |
3032 | 3032 | gchar *utf8str; |
@@ -3049,9 +3049,9 @@ | ||
3049 | 3049 | errno = EINVAL; |
3050 | 3050 | return -1; |
3051 | 3051 | } |
3052 | - result = _taccess (lpszFile, mode); | |
3052 | + ret = _taccess (lpszFile, mode); | |
3053 | 3053 | g_free (lpszFile); |
3054 | - return result; | |
3054 | + return ret; | |
3055 | 3055 | #else /* not G_OS_WIN32 */ |
3056 | 3056 | return access (filename, mode); |
3057 | 3057 | #endif /* not G_OS_WIN32 */ |
@@ -3062,7 +3062,7 @@ | ||
3062 | 3062 | gint mode) |
3063 | 3063 | { |
3064 | 3064 | #ifdef G_OS_WIN32 |
3065 | - gint result; | |
3065 | + gint ret; | |
3066 | 3066 | LPTSTR lpszFile; |
3067 | 3067 | # ifdef UNICODE |
3068 | 3068 | gchar *utf8str; |
@@ -3085,9 +3085,9 @@ | ||
3085 | 3085 | errno = EINVAL; |
3086 | 3086 | return -1; |
3087 | 3087 | } |
3088 | - result = _tcreat (lpszFile, mode); | |
3088 | + ret = _tcreat (lpszFile, mode); | |
3089 | 3089 | g_free (lpszFile); |
3090 | - return result; | |
3090 | + return ret; | |
3091 | 3091 | #else /* not G_OS_WIN32 */ |
3092 | 3092 | return creat (filename, mode); |
3093 | 3093 | #endif /* not G_OS_WIN32 */ |
@@ -3098,7 +3098,7 @@ | ||
3098 | 3098 | g_chdir (const gchar *path) |
3099 | 3099 | { |
3100 | 3100 | #ifdef G_OS_WIN32 |
3101 | - gint result; | |
3101 | + gint ret; | |
3102 | 3102 | LPTSTR lpszPath; |
3103 | 3103 | # ifdef UNICODE |
3104 | 3104 | gchar *utf8str; |
@@ -3121,9 +3121,9 @@ | ||
3121 | 3121 | errno = EINVAL; |
3122 | 3122 | return -1; |
3123 | 3123 | } |
3124 | - result = _tchdir (lpszPath); | |
3124 | + ret = _tchdir (lpszPath); | |
3125 | 3125 | g_free (lpszPath); |
3126 | - return result; | |
3126 | + return ret; | |
3127 | 3127 | #else /* not G_OS_WIN32 */ |
3128 | 3128 | return chdir (path); |
3129 | 3129 | #endif /* not G_OS_WIN32 */ |
@@ -3137,7 +3137,7 @@ | ||
3137 | 3137 | struct utimbuf *utb) |
3138 | 3138 | { |
3139 | 3139 | #ifdef G_OS_WIN32 |
3140 | - gint result; | |
3140 | + gint ret; | |
3141 | 3141 | HANDLE hFile; |
3142 | 3142 | LPTSTR lpszFile; |
3143 | 3143 | # ifdef UNICODE |
@@ -3161,9 +3161,9 @@ | ||
3161 | 3161 | errno = EINVAL; |
3162 | 3162 | return -1; |
3163 | 3163 | } |
3164 | - result = _tutime (lpszFile, (struct _utimbuf *)utb); | |
3164 | + ret = _tutime (lpszFile, (struct _utimbuf *)utb); | |
3165 | 3165 | g_free (lpszFile); |
3166 | - return result; | |
3166 | + return ret; | |
3167 | 3167 | #else /* not G_OS_WIN32 */ |
3168 | 3168 | # ifdef HAVE_UTIME |
3169 | 3169 | return utime (filename, utb); |
@@ -3202,7 +3202,7 @@ | ||
3202 | 3202 | const gchar *reserved_chars_allowed, |
3203 | 3203 | gboolean allow_utf8) |
3204 | 3204 | { |
3205 | - gchar *result = NULL; | |
3205 | + gchar *ret = NULL; | |
3206 | 3206 | |
3207 | 3207 | if (unescaped) |
3208 | 3208 | { |
@@ -3213,7 +3213,7 @@ | ||
3213 | 3213 | "-.0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz~", |
3214 | 3214 | reserved_chars_allowed, NULL); |
3215 | 3215 | p = unescaped; |
3216 | - q = result = g_malloc ((g_strlen (unescaped) * 3 + 1) * sizeof (gchar)); | |
3216 | + q = ret = g_malloc ((g_strlen (unescaped) * 3 + 1) * sizeof (gchar)); | |
3217 | 3217 | while (*p != '\0') |
3218 | 3218 | { |
3219 | 3219 | gunichar c; |
@@ -3245,7 +3245,7 @@ | ||
3245 | 3245 | } |
3246 | 3246 | g_free (allowed); |
3247 | 3247 | } |
3248 | - return result; | |
3248 | + return ret; | |
3249 | 3249 | } |
3250 | 3250 | |
3251 | 3251 |
@@ -3262,7 +3262,7 @@ | ||
3262 | 3262 | const gchar *escaped_string_end, |
3263 | 3263 | const gchar *illegal_characters) |
3264 | 3264 | { |
3265 | - gchar *result = NULL; | |
3265 | + gchar *ret = NULL; | |
3266 | 3266 | |
3267 | 3267 | if (escaped_string) |
3268 | 3268 | { |
@@ -3271,7 +3271,7 @@ | ||
3271 | 3271 | |
3272 | 3272 | p = escaped_string; |
3273 | 3273 | end = escaped_string_end ? escaped_string_end : p + g_strlen (p); |
3274 | - q = result = g_malloc ((end - escaped_string + 1) * sizeof (gchar)); | |
3274 | + q = ret = g_malloc ((end - escaped_string + 1) * sizeof (gchar)); | |
3275 | 3275 | while (p < end) |
3276 | 3276 | { |
3277 | 3277 | gchar c; |
@@ -3286,8 +3286,8 @@ | ||
3286 | 3286 | ? (c1 << 4) | c2 : '\0'; |
3287 | 3287 | if (c == '\0' || g_strchr (illegal_characters, c)) |
3288 | 3288 | { |
3289 | - g_free (result); | |
3290 | - result = NULL; | |
3289 | + g_free (ret); | |
3290 | + ret = NULL; | |
3291 | 3291 | break; |
3292 | 3292 | } |
3293 | 3293 | } |
@@ -3294,7 +3294,7 @@ | ||
3294 | 3294 | *q++ = c; |
3295 | 3295 | } |
3296 | 3296 | } |
3297 | - return result; | |
3297 | + return ret; | |
3298 | 3298 | } |
3299 | 3299 | #endif /* not GLIB_CHECK_VERSION(2,16,0) */ |
3300 | 3300 |
@@ -3471,11 +3471,11 @@ | ||
3471 | 3471 | int |
3472 | 3472 | tclosedir (TDIR *nDir) |
3473 | 3473 | { |
3474 | - int result; | |
3474 | + int ret; | |
3475 | 3475 | |
3476 | 3476 | if (nDir) |
3477 | 3477 | { |
3478 | - result = nDir->hFind == INVALID_HANDLE_VALUE || FindClose (nDir->hFind) | |
3478 | + ret = nDir->hFind == INVALID_HANDLE_VALUE || FindClose (nDir->hFind) | |
3479 | 3479 | ? 0 : -1; |
3480 | 3480 | HeapFree (GetProcessHeap (), 0, nDir->lpszPath); |
3481 | 3481 | HeapFree (GetProcessHeap (), 0, nDir); |
@@ -3483,10 +3483,10 @@ | ||
3483 | 3483 | } |
3484 | 3484 | else |
3485 | 3485 | { |
3486 | - result = -1; | |
3486 | + ret = -1; | |
3487 | 3487 | errno = EFAULT; |
3488 | 3488 | } |
3489 | - return result; | |
3489 | + return ret; | |
3490 | 3490 | } |
3491 | 3491 | # endif /* defined (G_OS_WIN32) && ! defined (HAVE_DIRENT_H) */ |
3492 | 3492 |
@@ -4724,9 +4724,9 @@ | ||
4724 | 4724 | if (!s1 && !s2) |
4725 | 4725 | return 0; |
4726 | 4726 | else if (s1 && !s2) |
4727 | - return -1; | |
4727 | + return G_MININT; | |
4728 | 4728 | else if (!s1 && s2) |
4729 | - return 1; | |
4729 | + return G_MAXINT; | |
4730 | 4730 | return strcmp (s1, s2); |
4731 | 4731 | } |
4732 | 4732 |
@@ -4739,9 +4739,9 @@ | ||
4739 | 4739 | if (!s1 && !s2) |
4740 | 4740 | return 0; |
4741 | 4741 | else if (s1 && !s2) |
4742 | - return -1; | |
4742 | + return G_MININT; | |
4743 | 4743 | else if (!s1 && s2) |
4744 | - return 1; | |
4744 | + return G_MAXINT; | |
4745 | 4745 | return strncmp (s1, s2, n); |
4746 | 4746 | } |
4747 | 4747 |
@@ -4855,9 +4855,9 @@ | ||
4855 | 4855 | if (!s1 && !s2) |
4856 | 4856 | return 0; |
4857 | 4857 | else if (s1 && !s2) |
4858 | - return -1; | |
4858 | + return G_MININT; | |
4859 | 4859 | else if (!s1 && s2) |
4860 | - return 1; | |
4860 | + return G_MAXINT; | |
4861 | 4861 | return memcmp (s1, s2, n); |
4862 | 4862 | } |
4863 | 4863 |
@@ -1,6 +1,6 @@ | ||
1 | 1 | /* |
2 | 2 | misc |
3 | - copyright (c) 1998-2011 Kazuki Iwamoto http://www.maid.org/ iwm@maid.org | |
3 | + copyright (c) 1998-2012 Kazuki Iwamoto http://www.maid.org/ iwm@maid.org | |
4 | 4 | |
5 | 5 | This program is free software: you can redistribute it and/or modify |
6 | 6 | it under the terms of the GNU General Public License as published by |
@@ -277,6 +277,83 @@ | ||
277 | 277 | const gboolean flag); |
278 | 278 | |
279 | 279 | |
280 | +/****************************************************************************** | |
281 | +* * | |
282 | +* ja:日時文字列関数群 * | |
283 | +* * | |
284 | +******************************************************************************/ | |
285 | +/* ja:日時文字列→日時 | |
286 | + cymdhms,[[CC]YY]MMDDhhmm[.ss]文字列,接尾辞YMwDhmsの数値 | |
287 | + RET,日時 */ | |
288 | +GDateTime * | |
289 | +misc_string_to_time (const gchar *cymdhms); | |
290 | + | |
291 | + | |
292 | +/* ja:日時文字列→日時 | |
293 | + datetime,基準となる日時(NULL:現在時刻) | |
294 | + cymdhms,[[CC]YY]MMDDhhmm[.ss]文字列,接尾辞YMwDhmsの数値 | |
295 | + RET,日時 */ | |
296 | +GDateTime * | |
297 | +misc_string_to_time_datetime (GDateTime *datetime, | |
298 | + const gchar *cymdhms); | |
299 | + | |
300 | + | |
301 | +/* ja:日時文字列→日時 | |
302 | + datetime,基準となる日時(NULL:現在時刻) | |
303 | + cymdhms,[[CC]YY]MMDDhhmm[.ss]文字列,接尾辞YMwDhmsの数値 | |
304 | + sign,デフォルトの符号,NULL:+ | |
305 | + RET,日時 */ | |
306 | +GDateTime * | |
307 | +misc_string_to_time_full (GDateTime *datetime, | |
308 | + const gchar *cymdhms, | |
309 | + const gchar sign); | |
310 | + | |
311 | + | |
312 | +/* ja:日時文字列→日時 | |
313 | + cymdhms,[[CC]YY]MMDDhhmm[.ss]文字列,接尾辞YMwDhmsの数値 | |
314 | + sign,デフォルトの符号,NULL:+ | |
315 | + RET,日時 */ | |
316 | +GDateTime * | |
317 | +misc_string_to_time_sign (const gchar *cymdhms, | |
318 | + const gchar sign); | |
319 | + | |
320 | + | |
321 | +/* ja:日時文字列→UNIX時間 | |
322 | + cymdhms,[[CC]YY]MMDDhhmm[.ss]文字列,接尾辞YMwDhmsの数値 | |
323 | + RET,日時 */ | |
324 | +gint64 | |
325 | +misc_string_to_epoch (const gchar *cymdhms); | |
326 | + | |
327 | + | |
328 | +/* ja:日時文字列→UNIX時間 | |
329 | + datetime,基準となる日時(NULL:現在時刻) | |
330 | + cymdhms,[[CC]YY]MMDDhhmm[.ss]文字列,接尾辞YMwDhmsの数値 | |
331 | + RET,日時 */ | |
332 | +gint64 | |
333 | +misc_string_to_epoch_datetime (GDateTime *datetime, | |
334 | + const gchar *cymdhms); | |
335 | + | |
336 | + | |
337 | +/* ja:日時文字列→UNIX時間 | |
338 | + datetime,基準となる日時(NULL:現在時刻) | |
339 | + cymdhms,[[CC]YY]MMDDhhmm[.ss]文字列,接尾辞YMwDhmsの数値 | |
340 | + sign,デフォルトの符号,NULL:+ | |
341 | + RET,日時 */ | |
342 | +gint64 | |
343 | +misc_string_to_epoch_full (GDateTime *datetime, | |
344 | + const gchar *cymdhms, | |
345 | + const gchar sign); | |
346 | + | |
347 | + | |
348 | +/* ja:日時文字列→UNIX時間 | |
349 | + cymdhms,[[CC]YY]MMDDhhmm[.ss]文字列,接尾辞YMwDhmsの数値 | |
350 | + sign,デフォルトの符号,NULL:+ | |
351 | + RET,日時 */ | |
352 | +gint64 | |
353 | +misc_string_to_epoch_sign (const gchar *cymdhms, | |
354 | + const gchar sign); | |
355 | + | |
356 | + | |
280 | 357 | G_END_DECLS |
281 | 358 | |
282 | 359 |
@@ -1013,13 +1013,14 @@ | ||
1013 | 1013 | if (!dir) |
1014 | 1014 | return FALSE; |
1015 | 1015 | while (result && (name = g_dir_read_name (dir))) |
1016 | - { | |
1017 | - gchar *file; | |
1016 | + if (g_strcmp (name, ".") != 0 && g_strcmp (name, "..") != 0) | |
1017 | + { | |
1018 | + gchar *file; | |
1018 | 1019 | |
1019 | - file = g_build_filename (path, name, NULL); | |
1020 | - result = fileio_remove (file); | |
1021 | - g_free (file); | |
1022 | - } | |
1020 | + file = g_build_filename (path, name, NULL); | |
1021 | + result = fileio_remove (file); | |
1022 | + g_free (file); | |
1023 | + } | |
1023 | 1024 | g_dir_close (dir); |
1024 | 1025 | if (result) |
1025 | 1026 | result = g_rmdir (path) == 0; |
@@ -1,6 +1,6 @@ | ||
1 | 1 | /* |
2 | 2 | misc |
3 | - copyright (c) 1998-2011 Kazuki Iwamoto http://www.maid.org/ iwm@maid.org | |
3 | + copyright (c) 1998-2012 Kazuki Iwamoto http://www.maid.org/ iwm@maid.org | |
4 | 4 | |
5 | 5 | This program is free software: you can redistribute it and/or modify |
6 | 6 | it under the terms of the GNU General Public License as published by |
@@ -1187,3 +1187,257 @@ | ||
1187 | 1187 | g_free (p); |
1188 | 1188 | return array; |
1189 | 1189 | } |
1190 | + | |
1191 | + | |
1192 | +/****************************************************************************** | |
1193 | +* * | |
1194 | +* ja:日時文字列関数群 * | |
1195 | +* * | |
1196 | +******************************************************************************/ | |
1197 | +/* ja:日時文字列→日時 | |
1198 | + cymdhms,[[CC]YY]MMDDhhmm[.ss]文字列,接尾辞YMwDhmsの数値 | |
1199 | + RET,日時 */ | |
1200 | +GDateTime * | |
1201 | +misc_string_to_time (const gchar *cymdhms) | |
1202 | +{ | |
1203 | + return misc_string_to_time_full (NULL, cymdhms, '+'); | |
1204 | +} | |
1205 | + | |
1206 | + | |
1207 | +/* ja:日時文字列→日時 | |
1208 | + datetime,基準となる日時(NULL:現在時刻) | |
1209 | + cymdhms,[[CC]YY]MMDDhhmm[.ss]文字列,接尾辞YMwDhmsの数値 | |
1210 | + RET,日時 */ | |
1211 | +GDateTime * | |
1212 | +misc_string_to_time_datetime (GDateTime *datetime, | |
1213 | + const gchar *cymdhms) | |
1214 | +{ | |
1215 | + return misc_string_to_time_full (datetime, cymdhms, '+'); | |
1216 | +} | |
1217 | + | |
1218 | + | |
1219 | +/* ja:日時文字列→日時 | |
1220 | + datetime,基準となる日時(NULL:現在時刻) | |
1221 | + cymdhms,[[CC]YY]MMDDhhmm[.ss]文字列,接尾辞YMwDhmsの数値 | |
1222 | + sign,デフォルトの符号,NULL:+ | |
1223 | + RET,日時 */ | |
1224 | +GDateTime * | |
1225 | +misc_string_to_time_full (GDateTime *datetime, | |
1226 | + const gchar *cymdhms, | |
1227 | + const gchar sign) | |
1228 | +{ | |
1229 | + GDateTime *dt0 = NULL; | |
1230 | + | |
1231 | + if (cymdhms) | |
1232 | + { | |
1233 | + GDateTime *dt1; | |
1234 | + | |
1235 | + dt1 = datetime ? g_date_time_ref (datetime) : g_date_time_new_now_utc (); | |
1236 | + if (dt1) | |
1237 | + { | |
1238 | + const gchar *p; | |
1239 | + | |
1240 | + for (p = cymdhms; g_ascii_isdigit (*p); p++); | |
1241 | + if (*p == '.' | |
1242 | + && g_ascii_isdigit (*(p + 1)) && g_ascii_isdigit (*(p + 2))) | |
1243 | + p += 3; | |
1244 | + if (*p == '\0') | |
1245 | + { | |
1246 | + gsize len; | |
1247 | + | |
1248 | + len = p - cymdhms; | |
1249 | + if (len == 8 || len == 10 || len == 11 | |
1250 | + || len == 12 || len == 13 || len == 15) | |
1251 | + { | |
1252 | + gint i = 0, year, month, day, hour, minute, second; | |
1253 | + | |
1254 | + if (len == 12 || len == 15) | |
1255 | + { | |
1256 | + i = 4; | |
1257 | + year = 0; | |
1258 | + } | |
1259 | + else | |
1260 | + { | |
1261 | + year = g_date_time_get_year (dt1); | |
1262 | + if (len == 10 || len == 13) | |
1263 | + { | |
1264 | + i = 2; | |
1265 | + year /= 100; | |
1266 | + } | |
1267 | + } | |
1268 | + p = cymdhms; | |
1269 | + while (i > 0) | |
1270 | + { | |
1271 | + i--; | |
1272 | + year = year * 10 + g_ascii_digit_value (*p++); | |
1273 | + } | |
1274 | + month = g_ascii_digit_value (*p++) * 10; | |
1275 | + month += g_ascii_digit_value (*p++); | |
1276 | + hour = g_ascii_digit_value (*p++) * 10; | |
1277 | + hour += g_ascii_digit_value (*p++); | |
1278 | + day = g_ascii_digit_value (*p++) * 10; | |
1279 | + day += g_ascii_digit_value (*p++); | |
1280 | + minute = g_ascii_digit_value (*p++) * 10; | |
1281 | + minute += g_ascii_digit_value (*p++); | |
1282 | + if (*p++ == '.') | |
1283 | + { | |
1284 | + second = g_ascii_digit_value (*p++) * 10; | |
1285 | + second += g_ascii_digit_value (*p++); | |
1286 | + } | |
1287 | + else | |
1288 | + { | |
1289 | + second = 0; | |
1290 | + } | |
1291 | + dt0 = g_date_time_new_utc (year, month, day, | |
1292 | + hour, minute, second); | |
1293 | + } | |
1294 | + } | |
1295 | + else if (g_str_has_suffix (cymdhms, "u") | |
1296 | + || g_str_has_suffix (cymdhms, "U")) | |
1297 | + { | |
1298 | + gchar *endptr; | |
1299 | + glong value; | |
1300 | + | |
1301 | + value = g_strtol (cymdhms, &endptr, 0); | |
1302 | + if (g_strcasecmp (endptr, "u") == 0) | |
1303 | + dt0 = g_date_time_new_from_unix_utc (value); | |
1304 | + | |
1305 | + } | |
1306 | + else | |
1307 | + { | |
1308 | + gchar *tmp; | |
1309 | + | |
1310 | + tmp = sign == '-' | |
1311 | + && (*cymdhms == '.' || g_ascii_isdigit (*cymdhms)) | |
1312 | + ? g_strconcat ("-", cymdhms, NULL) : g_strdup (cymdhms); | |
1313 | + if (g_str_has_suffix (tmp, "s") || g_str_has_suffix (tmp, "S")) | |
1314 | + { | |
1315 | + gchar *endptr; | |
1316 | + gdouble value; | |
1317 | + | |
1318 | + value = g_strtod (tmp, &endptr); | |
1319 | + if (g_strcasecmp (endptr, "s") == 0) | |
1320 | + dt0 = g_date_time_add_seconds (dt1, value); | |
1321 | + } | |
1322 | + else | |
1323 | + { | |
1324 | + gchar *endptr; | |
1325 | + glong value; | |
1326 | + | |
1327 | + value = g_strtol (tmp, &endptr, 0); | |
1328 | + if (g_strcasecmp (endptr, "y") == 0) | |
1329 | + dt0 = g_date_time_add_years (dt1, value); | |
1330 | + else if (g_strcmp (endptr, "M") == 0) | |
1331 | + dt0 = g_date_time_add_months (dt1, value); | |
1332 | + else if (g_strcasecmp (endptr, "w") == 0) | |
1333 | + dt0 = g_date_time_add_weeks (dt1, value); | |
1334 | + else if (g_strcasecmp (endptr, "d") == 0) | |
1335 | + dt0 = g_date_time_add_days (dt1, value); | |
1336 | + else if (g_strcasecmp (endptr, "h") == 0) | |
1337 | + dt0 = g_date_time_add_hours (dt1, value); | |
1338 | + else if (g_strcmp (endptr, "m") == 0) | |
1339 | + dt0 = g_date_time_add_minutes (dt1, value); | |
1340 | + } | |
1341 | + g_free (tmp); | |
1342 | + } | |
1343 | + g_date_time_unref (dt1); | |
1344 | + } | |
1345 | + } | |
1346 | + return dt0; | |
1347 | +} | |
1348 | + | |
1349 | + | |
1350 | +/* ja:日時文字列→日時 | |
1351 | + cymdhms,[[CC]YY]MMDDhhmm[.ss]文字列,接尾辞YMwDhmsの数値 | |
1352 | + sign,デフォルトの符号,NULL:+ | |
1353 | + RET,日時 */ | |
1354 | +GDateTime * | |
1355 | +misc_string_to_time_sign (const gchar *cymdhms, | |
1356 | + const gchar sign) | |
1357 | +{ | |
1358 | + return misc_string_to_time_full (NULL, cymdhms, sign); | |
1359 | +} | |
1360 | + | |
1361 | + | |
1362 | +/* ja:日時文字列→UNIX時間 | |
1363 | + cymdhms,[[CC]YY]MMDDhhmm[.ss]文字列,接尾辞YMwDhmsの数値 | |
1364 | + RET,日時 */ | |
1365 | +gint64 | |
1366 | +misc_string_to_epoch (const gchar *cymdhms) | |
1367 | +{ | |
1368 | + gint64 epoch = -1; | |
1369 | + GDateTime *dt; | |
1370 | + | |
1371 | + dt = misc_string_to_time (cymdhms); | |
1372 | + if (dt) | |
1373 | + { | |
1374 | + epoch = g_date_time_to_unix (dt); | |
1375 | + g_date_time_unref (dt); | |
1376 | + } | |
1377 | + return epoch; | |
1378 | +} | |
1379 | + | |
1380 | + | |
1381 | +/* ja:日時文字列→UNIX時間 | |
1382 | + datetime,基準となる日時(NULL:現在時刻) | |
1383 | + cymdhms,[[CC]YY]MMDDhhmm[.ss]文字列,接尾辞YMwDhmsの数値 | |
1384 | + RET,日時 */ | |
1385 | +gint64 | |
1386 | +misc_string_to_epoch_datetime (GDateTime *datetime, | |
1387 | + const gchar *cymdhms) | |
1388 | +{ | |
1389 | + gint64 epoch = -1; | |
1390 | + GDateTime *dt; | |
1391 | + | |
1392 | + dt = misc_string_to_time_datetime (datetime, cymdhms); | |
1393 | + if (dt) | |
1394 | + { | |
1395 | + epoch = g_date_time_to_unix (dt); | |
1396 | + g_date_time_unref (dt); | |
1397 | + } | |
1398 | + return epoch; | |
1399 | +} | |
1400 | + | |
1401 | + | |
1402 | +/* ja:日時文字列→UNIX時間 | |
1403 | + datetime,基準となる日時(NULL:現在時刻) | |
1404 | + cymdhms,[[CC]YY]MMDDhhmm[.ss]文字列,接尾辞YMwDhmsの数値 | |
1405 | + sign,デフォルトの符号,NULL:+ | |
1406 | + RET,日時 */ | |
1407 | +gint64 | |
1408 | +misc_string_to_epoch_full (GDateTime *datetime, | |
1409 | + const gchar *cymdhms, | |
1410 | + const gchar sign) | |
1411 | +{ | |
1412 | + gint64 epoch = -1; | |
1413 | + GDateTime *dt; | |
1414 | + | |
1415 | + dt = misc_string_to_time_full (datetime, cymdhms, sign); | |
1416 | + if (dt) | |
1417 | + { | |
1418 | + epoch = g_date_time_to_unix (dt); | |
1419 | + g_date_time_unref (dt); | |
1420 | + } | |
1421 | + return epoch; | |
1422 | +} | |
1423 | + | |
1424 | + | |
1425 | +/* ja:日時文字列→UNIX時間 | |
1426 | + cymdhms,[[CC]YY]MMDDhhmm[.ss]文字列,接尾辞YMwDhmsの数値 | |
1427 | + sign,デフォルトの符号,NULL:+ | |
1428 | + RET,日時 */ | |
1429 | +gint64 | |
1430 | +misc_string_to_epoch_sign (const gchar *cymdhms, | |
1431 | + const gchar sign) | |
1432 | +{ | |
1433 | + gint64 epoch = -1; | |
1434 | + GDateTime *dt; | |
1435 | + | |
1436 | + dt = misc_string_to_time_sign (cymdhms, sign); | |
1437 | + if (dt) | |
1438 | + { | |
1439 | + epoch = g_date_time_to_unix (dt); | |
1440 | + g_date_time_unref (dt); | |
1441 | + } | |
1442 | + return epoch; | |
1443 | +} |
@@ -5,7 +5,7 @@ | ||
5 | 5 | dnl version number |
6 | 6 | MAJOR_VERSION=2 |
7 | 7 | MINOR_VERSION=7 |
8 | -MICRO_VERSION=2 | |
8 | +MICRO_VERSION=3 | |
9 | 9 | EXTRA_VERSION= |
10 | 10 | VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION$EXTRA_VERSION |
11 | 11 |
@@ -134,7 +134,7 @@ | ||
134 | 134 | AC_FUNC_STRCOLL |
135 | 135 | AC_FUNC_STRFTIME |
136 | 136 | AC_FUNC_VPRINTF |
137 | -AC_CHECK_FUNCS(clock_gettime flock ftruncate getcwd gettimeofday gmtime_r lstat nanosleep setenv sleep unsetenv usleep utime vasprintf) | |
137 | +AC_CHECK_FUNCS(clock_gettime flock ftruncate getcwd gettimeofday gmtime_r lstat nanosleep setenv sleep timegm tzset unsetenv usleep utime vasprintf) | |
138 | 138 | |
139 | 139 | AC_OUTPUT([ |
140 | 140 | Makefile |
@@ -4,9 +4,9 @@ | ||
4 | 4 | # |
5 | 5 | msgid "" |
6 | 6 | msgstr "" |
7 | -"Project-Id-Version: tmaid 2.7.2\n" | |
7 | +"Project-Id-Version: tmaid 2.7.3\n" | |
8 | 8 | "Report-Msgid-Bugs-To: http://www.maid.org/\n" |
9 | -"POT-Creation-Date: 2012-02-29 02:09+0900\n" | |
9 | +"POT-Creation-Date: 2012-03-29 04:54+0900\n" | |
10 | 10 | "PO-Revision-Date: 2002-08-11 18:10+0900\n" |
11 | 11 | "Last-Translator: Kazuki Iwamoto <iwm@maid.org>\n" |
12 | 12 | "Language-Team: Kazuki Iwamoto <iwm@maid.org>\n" |
@@ -80,7 +80,7 @@ | ||
80 | 80 | msgid "_Bottom" |
81 | 81 | msgstr "下(_B)" |
82 | 82 | |
83 | -#: orz/orzpref.c:191 src/tmaid.c:120 src/sigmain.c:317 | |
83 | +#: orz/orzpref.c:191 src/tmaid.c:120 src/sigmain.c:335 | |
84 | 84 | msgid "Window Size" |
85 | 85 | msgstr "ウインドウのサイズ" |
86 | 86 |
@@ -88,15 +88,15 @@ | ||
88 | 88 | msgid "Tab Position" |
89 | 89 | msgstr "タブの位置" |
90 | 90 | |
91 | -#: src/tmaid.c:116 src/sigmain.c:314 | |
91 | +#: src/tmaid.c:116 src/sigmain.c:332 | |
92 | 92 | msgid "History" |
93 | 93 | msgstr "ファイルの履歴" |
94 | 94 | |
95 | -#: src/tmaid.c:117 src/sigmain.c:315 | |
95 | +#: src/tmaid.c:117 src/sigmain.c:333 | |
96 | 96 | msgid "Caret Position" |
97 | 97 | msgstr "初期のキャレット位置" |
98 | 98 | |
99 | -#: src/tmaid.c:118 src/sigmain.c:316 | |
99 | +#: src/tmaid.c:118 src/sigmain.c:334 | |
100 | 100 | msgid "New File" |
101 | 101 | msgstr "新規ファイルを開く" |
102 | 102 |
@@ -104,7 +104,7 @@ | ||
104 | 104 | msgid "Profile" |
105 | 105 | msgstr "プロファイル" |
106 | 106 | |
107 | -#: src/tmaid.c:121 src/sigmain.c:318 | |
107 | +#: src/tmaid.c:121 src/sigmain.c:336 | |
108 | 108 | msgid "Open Window" |
109 | 109 | msgstr "新規ウインドウを開く" |
110 | 110 |