@@ -62,8 +62,8 @@ static void hash_fd(int fd, const char *type, const char *path, unsigned flags,
# include <stdio.h>
# include <stdlib.h>
- int setbinaryfd(int fd)
- {
+int setbinaryfd(int fd)
+{
attrib_t attr;
int rc;
@@ -74,7 +74,7 @@ static void hash_fd(int fd, const char *type, const char *path, unsigned flags,
rc = __fchattr(fd, &attr, sizeof(attr));
return rc;
- }
+}
# endif
#endif
@@ -1315,15 +1315,28 @@ static struct attr_check *check;
static const char* get_platform() {
struct utsname uname_info;
+ char *result;
+ if(!uname_info.sysname)
+ {
+ result = (char *)malloc(strlen(uname_info.sysname)+1);
+ int index=0;
+ while(index <= strlen(uname_info.sysname))
+ {
+ *result = uname_info.sysname[index];
+ ++result;
+ ++index;
+ }
+ }
if (uname(&uname_info))
die(_("uname() failed with error '%s' (%d)\n"),
strerror(errno),
errno);
- if (!strcmp(uname_info.sysname, "OS/390"))
- return "zos";
- return uname_info.sysname;
+ if (!strcmp(uname_info.sysname, "OS/390"))
+ result="zos";
+
+ return result;
}
@@ -1331,11 +1344,10 @@ void convert_attrs(struct index_state *istate,
struct conv_attrs *ca, const char *path)
{
struct attr_check_item *ccheck = NULL;
- struct strbuf platform_working_tree_encoding = STRBUF_INIT;
+ struct strbuf platform_working_tree_encoding = STRBUF_INIT;
strbuf_addf(&platform_working_tree_encoding, "%s-working-tree-encoding", get_platform());
-
if (!check) {
check = attr_check_initl("crlf", "ident", "filter",
"eol", "text", "working-tree-encoding", platform_working_tree_encoding.buf,
@@ -130,17 +130,17 @@ int fstat_checkout_output(int fd, const struct checkout *state, struct stat *st)
void tag_file_as_working_tree_encoding(struct index_state *istate, char* path, int fd) {
struct conv_attrs ca;
convert_attrs(istate, &ca, path);
- if (ca.attr_action != CRLF_BINARY) {
- if (ca.working_tree_encoding)
- __chgfdcodeset(fd, ca.working_tree_encoding);
- else
- __setfdtext(fd);
- }
- else {
- __setfdbinary(fd);
- }
-
- __disableautocvt(fd);
+ if (ca.attr_action != CRLF_BINARY) {
+ if (ca.working_tree_encoding)
+ __chgfdcodeset(fd, ca.working_tree_encoding);
+ else
+ __setfdtext(fd);
+ }
+ else {
+ __setfdbinary(fd);
+ }
+
+ __disableautocvt(fd);
}
#endif
@@ -2557,15 +2557,15 @@ int index_path(struct index_state *istate, struct object_id *oid,
switch (st->st_mode & S_IFMT) {
case S_IFREG:
#ifdef __MVS__
- validate_codeset(istate, path, &autocvtToASCII);
+ validate_codeset(istate, path, &autocvtToASCII);
#endif
fd = open(path, O_RDONLY);
if (fd < 0)
return error_errno("open(\"%s\")", path);
#ifdef __MVS__
- if (!autocvtToASCII)
- __disableautocvt(fd);
+ if (!autocvtToASCII)
+ __disableautocvt(fd);
#endif
if (index_fd(istate, oid, fd, st, OBJ_BLOB, path, flags) < 0)