commit f291075326e2020a07a5d37ec9ae0454666ea3df
parent 378ae10e5e4a8b332e2418c96bd0fb160be22949
Author: Colin Leroy <colin@colino.net>
Date: Thu, 24 Apr 2008 15:54:19 +0000
2008-04-24 [colin] 3.4.0cvs11
* src/inc.c
* src/inc.h
Trace inc locks
* src/ldif.c
* src/ldif.h
Fix bug 1581, 'Bad File Format during Import LDIF':
Use dynamically allocated buffers; also, allow
importing contacts with no email address
Diffstat:
7 files changed, 37 insertions(+), 13 deletions(-)
diff --git a/ChangeLog b/ChangeLog
@@ -1,3 +1,14 @@
+2008-04-24 [colin] 3.4.0cvs11
+
+ * src/inc.c
+ * src/inc.h
+ Trace inc locks
+ * src/ldif.c
+ * src/ldif.h
+ Fix bug 1581, 'Bad File Format during Import LDIF':
+ Use dynamically allocated buffers; also, allow
+ importing contacts with no email address
+
2008-04-24 [colin] 3.4.0cvs10
* src/prefs_common.c
diff --git a/PATCHSETS b/PATCHSETS
@@ -3306,3 +3306,4 @@
( cvs diff -u -r 1.1.2.46 -r 1.1.2.47 manual/advanced.xml; ) > 3.4.0cvs8.patchset
( cvs diff -u -r 1.382.2.443 -r 1.382.2.444 src/compose.c; cvs diff -u -r 1.52.2.62 -r 1.52.2.63 src/prefs_folder_item.c; cvs diff -u -r 1.12.2.61 -r 1.12.2.62 src/prefs_template.c; cvs diff -u -r 1.8.2.33 -r 1.8.2.34 src/quote_fmt.c; ) > 3.4.0cvs9.patchset
( cvs diff -u -r 1.204.2.166 -r 1.204.2.167 src/prefs_common.c; ) > 3.4.0cvs10.patchset
+( cvs diff -u -r 1.149.2.89 -r 1.149.2.90 src/inc.c; cvs diff -u -r 1.29.2.13 -r 1.29.2.14 src/inc.h; cvs diff -u -r 1.12.2.15 -r 1.12.2.16 src/ldif.c; cvs diff -u -r 1.5.2.6 -r 1.5.2.7 src/ldif.h; ) > 3.4.0cvs11.patchset
diff --git a/configure.ac b/configure.ac
@@ -11,7 +11,7 @@ MINOR_VERSION=4
MICRO_VERSION=0
INTERFACE_AGE=0
BINARY_AGE=0
-EXTRA_VERSION=10
+EXTRA_VERSION=11
EXTRA_RELEASE=
EXTRA_GTK2_VERSION=
diff --git a/src/inc.c b/src/inc.c
@@ -82,7 +82,7 @@ static gboolean maemo_warned_offline = FALSE;
static GList *inc_dialog_list = NULL;
-static guint inc_lock_count = 0;
+guint inc_lock_count = 0;
static GdkPixbuf *currentpix;
static GdkPixbuf *errorpix;
@@ -1387,12 +1387,12 @@ static gint get_spool(FolderItem *dest, const gchar *mbox, PrefsAccount *account
return msgs;
}
-void inc_lock(void)
+void inc_lock_real(void)
{
inc_lock_count++;
}
-void inc_unlock(void)
+void inc_unlock_real(void)
{
if (inc_lock_count > 0)
inc_lock_count--;
diff --git a/src/inc.h b/src/inc.h
@@ -92,8 +92,19 @@ gboolean inc_is_active (void);
void inc_cancel_all (void);
-void inc_lock (void);
-void inc_unlock (void);
+extern guint inc_lock_count;
+#define inc_lock() { \
+ inc_lock_real(); \
+ debug_print("called inc_lock (lock count %d)\n", inc_lock_count); \
+}
+
+#define inc_unlock() { \
+ inc_unlock_real(); \
+ debug_print("called inc_unlock (lock count %d)\n", inc_lock_count); \
+}
+
+void inc_lock_real (void);
+void inc_unlock_real (void);
void inc_autocheck_timer_init (MainWindow *mainwin);
void inc_autocheck_timer_set (void);
diff --git a/src/ldif.c b/src/ldif.c
@@ -47,7 +47,6 @@ LdifFile *ldif_create() {
ldifFile = g_new0( LdifFile, 1 );
ldifFile->path = NULL;
ldifFile->file = NULL;
- ldifFile->bufptr = ldifFile->buffer;
ldifFile->hashFields = g_hash_table_new( g_str_hash, g_str_equal );
ldifFile->tempList = NULL;
ldifFile->dirtyFlag = TRUE;
@@ -226,8 +225,6 @@ static gint ldif_open_file( LdifFile* ldifFile ) {
}
/* Setup a buffer area */
- ldifFile->buffer[0] = '\0';
- ldifFile->bufptr = ldifFile->buffer;
ldifFile->retVal = MGU_SUCCESS;
return ldifFile->retVal;
}
@@ -248,14 +245,15 @@ static void ldif_close_file( LdifFile *ldifFile ) {
* \return ptr to buffer where line starts.
*/
static gchar *ldif_get_line( LdifFile *ldifFile ) {
- gchar buf[ LDIFBUFSIZE ];
+ gchar *buf = g_malloc(LDIFBUFSIZE);
gint ch;
int i = 0;
+ int cur_alloc = LDIFBUFSIZE;
if( feof( ldifFile->file ) )
return NULL;
- while( i < LDIFBUFSIZE-1 ) {
+ while( i < cur_alloc-1 ) {
ch = fgetc( ldifFile->file );
if (ferror( ldifFile->file ))
ldifFile->retVal = MGU_ERROR_READ;
@@ -272,6 +270,10 @@ static gchar *ldif_get_line( LdifFile *ldifFile ) {
break;
buf[i] = ch;
i++;
+ if (i == cur_alloc-1 && cur_alloc < LDIFBUFSIZE * 32) {
+ cur_alloc += LDIFBUFSIZE;
+ buf = g_realloc(buf, cur_alloc);
+ }
}
buf[i] = '\0';
@@ -394,7 +396,7 @@ static void ldif_build_items(
ItemEMail *email;
nodeAddress = rec->listAddress;
- if( nodeAddress == NULL ) return;
+// if( nodeAddress == NULL ) return;
/* Find longest first name in list */
nodeFirst = rec->listFName;
diff --git a/src/ldif.h b/src/ldif.h
@@ -87,7 +87,6 @@ struct _LdifFile {
FILE *file;
gchar *path;
gchar *bufptr;
- gchar buffer[ LDIFBUFSIZE ];
gint retVal;
GHashTable *hashFields;
GList *tempList;