[nautilus] eel: remove unused eel_strdup_strftime()



commit 0e5bc91c5a97940c2ca916646498ddd210268d23
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Wed Apr 11 12:11:14 2012 -0400

    eel: remove unused eel_strdup_strftime()
    
    And there was much rejoice.

 configure.in              |   19 ----
 eel/eel-glib-extensions.c |  212 ---------------------------------------------
 eel/eel-glib-extensions.h |    4 -
 3 files changed, 0 insertions(+), 235 deletions(-)
---
diff --git a/configure.in b/configure.in
index e1c24cf..3e71d0d 100644
--- a/configure.in
+++ b/configure.in
@@ -231,25 +231,6 @@ fi
 AC_SUBST(WARNING_CFLAGS)
 
 dnl ===========================================================================
-
-dnl strftime checks
-
-AC_TRY_RUN([#include <time.h>
-                int main ()
-                {
-                  char buf[100];
-                  struct tm tm = {0};
-                  tm.tm_year = 99;
-                  if (strftime(buf, 100, "%EY", &tm) == 4 &&
-		      strcmp (buf, "1999")==0)
-                    return 0;
-                  return 1;
-                }
-            ],
-	    AC_DEFINE(HAVE_STRFTIME_EXTENSION, 1, [Define if strftime supports %E and %O modifiers.])
-            )
-
-dnl ===========================================================================
 dnl Check for Tracker
 dnl ===========================================================================
 
diff --git a/eel/eel-glib-extensions.c b/eel/eel-glib-extensions.c
index 1274e3c..8008172 100644
--- a/eel/eel-glib-extensions.c
+++ b/eel/eel-glib-extensions.c
@@ -33,175 +33,6 @@
 #include <glib-object.h>
 #include <math.h>
 #include <stdlib.h>
-#include <sys/time.h>
-#include <sys/utsname.h>
-#include <time.h>
-#include <locale.h>
-
-/* Legal conversion specifiers, as specified in the C standard. */
-#define C_STANDARD_STRFTIME_CHARACTERS "aAbBcdHIjmMpSUwWxXyYZ"
-#define C_STANDARD_NUMERIC_STRFTIME_CHARACTERS "dHIjmMSUwWyY"
-#define SUS_EXTENDED_STRFTIME_MODIFIERS "EO"
-
-#define SAFE_SHELL_CHARACTERS "-_0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
-
-/**
- * eel_strdup_strftime:
- *
- * Cover for standard date-and-time-formatting routine strftime that returns
- * a newly-allocated string of the correct size. The caller is responsible
- * for g_free-ing the returned string.
- *
- * Besides the buffer management, there are two differences between this
- * and the library strftime:
- *
- *   1) The modifiers "-" and "_" between a "%" and a numeric directive
- *      are defined as for the GNU version of strftime. "-" means "do not
- *      pad the field" and "_" means "pad with spaces instead of zeroes".
- *   2) Non-ANSI extensions to strftime are flagged at runtime with a
- *      warning, so it's easy to notice use of the extensions without
- *      testing with multiple versions of the library.
- *
- * @format: format string to pass to strftime. See strftime documentation
- * for details.
- * @time_pieces: date/time, in struct format.
- * 
- * Return value: Newly allocated string containing the formatted time.
- **/
-char *
-eel_strdup_strftime (const char *format, struct tm *time_pieces)
-{
-	GString *string;
-	const char *remainder, *percent;
-	char code[4], buffer[512];
-	char *piece, *result, *converted;
-	size_t string_length;
-	gboolean strip_leading_zeros, turn_leading_zeros_to_spaces;
-	char modifier;
-	int i;
-
-	/* Format could be translated, and contain UTF-8 chars,
-	 * so convert to locale encoding which strftime uses */
-	converted = g_locale_from_utf8 (format, -1, NULL, NULL, NULL);
-	g_return_val_if_fail (converted != NULL, NULL);
-	
-	string = g_string_new ("");
-	remainder = converted;
-
-	/* Walk from % character to % character. */
-	for (;;) {
-		percent = strchr (remainder, '%');
-		if (percent == NULL) {
-			g_string_append (string, remainder);
-			break;
-		}
-		g_string_append_len (string, remainder,
-				     percent - remainder);
-
-		/* Handle the "%" character. */
-		remainder = percent + 1;
-		switch (*remainder) {
-		case '-':
-			strip_leading_zeros = TRUE;
-			turn_leading_zeros_to_spaces = FALSE;
-			remainder++;
-			break;
-		case '_':
-			strip_leading_zeros = FALSE;
-			turn_leading_zeros_to_spaces = TRUE;
-			remainder++;
-			break;
-		case '%':
-			g_string_append_c (string, '%');
-			remainder++;
-			continue;
-		case '\0':
-			g_warning ("Trailing %% passed to eel_strdup_strftime");
-			g_string_append_c (string, '%');
-			continue;
-		default:
-			strip_leading_zeros = FALSE;
-			turn_leading_zeros_to_spaces = FALSE;
-			break;
-		}
-
-		modifier = 0;
-		if (strchr (SUS_EXTENDED_STRFTIME_MODIFIERS, *remainder) != NULL) {
-			modifier = *remainder;
-			remainder++;
-
-			if (*remainder == 0) {
-				g_warning ("Unfinished %%%c modifier passed to eel_strdup_strftime", modifier);
-				break;
-			}
-		} 
-		
-		if (strchr (C_STANDARD_STRFTIME_CHARACTERS, *remainder) == NULL) {
-			g_warning ("eel_strdup_strftime does not support "
-				   "non-standard escape code %%%c",
-				   *remainder);
-		}
-
-		/* Convert code to strftime format. We have a fixed
-		 * limit here that each code can expand to a maximum
-		 * of 512 bytes, which is probably OK. There's no
-		 * limit on the total size of the result string.
-		 */
-		i = 0;
-		code[i++] = '%';
-		if (modifier != 0) {
-#ifdef HAVE_STRFTIME_EXTENSION
-			code[i++] = modifier;
-#endif
-		}
-		code[i++] = *remainder;
-		code[i++] = '\0';
-		string_length = strftime (buffer, sizeof (buffer),
-					  code, time_pieces);
-		if (string_length == 0) {
-			/* We could put a warning here, but there's no
-			 * way to tell a successful conversion to
-			 * empty string from a failure.
-			 */
-			buffer[0] = '\0';
-		}
-
-		/* Strip leading zeros if requested. */
-		piece = buffer;
-		if (strip_leading_zeros || turn_leading_zeros_to_spaces) {
-			if (strchr (C_STANDARD_NUMERIC_STRFTIME_CHARACTERS, *remainder) == NULL) {
-				g_warning ("eel_strdup_strftime does not support "
-					   "modifier for non-numeric escape code %%%c%c",
-					   remainder[-1],
-					   *remainder);
-			}
-			if (*piece == '0') {
-				do {
-					piece++;
-				} while (*piece == '0');
-				if (!g_ascii_isdigit (*piece)) {
-				    piece--;
-				}
-			}
-			if (turn_leading_zeros_to_spaces) {
-				memset (buffer, ' ', piece - buffer);
-				piece = buffer;
-			}
-		}
-		remainder++;
-
-		/* Add this piece. */
-		g_string_append (string, piece);
-	}
-	
-	/* Convert the string back into utf-8. */
-	result = g_locale_to_utf8 (string->str, -1, NULL, NULL, NULL);
-
-	g_string_free (string, TRUE);
-	g_free (converted);
-
-	return result;
-}
 
 /**
  * eel_g_str_list_equal
@@ -428,29 +259,6 @@ eel_test_predicate (gpointer data,
 	return g_ascii_strcasecmp (data, callback_data) <= 0;
 }
 
-static char *
-test_strftime (const char *format,
-	       int year,
-	       int month,
-	       int day,
-	       int hour,
-	       int minute,
-	       int second)
-{
-	struct tm time_pieces;
-
-	time_pieces.tm_sec = second;
-	time_pieces.tm_min = minute;
-	time_pieces.tm_hour = hour;
-	time_pieces.tm_mday = day;
-	time_pieces.tm_mon = month - 1;
-	time_pieces.tm_year = year - 1900;
-	time_pieces.tm_isdst = -1;
-	mktime (&time_pieces);
-
-	return eel_strdup_strftime (format, &time_pieces);
-}
-
 void
 eel_self_check_glib_extensions (void)
 {
@@ -464,7 +272,6 @@ eel_self_check_glib_extensions (void)
 	GList *expected_failed;
 	GList *actual_passed;
 	GList *actual_failed;
-	char *huge_string;
 	
 	/* eel_g_str_list_equal */
 
