[geany/geany] fb4fc0: Make tempFile() return MIO
Jiří Techet
git-noreply at xxxxx
Mon Dec 17 21:05:31 UTC 2018
Branch: refs/heads/master
Author: Jiří Techet <techet at gmail.com>
Committer: Jiří Techet <techet at gmail.com>
Date: Sat, 08 Oct 2016 12:12:45 UTC
Commit: fb4fc07b6a2197d5fdf9ea304c8d51d507ad5f2c
https://github.com/geany/geany/commit/fb4fc07b6a2197d5fdf9ea304c8d51d507ad5f2c
Log Message:
-----------
Make tempFile() return MIO
Modified Paths:
--------------
ctags/main/entry.c
ctags/main/routines.c
ctags/main/routines.h
Modified: ctags/main/entry.c
11 lines changed, 5 insertions(+), 6 deletions(-)
===================================================================
@@ -272,10 +272,9 @@ extern void openTagFile (void)
*/
if (TagsToStdout)
{
- FILE *fp;
-
- fp = tempFile ("w", &TagFile.name);
- TagFile.mio = mio_new_fp (fp, fclose);
+ /* Open a tempfile with read and write mode. Read mode is used when
+ * write the result to stdout. */
+ TagFile.mio = tempFile ("w+", &TagFile.name);
}
else
{
@@ -363,8 +362,8 @@ extern void copyFile (const char *const from, const char *const to, const long s
static int replacementTruncate (const char *const name, const long size)
{
char *tempName = NULL;
- FILE *fp = tempFile ("w", &tempName);
- fclose (fp);
+ MIO *mio = tempFile ("w", &tempName);
+ mio_free (mio);
copyFile (name, tempName, size);
copyFile (tempName, name, WHOLE_FILE);
remove (tempName);
Modified: ctags/main/routines.c
6 lines changed, 4 insertions(+), 2 deletions(-)
===================================================================
@@ -658,10 +658,11 @@ extern char* relativeFilename (const char *file, const char *dir)
return res;
}
-extern FILE *tempFile (const char *const mode, char **const pName)
+extern MIO *tempFile (const char *const mode, char **const pName)
{
char *name;
FILE *fp;
+ MIO *mio;
int fd;
#if defined(HAVE_MKSTEMP)
const char *const pattern = "tags.XXXXXX";
@@ -701,9 +702,10 @@ extern FILE *tempFile (const char *const mode, char **const pName)
fp = fdopen (fd, mode);
if (fp == NULL)
error (FATAL | PERROR, "cannot open temporary file");
+ mio = mio_new_fp (fp, fclose);
DebugStatement (
debugPrintf (DEBUG_STATUS, "opened temporary file %s\n", name); )
Assert (*pName == NULL);
*pName = name;
- return fp;
+ return mio;
}
Modified: ctags/main/routines.h
3 lines changed, 2 insertions(+), 1 deletions(-)
===================================================================
@@ -17,6 +17,7 @@
#include <stdio.h>
#include "vstring.h"
+#include "mio.h"
/*
* MACROS
@@ -123,7 +124,7 @@ extern vString *combinePathAndFile (const char *const path, const char *const fi
extern char* absoluteFilename (const char *file);
extern char* absoluteDirname (char *file);
extern char* relativeFilename (const char *file, const char *dir);
-extern FILE *tempFile (const char *const mode, char **const pName);
+extern MIO *tempFile (const char *const mode, char **const pName);
extern char* eStrdup (const char* str);
#endif /* CTAGS_MAIN_ROUTINES_H */
--------------
This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).
More information about the Commits
mailing list