Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
openSUSE:Leap:42.1:Update
w3m.5344
w3m-history-crossdev.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File w3m-history-crossdev.patch of Package w3m.5344
--- history.c | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) Index: w3m-0.5.3/history.c =================================================================== --- w3m-0.5.3.orig/history.c +++ w3m-0.5.3/history.c @@ -68,11 +68,13 @@ loadHistory(Hist *hist) void saveHistory(Hist *hist, size_t size) { - FILE *f; + FILE *f, *h = NULL; HistItem *item; char *tmpf; #define FNAMELEN 255 char fname[FNAMELEN+1] = HISTORY_FILE; + char buf[4096]; + size_t rs, ws, remaining; if (hist == NULL || hist->list == NULL) return; @@ -96,7 +98,29 @@ saveHistory(Hist *hist, size_t size) strncat(fname, ".", FNAMELEN -6 - strlen(fname)); strncat(fname, Session, FNAMELEN -6 - strlen(fname)); } - rename(tmpf, rcFile(fname)); + if (rename(tmpf, rcFile(fname)) == -1 && errno == EXDEV) { + if ((f = fopen(tmpf, "r")) && (h = fopen(rcFile(fname), "w"))) { + while (1) { + rs = fread(buf, 1, sizeof(buf), f); + if (rs == 0 || rs > sizeof(buf)) + break; + ws = fwrite(buf, 1, rs, h); + if (ws == rs) + continue; + if (ws == 0 || ws > rs) + break; + remaining = rs - ws; + while (remaining > 0) { + ws = fwrite(buf + (rs - remaining), 1, remaining, h); + if (ws == 0 || ws > remaining) + break; + remaining -= ws; + } + } + } + if (f) fclose(f); + if (h) fclose(h); + } } #endif /* USE_HISTORY */
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor