]> code.citadel.org Git - citadel.git/commitdiff
* Remove nulls appended to editor files during replace, edit, and print
authorArt Cancro <ajc@citadel.org>
Sat, 4 Mar 2000 22:36:24 +0000 (22:36 +0000)
committerArt Cancro <ajc@citadel.org>
Sat, 4 Mar 2000 22:36:24 +0000 (22:36 +0000)
  operations.  Truncate temp files during same operations.
  Closes bugs #6 and #7.

citadel/ChangeLog
citadel/client_chat.c
citadel/client_icq.c
citadel/messages.c
citadel/messages.h
citadel/rooms.c
citadel/routines2.c

index 83a4ac8041cbf97cf0541b64e0672126334af743..db126f049ebff48ecf05dc6dcc82a6fddcf03172 100644 (file)
@@ -1,4 +1,9 @@
 $Log$
+Revision 1.477  2000/03/04 22:36:23  ajc
+* Remove nulls appended to editor files during replace, edit, and print
+  operations.  Truncate temp files during same operations.
+  Closes bugs #6 and #7.
+
 Revision 1.476  2000/03/04 05:29:18  ajc
 * Relax restrictions on editing of base rooms.  Renaming is not allowed but
   all other attributes can be edited.  Closes feature request #21.
@@ -1691,3 +1696,4 @@ Sat Jul 11 00:20:48 EDT 1998 Nathan Bryant <bryant@cs.usm.maine.edu>
 
 Fri Jul 10 1998 Art Cancro <ajc@uncnsrd.mt-kisco.ny.us>
        * Initial CVS import 
+
index 97805d157087853e6f11b13d9cd2ec7b96351315..e38f64976dda657557cd9539509a035ce58a288a 100644 (file)
@@ -40,7 +40,6 @@
 
 extern struct CtdlServInfo serv_info;
 extern char temp[];
-void citedit(FILE *fp, long int base_pos);
 void getline(char *, int);
 
 void chatmode(void) {
index 176eefd4ffd2cf51fee545449af6790415bf9c31..66a3cf27ddf953bb9a44333857010109ff8fa496 100644 (file)
@@ -33,7 +33,6 @@
 
 extern struct CtdlServInfo serv_info;
 extern char temp[];
-void citedit(FILE *fp, long int base_pos);
 void getline(char *, int);
 
 struct icq_contact {
index aa9dd081e1dde0431e2e2b15ccab04c787ea6ea2..42a048bae8d88fd9fee599449929d3dc9b7f1272 100644 (file)
@@ -186,9 +186,9 @@ void add_word(struct cittext *textlist, char *wordbuf)
 
 
 /*
- * begin editing of an opened file pointed to by fp, beginning at position pos.
+ * begin editing of an opened file pointed to by fp
  */
-void citedit(FILE *fp, long int base_pos)
+void citedit(FILE *fp)
 {
        int a,prev,finished,b,last_space;
        int appending = 0;
@@ -206,7 +206,7 @@ void citedit(FILE *fp, long int base_pos)
        time(&last_server_msg);
 
        /* first, load the text into the buffer */
-       fseek(fp,base_pos,0);
+       fseek(fp, 0L, 0);
        textlist = (struct cittext *)malloc(sizeof(struct cittext));
        textlist->next = NULL;
        strcpy(textlist->text,"");
@@ -314,12 +314,13 @@ void citedit(FILE *fp, long int base_pos)
                } while (finished==0);
 
        /* write the buffer back to disk */
-       fseek(fp,base_pos,0);
+       fseek(fp, 0L, 0);
        for (ptr=textlist; ptr!=NULL; ptr=ptr->next) {
                fprintf(fp,"%s",ptr->text);
                }
        putc(10,fp);
-       putc(0,fp);
+       fflush(fp);
+       ftruncate(fileno(fp), ftell(fp));
 
        /* and deallocate the memory we used */
        while (textlist!=NULL) {
@@ -569,8 +570,9 @@ void replace_string(char *filename, long int startpos)
                }
        fseek(fp,wpos,0);
        if (strlen(buf)>0) fwrite((char *)buf,strlen(buf),1,fp);
-       putc(0,fp);
+       wpos = ftell(fp);
        fclose(fp);
+       truncate(filename, wpos);
        printf("<R>eplace made %d substitution(s).\n\n",substitutions);
        }
 
@@ -626,7 +628,7 @@ ME1:        switch(mode) {
 
           case 0:
                fp=fopen(filename,"r+");
-               citedit(fp, beg);
+               citedit(fp);
                fclose(fp);
                goto MECR;
 
index aa43c472dbbb8030569b93ee4cbc5d92d69fc82f..887915ff81cabbdeafaad6fa245b1360796797d9 100644 (file)
@@ -12,3 +12,4 @@ int make_message(char *filename,      /* temporary file name */
                int anon_type,          /* see MES_ types in header file */
                int format_type,
                int mode);
+void citedit(FILE *);
index 2e50e99a8a6d661be1f1969cf0cac3ef339dfe8d..0f334ebabfaa79e45b51dceb4b701255552a5a24 100644 (file)
@@ -18,6 +18,7 @@
 #include "rooms.h"
 #include "commands.h"
 #include "tools.h"
+#include "messages.h"
 #ifndef HAVE_SNPRINTF
 #include "snprintf.h"
 #endif
@@ -36,7 +37,6 @@ void serv_read(char *buf, int bytes);
 void formout(char *name);
 int inkey(void);
 int fmout(int width, FILE *fp, char pagin, int height, int starting_lp, char subst);
-void citedit(FILE *fp, long int base_pos);
 void progress(long int curr, long int cmax);
 int pattern(char *search, char *patn);
 int file_checksum(char *filename);
@@ -960,7 +960,7 @@ void do_edit(char *desc, char *read_cmd, char *check_cmd, char *write_cmd)
                printf("Entering %s.  ",desc);
                printf("Press return twice when finished.\n");
                fp=fopen(temp,"r+");
-               citedit(fp,0);
+               citedit(fp);
                fclose(fp);
                }
 
index 7efce58b4937c569734555a27cd955e9a33cb2b6..d2629cd36efcd300fc2d6f3a0c4ecb452766e5ec 100644 (file)
@@ -36,7 +36,6 @@ int inkey(void);
 void serv_write(char *buf, int nbytes);
 int haschar(char *st, int ch);
 void progress(long int curr, long int cmax);
-void citedit(FILE * fp, long int base_pos);
 int yesno(void);
 
 extern char temp[];