...
|
...
|
@@ -28,9 +28,9 @@
|
28
|
28
|
//#define CHUNKSIZE 32768
|
29
|
29
|
//#define CHUNKSIZE 4096
|
30
|
30
|
//#define CHUNKSIZE 1024
|
31
|
|
-//#define CHUNKSIZE 160
|
|
31
|
+#define CHUNKSIZE 160
|
32
|
32
|
//#define CHUNKSIZE 16
|
33
|
|
-#define CHUNKSIZE 3
|
|
33
|
+//#define CHUNKSIZE 3
|
34
|
34
|
#warning XXX: TODO: CHANGE CHUNKSIZE TO A SANE VALUE (not 1!), THIS IS ONLY FOR TESTING UTF-8 multi-byte CHARS
|
35
|
35
|
|
36
|
36
|
#define UNDOBLOCK 1024
|
...
|
...
|
@@ -702,6 +702,7 @@ redata_save(redata_t *redata, char *filename, char **errordesc)
|
702
|
702
|
int fd;
|
703
|
703
|
int i,n;
|
704
|
704
|
char tmpfile[PATH_MAX+1];
|
|
705
|
+ struct stat statbuf;
|
705
|
706
|
if(redata==NULL || filename==NULL) {
|
706
|
707
|
if(errordesc!=NULL)
|
707
|
708
|
*errordesc="Internal error";
|
...
|
...
|
@@ -712,7 +713,10 @@ redata_save(redata_t *redata, char *filename, char **errordesc)
|
712
|
713
|
*errordesc="Malformed filename";
|
713
|
714
|
return(-1); /* malformed filename */
|
714
|
715
|
}
|
715
|
|
- if((fd=open(tmpfile,O_WRONLY|O_TRUNC|O_CREAT,0644))==-1) {
|
|
716
|
+ memset(&statbuf,0,sizeof(statbuf));
|
|
717
|
+ if(stat(filename,&statbuf)!=0)
|
|
718
|
+ statbuf.st_mode=0644;
|
|
719
|
+ if((fd=open(tmpfile,O_WRONLY|O_TRUNC|O_CREAT,statbuf.st_mode))==-1) {
|
716
|
720
|
if(errordesc!=NULL)
|
717
|
721
|
*errordesc="Couldn't open file for writing";
|
718
|
722
|
return(-1); /* couldn't open file for writing */
|