if (from_code == CODE_SJIS && to_code == CODE_UTF8) {
for (i = 0; i < len; i++)
- if (name[i] == '\xff') name[i] = '/';
+ if ((unsigned char)name[i] == LHA_PATHSEP) name[i] = '/';
sjis_to_utf8(tmp, name, sizeof(tmp));
strncpy(name, tmp, size);
name[size-1] = 0;
len = strlen(name);
for (i = 0; i < len; i++)
- if (name[i] == '/') name[i] = '\xff';
+ if (name[i] == '/') name[i] = LHA_PATHSEP;
+ from_code = CODE_UTF8;
}
else if (from_code == CODE_UTF8 && to_code == CODE_SJIS) {
for (i = 0; i < len; i++)
- if (name[i] == '\xff') name[i] = '/';
+ if ((unsigned char)name[i] == LHA_PATHSEP) name[i] = '/';
utf8_to_sjis(tmp, name, sizeof(tmp));
strncpy(name, tmp, size);
name[size-1] = 0;
len = strlen(name);
for (i = 0; i < len; i++)
- if (name[i] == '/') name[i] = '\xff';
+ if (name[i] == '/') name[i] = LHA_PATHSEP;
+ from_code = CODE_SJIS;
}
#endif
"\xff\\/", "\xff\xff\xff", NONE);
if (hdr->header_level != HEADER_LEVEL2) {
- if (p = (char *) strrchr(lzname, DELIM2))
+ if (p = (char *) strrchr(lzname, LHA_PATHSEP))
name_length = strlen(++p);
else
name_length = strlen(lzname);
put_byte(hdr->user[i]);
}
- if (p = (char *) strrchr(lzname, DELIM2)) {
+ if (p = (char *) strrchr(lzname, LHA_PATHSEP)) {
int i;
name_length = p - lzname + 1;
data[I_HEADER_CHECKSUM] = calc_sum(data + I_METHOD, header_size);
} else { /* header level 2 */
int i;
- if (p = (char *) strrchr(lzname, DELIM2))
+ if (p = (char *) strrchr(lzname, LHA_PATHSEP))
name_length = strlen(++p);
else {
p = lzname;
#define CURRENT_UNIX_MINOR_VERSION 0x00
-#define DELIM ('/')
-#define DELIM2 (0xff)
-#define DELIMSTR "/"
+#define LHA_PATHSEP 0xff /* path separator of the
+ filename in lha header.
+ it should compare with
+ `unsigned char' or `int',
+ that is not '\xff', but 0xff. */
#define OSK_RW_RW_RW 0000033
#define OSK_FILE_REGULAR 0000000
}
else
#endif
- if (c == '\\' || c == DELIM || c == DELIM2) {
+ if (c == '\\' || c == '/' || c == LHA_PATHSEP) {
*p = delim;
path = p + 1;
}
return 0;
}
+#if !STRCHR_8BIT_CLEAN
+/* 8 bit clean strchr()/strrchr() */
+char *
+xstrchr(const char *s, int c)
+{
+ while (*s) {
+ if ((unsigned char)*s == (unsigned char)c)
+ return s;
+ s++;
+ }
+
+ return 0;
+}
+
+char *
+xstrrchr(const char *s, int c)
+{
+ char *p = 0;
+
+ while (*s) {
+ if ((unsigned char)*s == (unsigned char)c)
+ p = s;
+ s++;
+ }
+
+ return p;
+}
+#endif
+
/* Local Variables: */
/* mode:c */
/* tab-width:4 */