Fix bug with handling of non-Unix lha archives
The only lha archives that have UID/GID metadata are those generated by the Unix version of lha. Archives from other systems just show empty whitespace at this point in the list output. As a result, trying to open such archives with xarchiver just produced an empty window. This detects when there is whitespace in the UID/GID column and handles it appropriately.
This PR makes most .lzh archives in the lhasa test suite open correctly; the two exceptions are:
I have expanded this PR to fix a similar parsing bug when the timestamp field is empty. PR title and description have been updated accordingly.
@ib - any chance you can review my change?
Let's talk about about "lha: Fix handling of non-Unix lha archives" first.
The commit message describes the problem and the patch very well, but please drop the "lha:" prefix. We don't use such prefixes.
Patch source comments to follow.
Now "lha: Fix handling of missing timestamp field":
Do not refer to another bug. Describe the commit as you did in "lha: Fix handling of non-Unix lha archives".
EDIT: Instead of the "lha:" prefix: "Fix handling of missing timestamp field in lha archives"
Mac OS archives have "[Mac OS]" listed in the permissions column, and this gets split as "[Mac" in the permissions column and "OS]" in the UID/GID column
I'll fix this after your pull requests:
--- a/src/lha.c
+++ b/src/lha.c
@@ -69,7 +69,7 @@ static void xa_lha_parse_output (gchar *line, XArchive *archive)
{
XEntry *entry;
gpointer item[7];
- gchar *filename, time[6];
+ gchar *filename, permissions[11], time[6];
gboolean dir, link;
USE_PARSER;
@@ -94,12 +94,16 @@ static void xa_lha_parse_output (gchar *line, XArchive *archive)
return;
}
- /* permissions */
- NEXT_ITEM(item[5]);
+ /* permissions (may contain spaces) */
+
+ item[5] = strncpy(permissions, line, sizeof(permissions));
+ permissions[sizeof(permissions) -1] = 0;
dir = (*(char *) item[5] == 'd');
link = (*(char *) item[5] == 'l');
+ LINE_SKIP(sizeof(permissions));
+
/* uid/gid */
NEXT_ITEM(item[6]);
Are you going to revise your pull request?
Are you going to revise your pull request?
Sorry I've been quite busy lately as I recently started a new job, I'll try to find the time to get around to addressing your comments when I can.
Sorry I've been quite busy lately
No problem! It might be easier if I fix it.
Fixed.
Thanks!