@@ -538,25 +345,6 @@ eel_self_check_glib_extensions (void)
 	g_list_free (actual_passed);
 	g_list_free (expected_failed);
 	g_list_free (actual_failed);
-
-	/* eel_strdup_strftime */
-	huge_string = g_new (char, 10000+1);
-	memset (huge_string, 'a', 10000);
-	huge_string[10000] = '\0';
-
-	setlocale (LC_TIME, "C");
-
-	EEL_CHECK_STRING_RESULT (test_strftime ("", 2000, 1, 1, 0, 0, 0), "");
-	EEL_CHECK_STRING_RESULT (test_strftime (huge_string, 2000, 1, 1, 0, 0, 0), huge_string);
-	EEL_CHECK_STRING_RESULT (test_strftime ("%%", 2000, 1, 1, 1, 0, 0), "%");
-	EEL_CHECK_STRING_RESULT (test_strftime ("%%%%", 2000, 1, 1, 1, 0, 0), "%%");
-	EEL_CHECK_STRING_RESULT (test_strftime ("%m/%d/%y, %I:%M %p", 2000, 1, 1, 1, 0, 0), "01/01/00, 01:00 AM");
-	EEL_CHECK_STRING_RESULT (test_strftime ("%-m/%-d/%y, %-I:%M %p", 2000, 1, 1, 1, 0, 0), "1/1/00, 1:00 AM");
-	EEL_CHECK_STRING_RESULT (test_strftime ("%_m/%_d/%y, %_I:%M %p", 2000, 1, 1, 1, 0, 0), " 1/ 1/00,  1:00 AM");
-
-	setlocale (LC_TIME, "");
-
-	g_free (huge_string);
 }
 
 #endif /* !EEL_OMIT_SELF_CHECK */
diff --git a/eel/eel-glib-extensions.h b/eel/eel-glib-extensions.h
index 389eb5c..05a78a5 100644
--- a/eel/eel-glib-extensions.h
+++ b/eel/eel-glib-extensions.h
@@ -37,10 +37,6 @@ typedef guint eel_boolean_bit;
 typedef gboolean (* EelPredicateFunction) (gpointer data,
 					   gpointer callback_data);
 
-/* Date & time functions. */
-char *      eel_strdup_strftime                         (const char            *format,
-							 struct tm             *time_pieces);
-
 /* GList functions. */
 gboolean    eel_g_lists_sort_and_check_for_intersection (GList                **list_a,
 							 GList                **list_b);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]