aboutsummaryrefslogtreecommitdiff
path: root/src/hyper
diff options
context:
space:
mode:
authordos-reis <gdr@axiomatics.org>2008-09-25 04:59:08 +0000
committerdos-reis <gdr@axiomatics.org>2008-09-25 04:59:08 +0000
commite0c8f3d8155dabb7d7d54e426f56febfab77ee92 (patch)
tree4240cc0b9ec9eb01a4bf3e067a13cc74d6c7d403 /src/hyper
parente2b728ff9a53eb2ff4518ad10beb649b5e636f74 (diff)
downloadopen-axiom-e0c8f3d8155dabb7d7d54e426f56febfab77ee92.tar.gz
* include/cfuns.h (oa_copy_file): Declare.
* lib/cfuns-c.c (oa_chdir): Define. (oa_dirname): Fix typo. * hyper/htadd.c (copy_file): Remove. (build_db_filename): Tidy. (delete_file): Use oa_copy_file.
Diffstat (limited to 'src/hyper')
-rw-r--r--src/hyper/Makefile.in1
-rw-r--r--src/hyper/htadd.c29
2 files changed, 8 insertions, 22 deletions
diff --git a/src/hyper/Makefile.in b/src/hyper/Makefile.in
index 034180f3..a29c2601 100644
--- a/src/hyper/Makefile.in
+++ b/src/hyper/Makefile.in
@@ -150,6 +150,7 @@ ${HYPER}/pages/ht.db: all-hyper-pre $(srcdir)/pages/*.pht
done
@ rm -f "${HYPER}"/pages/ht.db
@ rm -f "${HYPER}"/pages/*~
+ @ touch "${HYPER}"/pages/ht.db
for f in `ls "${HYPER}"/pages/*.ht "${HYPER}"/pages/*.pht`; do \
AXIOM="$(AXIOM)" $(HTADD) -s $$f || exit 1; done
@ mkdir -p "$(HYPER)"/bitmaps
diff --git a/src/hyper/htadd.c b/src/hyper/htadd.c
index f08a6205..4e122e45 100644
--- a/src/hyper/htadd.c
+++ b/src/hyper/htadd.c
@@ -54,7 +54,6 @@
static void add_file(char*, char*, int);
static void add_new_pages(FILE*, FILE*, char*, char*);
static int build_db_filename(short, char*, char*);
-static void copy_file(char*, char*);
static void delete_db(FILE*, FILE*, char*);
static int delete_file(char*, char*);
static void get_filename(void);
@@ -217,10 +216,10 @@ build_db_filename(short flag, char *db_dir, char *dbfilename)
}
}
- if (writeablep(dbfilename) != 0)
+ if (writeablep(dbfilename) > 0)
return 1;
- fprintf(stderr, "build_db_filename: Database file name is not writable\n");
+ fprintf(stderr, "build_db_filename: '%s' is not writable\n",dbfilename);
exit(1);
return 0;
}
@@ -270,6 +269,7 @@ add_file(char *dbname, char *name, int fresh)
}
else {
if ((db_fp = fopen(dbname, "r")) == NULL) {
+ exit(-1);
}
}
if (!fresh)
@@ -284,7 +284,8 @@ add_file(char *dbname, char *name, int fresh)
if (db_fp != NULL)
fclose(db_fp);
if (!fresh) {
- copy_file(temp_db_file, dbname);
+ if (oa_copy_file(temp_db_file, dbname) < 0)
+ exit(-1);
unlink(temp_db_file);
}
}
@@ -400,23 +401,6 @@ add_new_pages(FILE *temp_db, FILE *new_file, char *addname, char *fullname)
printf("Added %3d pages and/or macros from %s\n", pages, addname);
}
-static void
-copy_file(char *f1, char *f2)
-{
- FILE *fp1, *fp2;
- int c;
-
- fp1 = fopen(f1, "r");
- fp2 = fopen(f2, "w");
- while ((c = getc(fp1)) != EOF) {
- putc(c, fp2);
- }
- fclose(fp2);
- fclose(fp1);
-}
-
-
-
#define whitespace(c) ((c) == ' ' || (c) == '\t' || (c) == '\n')
#define delim(c) \
(whitespace(c) )
@@ -481,7 +465,8 @@ delete_file(char *dbname, char *name)
fclose(temp_db_fp);
if (db_fp != NULL)
fclose(db_fp);
- copy_file(temp_db_file, dbname);
+ if (oa_copy_file(temp_db_file, dbname) < 0)
+ return -1;
unlink(temp_db_file);
return 0;
}