summaryrefslogtreecommitdiff
path: root/src/PSEditor.cxx
diff options
context:
space:
mode:
authorJohannes Hofmann <johannes.hofmann@gmx.de>2004-10-24 16:28:37 +0000
committerJohannes Hofmann <johannes.hofmann@gmx.de>2004-10-24 16:28:37 +0000
commit25da85de6a1eca08de94bbc9f1b63ae9a7c87841 (patch)
treed183c37c94d1bbdbad8b71bf8db390e3616fb551 /src/PSEditor.cxx
parenta6eb8c7fe8a52d0d2fc5d9d3cf2a186745eac3c0 (diff)
move parsing from PSEditor to PSEditModel.
move parsing from PSEditor to PSEditModel.
Diffstat (limited to 'src/PSEditor.cxx')
-rw-r--r--src/PSEditor.cxx48
1 files changed, 10 insertions, 38 deletions
diff --git a/src/PSEditor.cxx b/src/PSEditor.cxx
index d263360..bc4541e 100644
--- a/src/PSEditor.cxx
+++ b/src/PSEditor.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: PSEditor.cxx,v 1.14 2004/10/23 19:57:14 hofmann Exp $"
+// "$Id: PSEditor.cxx,v 1.15 2004/10/24 18:28:37 hofmann Exp $"
//
// PSEditor routines.
//
@@ -116,47 +116,19 @@ int PSEditor::handle(int event) {
int PSEditor::load(char *f) {
- FILE *fp;
- char tmpname[256];
- char linebuf[1024];
- int ret;
- PSParser *p1 = new PSParser_1(model);
- PSParser *p2 = new PSParser_2(model);
-
- fp = fopen(f, "r");
- if (!fp) {
- fprintf(stderr, "Could not open file %s.\n", f);
- return 1;
+ if (tmp_fd) {
+ close(tmp_fd);
+ tmp_fd = -1;
}
-
- strncpy(tmpname, "/tmp/PSEditorXXXXXX", 256);
- tmp_fd = mkstemp(tmpname);
+
+ tmp_fd = model->load(f);
if (tmp_fd < 0) {
- fprintf(stderr, "Could not create temporary file (errno %d).\n", errno);
return 1;
+ } else {
+ mod = 0;
+ loaded = 1;
+ return GsWidget::load(tmp_fd);
}
- unlink(tmpname);
-
- clear_text();
-
- while (fgets(linebuf, 1024, fp) != NULL) {
- if (!p2->parse(linebuf) && !p1->parse(linebuf)) {
- ret = write(tmp_fd, linebuf, strlen(linebuf));
- if (ret != strlen(linebuf)) {
- fprintf(stderr, "Error while writing to temporary file\n");
- }
- }
- }
-
- fclose(fp);
- lseek(tmp_fd, 0L, SEEK_SET);
-
- delete(p1);
- delete(p2);
-
- mod = 0;
- loaded = 1;
- return GsWidget::load(tmp_fd);
}
int PSEditor::save(const char* savefile) {