From 58279423cfb4c6fa816d19f7078fdf1e111fbc55 Mon Sep 17 00:00:00 2001 From: Jim Evins Date: Mon, 19 Nov 2007 04:49:00 +0000 Subject: [PATCH] 2007-11-18 Jim Evins * libglabels/Makefile.am: * libglabels/str.h: * libglabels/str.c: Added lgl_str_utf8_casecmp(). * libglabels/libglabels-private.h: Use lgl_str_utf8_casecmp() for UTF8_EQUAL macro -- do case insensitive comparisons. * libglabels/db.c: (lgl_db_get_brand_list): Use lgl_str_utf8_casecmp() to determine if we have seen brand before when building brand list. git-svn-id: https://glabels.svn.sourceforge.net/svnroot/glabels/trunk@692 f5e0f49d-192f-0410-a22d-a8d8700d0965 --- glabels2/ChangeLog | 12 ++++ glabels2/libglabels/Makefile.am | 4 +- glabels2/libglabels/db.c | 4 +- glabels2/libglabels/libglabels-private.h | 4 +- glabels2/libglabels/str.c | 70 ++++++++++++++++++++++++ glabels2/libglabels/str.h | 41 ++++++++++++++ 6 files changed, 131 insertions(+), 4 deletions(-) create mode 100644 glabels2/libglabels/str.c create mode 100644 glabels2/libglabels/str.h diff --git a/glabels2/ChangeLog b/glabels2/ChangeLog index b4199448..6c4498cc 100644 --- a/glabels2/ChangeLog +++ b/glabels2/ChangeLog @@ -1,3 +1,15 @@ +2007-11-18 Jim Evins + + * libglabels/Makefile.am: + * libglabels/str.h: + * libglabels/str.c: + Added lgl_str_utf8_casecmp(). + * libglabels/libglabels-private.h: + Use lgl_str_utf8_casecmp() for UTF8_EQUAL macro -- do case insensitive comparisons. + * libglabels/db.c: (lgl_db_get_brand_list): + Use lgl_str_utf8_casecmp() to determine if we have seen brand before when building + brand list. + 2007-11-18 Jim Evins * data/glade/template-designer.glade: diff --git a/glabels2/libglabels/Makefile.am b/glabels2/libglabels/Makefile.am index bc6774f4..5bc36773 100644 --- a/glabels2/libglabels/Makefile.am +++ b/glabels2/libglabels/Makefile.am @@ -33,7 +33,9 @@ libglabels_la_SOURCES = \ xml-template.h \ xml-template.c \ xml.h \ - xml.c + xml.c \ + str.h \ + str.c libglabelsinclude_HEADERS = \ libglabels.h \ diff --git a/glabels2/libglabels/db.c b/glabels2/libglabels/db.c index 8e4f1924..1411408c 100644 --- a/glabels2/libglabels/db.c +++ b/glabels2/libglabels/db.c @@ -999,11 +999,11 @@ lgl_db_get_brand_list (const gchar *paper_id, alias = (lglTemplateAlias *)p_alias->data; if ( !g_list_find_custom (brands, alias->brand, - (GCompareFunc)g_utf8_collate) ) + (GCompareFunc)lgl_str_utf8_casecmp) ) { brands = g_list_insert_sorted (brands, g_strdup (alias->brand), - (GCompareFunc)g_utf8_collate); + (GCompareFunc)lgl_str_utf8_casecmp); } } } diff --git a/glabels2/libglabels/libglabels-private.h b/glabels2/libglabels/libglabels-private.h index bf171270..dd8bda83 100644 --- a/glabels2/libglabels/libglabels-private.h +++ b/glabels2/libglabels/libglabels-private.h @@ -30,6 +30,8 @@ #include #include +#include "str.h" + /* Data system and user data directories. (must free w/ g_free()) */ #define LGL_SYSTEM_DATA_DIR g_build_filename (LIBGLABELS_TEMPLATE_DIR, NULL) #define LGL_USER_DATA_DIR g_build_filename (g_get_home_dir (), ".glabels", NULL) @@ -37,7 +39,7 @@ #undef G_LOG_DOMAIN #define G_LOG_DOMAIN "LibGlabels" -#define UTF8_EQUAL(s1,s2) (!g_utf8_collate (s1, s2)) +#define UTF8_EQUAL(s1,s2) (!lgl_str_utf8_casecmp (s1, s2)) #define ASCII_EQUAL(s1,s2) (!g_ascii_strcasecmp (s1, s2)) diff --git a/glabels2/libglabels/str.c b/glabels2/libglabels/str.c new file mode 100644 index 00000000..adf52f2b --- /dev/null +++ b/glabels2/libglabels/str.c @@ -0,0 +1,70 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */ + +/* + * (LIBGLABELS) Template library for GLABELS + * + * str.c: libGLabels string utilities + * + * Copyright (C) 2007 Jim Evins . + * + * This file is part of the LIBGLABELS library. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, + * MA 02111-1307, USA + */ +#include + +#include "str.h" + + +/*===========================================*/ +/* Private types */ +/*===========================================*/ + + +/*===========================================*/ +/* Private globals */ +/*===========================================*/ + + +/*===========================================*/ +/* Local function prototypes */ +/*===========================================*/ + + +/*===========================================*/ +/* Functions. */ +/*===========================================*/ + +gint +lgl_str_utf8_casecmp (const gchar *s1, + const gchar *s2) +{ + gchar *folded_s1; + gchar *folded_s2; + gint result; + + folded_s1 = g_utf8_casefold (s1, -1); + folded_s2 = g_utf8_casefold (s2, -1); + + result = g_utf8_collate (folded_s1, folded_s2); + + g_free (folded_s1); + g_free (folded_s2); + + return result; +} + + diff --git a/glabels2/libglabels/str.h b/glabels2/libglabels/str.h new file mode 100644 index 00000000..bc6312f7 --- /dev/null +++ b/glabels2/libglabels/str.h @@ -0,0 +1,41 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */ + +/* + * (LIBGLABELS) Template library for GLABELS + * + * str.h: libGLabels string utilities header file + * + * Copyright (C) 2007 Jim Evins . + * + * This file is part of the LIBGLABELS library. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, + * MA 02111-1307, USA + */ + +#ifndef __STR_H__ +#define __STR_H__ + +#include + +G_BEGIN_DECLS + +gint lgl_str_utf8_casecmp (const gchar *s1, + const gchar *s2); + +G_END_DECLS + + +#endif /* __STR_H__ */ -- 2.39.5