Discussion:
[PATCH 1/2] track_info.c: cosmetic change
Johannes Weißl
2011-01-26 00:50:02 UTC
Permalink
---
track_info.c | 7 ++-----
1 files changed, 2 insertions(+), 5 deletions(-)

diff --git a/track_info.c b/track_info.c
index 38763f0..f32395e 100644
--- a/track_info.c
+++ b/track_info.c
@@ -38,11 +38,8 @@ static void track_info_free(struct track_info *ti)
struct track_info *track_info_new(const char *filename)
{
struct track_info *ti;
- int size = strlen(filename) + 1;
-
- ti = xmalloc(sizeof(struct track_info));
- ti->filename = xmalloc(size);
- memcpy(ti->filename, filename, size);
+ ti = xnew(struct track_info, 1);
+ ti->filename = xstrdup(filename);
ti->ref = 1;
return ti;
}
--
1.7.2.3
Johannes Weißl
2011-01-26 00:50:03 UTC
Permalink
Filenames can be in any encoding, but strcasecmp() is only valid for ASCII.
---
track_info.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/track_info.c b/track_info.c
index f32395e..334ac9e 100644
--- a/track_info.c
+++ b/track_info.c
@@ -136,7 +136,7 @@ int track_info_cmp(const struct track_info *a, const struct track_info *b, const
}
if (strcmp(key, "filename") == 0) {
/* NOTE: filenames are not necessarily UTF-8 */
- res = strcasecmp(a->filename, b->filename);
+ res = strcoll(a->filename, b->filename);
if (res)
break;
continue;
--
1.7.2.3
Gregory Petrosyan
2011-01-26 20:20:33 UTC
Permalink
Pushed both patches to master, thanks again!

Gregory
Gregory Petrosyan
2011-01-26 20:33:28 UTC
Permalink
                       /* NOTE: filenames are not necessarily UTF-8 */
-                       res = strcasecmp(a->filename, b->filename);
+                       res = strcoll(a->filename, b->filename);
Hm, after some thinking this looks like -maint material, maybe? What
do you thin
Johannes Weißl
2011-01-26 22:04:01 UTC
Permalink
Post by Gregory Petrosyan
                       /* NOTE: filenames are not necessarily UTF-8 */
-                       res = strcasecmp(a->filename, b->filename);
+                       res = strcoll(a->filename, b->filename);
Hm, after some thinking this looks like -maint material, maybe? What
do you think?
Master is the right place, because only there we call setlocale(LC_COLLATE, "").
Otherwise maint would be alright, but isn't it difficult if you have
already pushed it to master?


Johannes
Gregory Petrosyan
2011-01-30 13:31:44 UTC
Permalink
Post by Johannes Weißl
Post by Gregory Petrosyan
                       /* NOTE: filenames are not necessarily UTF-8 */
-                       res = strcasecmp(a->filename, b->filename);
+                       res = strcoll(a->filename, b->filename);
Hm, after some thinking this looks like -maint material, maybe? What
do you think?
Master is the right place, because only there we call setlocale(LC_COLLATE, "").
Otherwise maint would be alright, but isn't it difficult if you have
already pushed it to master?
I don't think it will be very difficult; let it be in master for now, though.

Gregory

Loading...